-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
Description
SDA_spatialQuery(..., addFields) only works for sapolygon, mupolygon, mupoint, and muline, but not for mukey, areasymbol, featpoint, or featline. There is no specific documentation to reflect this limitation, and ultimately it was not intended to be limited to spatial results only.
I think I may have recognized this as an issue in #414 but did not fix it at that time
Reprex:
library(soilDB)
point_sf <- sf::st_as_sf(data.frame(wkt = "POINT (-120.85 37.75)"),
wkt = "wkt",
crs = "EPSG:4236")
# silent
areasymbol <- SDA_spatialQuery(point_sf, what = "areasymbol", addFields = "legend.areaname")
areasymbol
#> areasymbol
#> 1 CA644
# works as expected
sapolygon <- SDA_spatialQuery(point_sf, what = "sapolygon", addFields = "legend.areaname")
sapolygon
#> Simple feature collection with 1 feature and 3 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -121.2414 ymin: 37.3995 xmax: -120.3879 ymax: 37.83287
#> Geodetic CRS: WGS 84
#> areasymbol areaname area_ac
#> 1 CA644 Eastern Stanislaus Area, California 470272.9
#> geom
#> 1 POLYGON ((-120.6414 37.8241...
# works as expected
mupolygon <- SDA_spatialQuery(point_sf, what = "mupolygon", addFields = "mapunit.muname")
mupolygon
#> Simple feature collection with 1 feature and 3 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -120.8593 ymin: 37.7401 xmax: -120.8428 ymax: 37.74836
#> Geodetic CRS: WGS 84
#> mukey muname area_ac
#> 1 462643 Madera sandy loam, 0 to 2 percent slopes 84.45869
#> geom
#> 1 POLYGON ((-120.8571 37.7433...
# works without error (muline are really rare)
muline <- SDA_spatialQuery(point_sf, what = "muline", addFields = "mapunit.muname")
muline
#> NULL
# works without error (mupoint are really rare)
mupoint <- SDA_spatialQuery(point_sf, what = "mupoint", addFields = "mapunit.muname")
mupoint
#> NULL
# broken
featpoint <- SDA_spatialQuery(sf::st_buffer(point_sf, 10000),
what = "featpoint",
addFields = "featpoint.featsym")
#> Warning in sprintf("INNER JOIN featdesc ON geom_data.featkey =
#> featdesc.featkey", : one argument not used by format 'INNER JOIN featdesc ON
#> geom_data.featkey = featdesc.featkey'
featpoint
#> [1] "Error : \r\nInvalid query: The multi-part identifier \"featpoint.featsym\" could not be bound.\n"
#> attr(,"class")
#> [1] "try-error"
#> attr(,"condition")
#> <simpleError:
#> Invalid query: The multi-part identifier "featpoint.featsym" could not be bound.>
# broken
featline <- SDA_spatialQuery(sf::st_buffer(point_sf, 10000),
what = "featline",
addFields = "featline.featsym")
#> Warning in sprintf("INNER JOIN featdesc ON geom_data.featkey =
#> featdesc.featkey", : one argument not used by format 'INNER JOIN featdesc ON
#> geom_data.featkey = featdesc.featkey'
featline
#> [1] "Error : \r\nInvalid query: The multi-part identifier \"featline.featsym\" could not be bound.\n"
#> attr(,"class")
#> [1] "try-error"
#> attr(,"condition")
#> <simpleError:
#> Invalid query: The multi-part identifier "featline.featsym" could not be bound.>Reactions are currently unavailable