eblondel / cleangeo

Cleaning geometries from spatial objects in R

Home Page:https://github.com/eblondel/cleangeo/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running time for clgeo_Clean()

fraba opened this issue · comments

commented

I have executed clgeo_Clean() on a 6MB shapefile (you can download it from here: it's the Reg2011_WGS84 file with all features merged into one, which I renamed Ita2011_WGS84) and is still running after almost 24 hours.

This is my code:

sp <- readShapePoly('Ita2011_WGS84');
report <- clgeo_CollectionReport(sp);
clgeo_SummaryReport(report);
type valid issue_type
rgeos_validity:1 Mode :logical GEOM_VALIDITY:1
FALSE:1
NA's :0
sp.clean <- clgeo_Clean(sp);


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Hello @fraba, I've tried on Reg2011_WGS84 (In the ZIP, i didn't find any Ita2011_WGS84 shapefile). Given the high resolution of your polygon delineation, Indeed POLYGONATION (although more accurate method to fix issues) is going to be very long process. This strategy is a new experimental one i've set in cleangeo to cover more geometry issues, but still i have to think if/how the algorithm could be improved in performance.

In your case, i've tried to apply a basic BUFFER strategy, and your shapes seems well adapted to it. You should not face performance issues with it:

#packages
require(sp)
require(maptools)
require(cleangeo)

#load data
sp <- readShapePoly('Ita2011_WGS84', proj4string = CRS("+init=epsg:4326"))

#geometry report
report <- clgeo_CollectionReport(sp)
clgeo_SummaryReport(report) #report gives 2 validity issues

#using buffer strategy
#==============
system.time(sp.clean.buffer <- clgeo_Clean(sp = sp, strategy = "BUFFER"))
#system time
#----------------------
# user  system elapsed 
# 1.960   0.004   1.959

gIsValid(sp.clean.buffer)

#look at plots for detecting possible geometry alteration issues or holes issues
plot(sp[12,])
plot(sp.clean.buffer[12,], add = TRUE, col="lightblue")
plot(sp[20,])
plot(sp.clean.buffer[20,], add = TRUE, col="lightblue")

Let me know

Hi @fraba did you have time to look at the above test?