[R-sig-Geo] Even simpler TM_WORLD_BORDERS_SIMPLE

Hans-Jörg Bibiko bibiko at eva.mpg.de
Thu Jan 29 22:15:44 CET 2009


On 29.01.2009, at 16:49, Jonathan Callahan wrote:
> Is anyone aware of an even more simplified version of the data that  
> went
> into creating TM_WORLD_BORDERS_SIMPL-0.2.RData so that we might have
> TM_WORLD_BORDERS_LOWRES.RData for use cases like my own.

A very quick solution would be to filter out all irrelevant small  
polygons (islands).
[to reduce the number of polygon points would lead to very unshaped  
boundaries, I mean]

What is an irrelevant polygon? My first approach is if a country  
consists of more than 2 polygons then draw only those which are  
greater than a given area let's say 0.1 .

To achieve that without recreating the entire SpatialPolygonsDataFrame  
one could simply change the plotOrder of each PolygonsList and save it.

Like that quick&dirty script:

library("maptools")
load(url("http://spatial.nhh.no/R/etc/ 
TM_WORLD_BORDERS_SIMPL-0.2.RData"))
wrld_simpl <- wrld_simpl[wrld_simpl$NAME != "Antarctica",]
for (i in (1:length(wrld_simpl at polygons))) {
   polyCnt <- length(wrld_simpl at polygons[[i]]@Polygons)
   if(polyCnt > 2) {
     pO <- sapply(wrld_simpl at polygons[[i]]@Polygons, function(x)  
{slot(x,'area')>0.1})
     new_pO <- pO[ wrld_simpl at polygons[[i]]@plotOrder ]
     wrld_simpl at polygons[[i]]@plotOrder <-  
wrld_simpl at polygons[[i]]@plotOrder[ new_pO ]
   }
}
save(wrld_simpl,'SIMPLEMAP.Rdata')



--Hans




More information about the R-sig-Geo mailing list