Closed goergen95 closed 1 day ago
Removing those extra []
we correctly identify the geometry as empty with sf=1.0-18
.
Now I am just trying to figure out what changed between releases? sfc_is_empty
seems to be untouched since apprx. two years.
library(sf)
#> Linking to GEOS 3.13.0, GDAL 3.9.2, PROJ 9.5.0; sf_use_s2() is TRUE
packageVersion("sf")
#> [1] '1.0.18'
json <- '{"type":"Polygon","coordinates":[]}'
(x <- read_sf(json, quiet = TRUE))
#> Simple feature collection with 1 feature and 0 fields (with 1 geometry empty)
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: NA ymin: NA xmax: NA ymax: NA
#> Geodetic CRS: WGS 84
#> # A tibble: 1 × 1
#> geometry
#> <POLYGON [°]>
#> 1 EMPTY
st_is_empty(x)
#> [1] TRUE
Created on 2024-10-29 with reprex v2.1.1
Also note the difference in WKT: (EMPTY)
vs EMPTY
(the former being no WKT). The change was here: https://github.com/r-spatial/sf/commit/436c2938eefac117013b446af97cb7e09488af50 in geom-predicates.R
: we stop using the GEOS function but use the built-in, which is more strict.
However,
'{"type":"MultiPolygon","coordinates":[[[]]]}' |> read_sf() |> st_is_empty()
## [1] FALSE
Cool, thank you! Any plans on when 1.0-19
will land on CRAN?
CRAN likes updates to occur less than bimonthly; I don't consider this a bug fix but rather a "grey zone" fix, so would like to wait a while.
When reading a GeoJSON string like the one below
st_is_empty()
returnedTRUE
withsf <= 1.0-17
. The example JSON is not entirely constructed, since the output ofgdalinfo
in some cases might return such a string which we are relying on correctly identifying as empty inmapme.biodiversity
. I am not at all sure what is causing this, so I'd appreciate any help on this.Created on 2024-10-28 with reprex v2.1.1