Using the rgeos library to combine country polygons

Hi, I need a world map in R and it was on my Windows 10 machine R version 2.15.2 (2012-10-26), using a few lines of code. rgeos version: 0.3-4, (SVN version 438) GEOS version: 3.4.2-CAPI-1.8.2 r3921 HOWEVER, the same code does not work on the unix server where we recently installed R (version 3.3.2) , rgeos version: 0.3-21, (SVN version 540), GEOS runtime version: 3.4.2 -CAPI-1.8.2 r3921

gUnionCascaded (sPDF) execution command gives an error on a unix machine with diff rgeos package error in TopologyFunc (groupID (spgeom [ids [[i]]], id [ids [[i]]]), names (ids) [i ] ,: IllegalArgumentException: LinearRing points do not form a closed linear string.

#sample code: library(rgeos) library(rworldmap) sPDF <- getMap() poly_globe <- gUnionCascaded(sPDF) plot(poly_globe) 
+3
source share
1 answer

Ultimately, this seems to lead to problems with the dataset provided by rworldmap . The problems seem to be fixed by a quick application of clgeo_Clean() from the cleangeo package.

Try this to see that in this case:

 library(rgeos) library(rworldmap) library(cleangeo) sPDF <- getMap() sPDF <- clgeo_Clean(sPDF) poly_globe <- gUnionCascaded(sPDF) plot(poly_globe) 

enter image description here

+4
source

Source: https://habr.com/ru/post/958644/


All Articles