-
Notifications
You must be signed in to change notification settings - Fork 288
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
st_union (or st_erase) takes ages #901
Comments
If your coordinates are in units metre, and you want to round to mm, then you need to use a precision value of 1000, not 0.001. A value of 0.001 rounds to km. |
Weird, large, complex polygon, and performance -- this may be relevant: http://blog.cleverelephant.ca/2018/09/postgis-external-storage.html |
I liked your suggestion of setting precision expressed as distance measures. You can do this now with sf too: > st_set_precision(shape1, units::set_units(1, mm))
Simple feature collection with 2 features and 2 fields
geometry type: POLYGON
dimension: XY
bbox: xmin: 551076.2 ymin: 5190411 xmax: 575786.2 ymax: 5210671
epsg (SRID): 32633
proj4string: +proj=utm +zone=33 +datum=WGS84 +units=m +no_defs
precision: 1000
Focus A_ha geometry
1 1 3257.03 POLYGON ((560246.2 5190411,...
2 2 13661.57 POLYGON ((560356.2 5199901,... |
thank you for the reply and the hints :-) shape1.prec <- st_set_precision(shape1, units::set_units(1, mm))
shape2.prec <- st_set_precision(shape2, units::set_units(1, mm)) # the "problematic" sf
union.prec <- sf::st_union(x = shape1.prec, y = shape2.prec) |
If you have already used RSAGA to create one of the shapefiles, why don't you use it for the unioning as well. SAGA is really fast with these kind of operations 😃 . |
Thanks @edzer for this hint. It helped me a lot. I had to union quite detailed polygons of Europea landmasses (Scandinavian coastline really is an issue here :-)). I stopped |
@MxNl Just to clarify - you ended up doing your union in PostGIS? |
@LDalby: That's correct, I used PostGIS with the described trick from R with the |
I would like to simply union two polygons. One of them is created by a raster to polygon conversion using RSAGA (I assume this polygon is problematic). However, the st_union-procedure takes ages, while, unfortunately, ArcGIS finishs in seconds (which annoys me a bit!).
In ArcGIS one can set the xy-tolerance (default is 0.001), maybe this speeds up the process. I tried to reduce the precision to 0.001, as well, but the results looks really strange :-/
Here, is the code with the shapefiles:
The text was updated successfully, but these errors were encountered: