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

Error in clgeo_Clean

Alectoria opened this issue · comments

Hi Emmanuel,
I came across your package when recently cleaning spatial polygons data that I derived from GADM (downloaded as .rds):

path <- your_path # adjust
test.0 <- getData("GADM", country="KEN", level=1, path=path)
clgeo_CollectionReport(test.0)
test.clean <- clgeo_Clean(test.0)

  Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_lower_td, "rgeos_difference") : 
  TopologyException: Input geom 0 is invalid: Nested shells at or near point 37.309135439999999   
  -0.14862486999999999 at 37.309135439999999 -0.14862486999999999

But this worked:

  test.1 <- getData("GADM", country="DEU", level=1, path=path)
  clgeo_CollectionReport(test.1)
  test.clean.1 <- clgeo_Clean(test.1)

Thanks for putting this package together!

Forgot to add: I am using the cleangeo_0.2 github version

sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.4 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] cleangeo_0.2 devtools_1.10.0 maptools_0.8-39 pipeR_0.6.0.6 raster_2.5-2
[6] choroplethrAdmin1_1.0.0 rgdal_1.0-4 sp_1.2-1 dplyr_0.4.3 plyr_1.8.3
[11] ggplot2_2.1.0 magrittr_1.5 data.table_1.9.6 rgeos_0.3-11

loaded via a namespace (and not attached):
[1] Rcpp_0.12.4 knitr_1.12.3 munsell_0.4.3 colorspace_1.2-6 lattice_0.20-33 R6_2.1.2 httr_1.1.0
[8] tools_3.2.3 parallel_3.2.3 grid_3.2.3 gtable_0.2.0 DBI_0.3.1 withr_1.0.1 git2r_0.14.0
[15] digest_0.6.9 lazyeval_0.1.10 assertthat_0.1 curl_0.9.7 memoise_1.0.0 scales_0.4.0 RTriangle_1.6-0.6
[22] foreign_0.8-66 chron_2.3-47

Hi Viktoria, cleangeo 0.2 (master branch in Github) is not yet released
and still in factory (in particular advanced cleaning with
triangulation, for which i still have to work in depth), so you may
expect misbehaviors or errors.

can you try to install the latest release from CRAN (0.1-1), or see if
it works for you?

In case it doesn't, i will inspect the geometry that fails, and see if
some improvement can be investigated for cleangeo 0.2

Thanks in advance,
Emmanuel

Le 26/04/2016 11:34, Viktoria Wagner a écrit :

Forgot to add: I am using the cleangeo_0.2 github version

sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.4 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] cleangeo_0.2 devtools_1.10.0 maptools_0.8-39 pipeR_0.6.0.6
raster_2.5-2

[6] choroplethrAdmin1_1.0.0 rgdal_1.0-4 sp_1.2-1 dplyr_0.4.3 plyr_1.8.3

[11] ggplot2_2.1.0 magrittr_1.5 data.table_1.9.6 rgeos_0.3-11

loaded via a namespace (and not attached):
[1] Rcpp_0.12.4 knitr_1.12.3 munsell_0.4.3 colorspace_1.2-6
lattice_0.20-33 R6_2.1.2 httr_1.1.0

[8] tools_3.2.3 parallel_3.2.3 grid_3.2.3 gtable_0.2.0 DBI_0.3.1
withr_1.0.1 git2r_0.14.0

[15] digest_0.6.9 lazyeval_0.1.10 assertthat_0.1 curl_0.9.7
memoise_1.0.0 scales_0.4.0 RTriangle_1.6-0.6
[22] foreign_0.8-66 chron_2.3-47


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#11 (comment)

Emmanuel Blondel
International Consultant | CEO
/Geographic Information Systems in Agronomy, Environment, Fishery &
Marine Sciences/
41, Avenue du Vacayrial
81370 Saint Sulpice la Pointe, France
Tel: +33 (0) 6 45 97 87 52
Email: emmanuel.blondel1@gmail.com mailto:emmanuel.blondel1@gmail.com

Yes, it worked like a charm! Problem solved.
Thanks for the suggestion and the great package!

Thanks @Alectoria
Just to be crystal clear on the differences between 0.1-1 and 0.2 still to be released:

  • In 0.1-1, i've applied a null buffer in order to fix geometries. In most of cases it is enough to fix the geometry, although it is criticized because for some specific cases, it can have side effects, such as removing holes or part of polygons.
  • In 0.2, i'm trying to extend cleangeo with advanced cleaning features such as triangulation, to deal with these specific cases, but also keep resolving geometries that could be solved by a simple buffer.
    I'm available in case you would need further clarifications

If it is ok for you we can close this specific ticket

Best
Emmanuel