-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nhd_query, use polygon/bbox to select #85
Comments
Happy to help with this. Could you provide some sample code for testing? Do you mean the documentation for the |
Thank you. The documentation I'm referring to is ?nhd_query. As I read it, I provide lon and lat in degrees and buffer_dist, also in degrees. The fact that the default buffer_dist is 0.05 suggests it is degrees. However, as shown below, I can raise buffer_dist to 2, which would be about 1/4 of Colorado and should contain many thousands of flowlines. Yet I get 0. I can get some if I raise it to many thousand. The output suggests that, for some reason, the point is being converted to UTM, so I assume that's why buffer_dist is interpreted as meters, not degrees. The flowline object is also in UTM. I don't understand this behavior.
|
I'd recommend specifying the buffer_dist as a units object instead of a bare numeric. This was in the nhd_plus_query docs but not nhd_query. I'll push a commit syncing the two shortly. At 40 deg lat, 2 deg is approximately 190 km, so the call would be: fl <- nhd_query(lon = -107.2, lat = 39.45,
dsn = "NHDFlowline", buffer_dist = units::set_units(190, "km")) |
Thank you. Speaking of nhd_plus_query, my other question. It allows selecting by a polygon, which is what I would prefer, but nhd_query does not. Could it, or is there a reason why not? To be honest, I sought out nhdR because I was unable to get st_read to work on NHD gdb's with wkt_filter, which allows selecting with a polygon. This does work with other spatial gdb layers, but for some reason not with NHD. Are you aware of why that might be? |
Just not implemented yet. I wasn't using NHD (regular) when I developed the wkt_filter functionality. Giving it a try on nhd_query now... |
Should work now, with something like: library(nhdR)
bbox <- sf::st_bbox(
c(xmin = -107.45, ymin = 39.2, xmax = -106.95, ymax = 39.7),
crs = 4326)
qry_lines <- nhd_query(poly = sf::st_as_sfc(bbox), dsn = "NHDFlowline")
nrow(qry_lines$sp$NHDFlowline) # == 17199 |
Awesome, thank you. |
nhd_plus_query allows the use of a polygon, but nhd_query does not. Would be nice if it did.
The point + buffer gives me 0 features. It's unclear if I can just use lon/lat for the point or it requires an sf point object broken somehow into lon and lat.
Edit: it looks like my lon/lat point is being converted to UTM in meters, which is why my buffer_dist in degrees is not working. This is way out of line with the documentation.
The text was updated successfully, but these errors were encountered: