Open layers on remote geodatabase with st_read() and a wkt_filter

Viewed 66

In R, using sf, I'm trying to open some layers in the National Hydrography Dataset cropped to my area using st_read with a wkt_filter. I always get an empty sf object; has all the column names and crs but no rows. I've made the wkt_filter much bigger than necessary. The layers are in NAD83 (EPSG 4269), which uses degrees, so I don't think that is the problem.

I once was able to open an entire layer without a wkt_filter, but it was so huge R crashed when I tried to crop it. Also, I am able to download non-spatial tables from it no problem.

Here's what I'm doing:

library(sf)
URL <- "/vsizip//vsicurl/https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/NHD/National/HighResolution/GDB/NHD_H_National_GDB.zip"
WKT <- "POLYGON ((-112.6 33.4, -103.6 33.4, -103.6 40.2, -112.6 40.2, -112.6 33.4))"

STR <- st_read( dsn=URL, layer="NHDFlowline", wkt_filter=WKT, quiet=FALSE )
STRarea <- st_read( dsn=URL, layer="NHDArea", wkt_filter=WKT, quiet=FALSE )
LAK <- st_read( dsn=URL, layer="NHDWaterbody", wkt_filter=WKT, quiet=FALSE )

Edit: I tried downloading the whole 23 GB zip locally and the same thing happens; wkt_filter returns nothing. I have successfully used wkt_filter on other zipped gdb's. NHD support says this is a standard ESRI GDB; they don't use R so can't help with this.

0 Answers
Related