Closed k6adams closed 1 year ago
{sf}
uses two different engines for calculations, GEOS for planar geometry (e.g. EPSG:5070) and S2 for spherical geometry (e.g. EPSG:4326), hence different results may come. I also checked the GEOS bindings and it seems the results here are more what you expect? But this also probably works like rowwise()
.
geos::geos_union(buffers_5070$buffer, buffers_5070$lag_buffer)
#> <geos_geometry[4] with CRS=NAD83 / Conus Albers>
#> [1] <POLYGON [1447169 763770...1467169 783770]>
#> [2] <MULTIPOLYGON [1334483 763770...1467169 878587]>
#> [3] <MULTIPOLYGON [1223922 858587...1354483 974995]>
#> [4] <MULTIPOLYGON [1115513 954995...1243922 1072936]>
{sf}
uses two different engines for calculations, GEOS for planar geometry (e.g. EPSG:5070) and S2 for spherical geometry (e.g. EPSG:4326), hence different results may come. I also checked the GEOS bindings and it seems the results here are more what you expect? But this also probably works likerowwise()
.geos::geos_union(buffers_5070$buffer, buffers_5070$lag_buffer) #> <geos_geometry[4] with CRS=NAD83 / Conus Albers> #> [1] <POLYGON [1447169 763770...1467169 783770]> #> [2] <MULTIPOLYGON [1334483 763770...1467169 878587]> #> [3] <MULTIPOLYGON [1223922 858587...1354483 974995]> #> [4] <MULTIPOLYGON [1115513 954995...1243922 1072936]>
I have a vague understanding that 5070 uses GEOS, and 4326 uses s2. But yeah, I am expecting the output you are getting from geo_union()
to be produced by st_union()
.
@edzer should this be closed? Is the expectation that end user should know that st_union() produces a data product of different dimensions depending on the underlying geo engine? If that is the case, some indication of that in the function documentation would be a great addition. just hoping to spare people time/grief/confusion. I recognize that you likely leave your hands full and this would not be high priority.
Yes, it is necessary that users do grasp the difference between planar anf spherical geometries. Please provide a PR if you can improve the documentation. Using geos will use a different, usually older, GEOS, and avoid checks trapping misuse of planar predicates and operations on spherical geometries.
@edzer forgive me, I am relatively ignorant when it comes to spatial and GitHub. Two questions…
What is PR?
Also, I understand that the user should have a know the difference between vs spherical and planar geometries. But I am failing to comprehend how the dimensionality of the sf output produced by the st_union function is related.
Should I have known that the union of the planar geometries would result in a cross product change in the data’s dimensionality?, and that the union of the spherical representations would result in no change in the structure/dimensions of the data?
I closed it because it didn't point to something that is not already widely known: that doing geometrical operation on the plane or on the sphere are very different activities, and are provided by software libraries interfaced by sf
that have a very different history (GEOS and s2geometry). It would have been helpful if someone had ironed out all the differences between these two libraries, but that hasn't happened.
Also, your example involves a lot of different commands, the section marked with # Doesn't work, in 5070
works for me, it uses lag
and rowwise
which I've never used and so don't understand how they relate to your problem. To get help, reduce your problem to a minimal reproducible example that doesn't use tidyverse but just those sf
commands that illustrate your problem.
Issue A colleague and I recently discovered that
st_union()
changes its' join behavior depending on the Coordinate Reference System used.In following example,
st_union()
is tasked with joining two geometry columns.st_union()
works as expected. For each row in the data, the union of the geometries is found.st_union()
attempts a cross join and fails to execute. It tries turning 4 geometries into 16.Specifying
rowwise()
prior to the union resolves the error. So something about the wayst_union()
is specifying the join must be inconsistent.I have not checked other CRSs.
Example