Montag, 1. März 2010

R maptools: Shapefile Polygons: Hole attribute

Problem: When I import a Shape File ( readShapePoly ) with the R package maptools, it does not seem to import that 'hole' attribute correctly. All the boolean values are set to 'FALSE'.

Solution: This attribute is not present in the shapefile itself, thus it cannot be imported. There is a function checkPolygonsHoles in the maptools package to fill out the attribute fields in your imported shapefile structure. I.e. you need to caluculate the value of that hole-field yourself, like so:

shp <- readShapePoly(...);
shp@polygons <- lapply(shp@polygons, checkPolygonsHoles);

Keine Kommentare:

Kommentar veröffentlichen