Note: Sur la suggestion de Edzer Pebesma, cette question a été crossposted à R-sig-géo, here, où il a reçu quelques bonnes réponses.Des trous dans les polygones disparaissent après avoir effectué checkPolygonsHoles de maptools
I rencontré le résultat inattendu suivant à l'aide checkPolygonsHoles
:
# attach the worldmap as SpatialPolygonsDataFrame from the package maptools
library(sp)
library(maptools)
data(wrld_simpl)
# get a polygon with a hole
shape_with_hole <- wrld_simpl[5,]
# plot it (hole is left white, surrounded by blue color)
plot(shape_with_hole, col = "blue")
# perform checkPolygonsHoles
[email protected] <- lapply([email protected], checkPolygonsHoles)
# plot again, now holes aren't recognized as such
plot(shape_with_hole, col = "blue")
# and even the original SpatialPolygonsDataFrame object is changed !?
plot(wrld_simpl[5,], col = "blue")
Un effet secondaire irritant est que l'objet original wrld_simpl
est également modifiée. Ce résultat me semble être un bug, ou ai-je raté quelque chose?
PS: l'objet shape_with_hole
édité avec checkPolygonsHoles
avant, continue à se comporter étrange:
# we check which polygons are marked as holes. The flags are still set
# properly, although the `plot` function didn't recognize them:
sapply([email protected][[1]]@Polygons, slot, "hole")
[1] FALSE TRUE TRUE TRUE
# load library rgdal for reprojection
library(rgdal)
# reproject with `spTransform`, just for testing
shape_with_hole <- spTransform(shape_with_hole,
CRS("+proj=longlat +ellps=WGS84 +datum=WGS84"))
# after reprojection all flags are set to FALSE
sapply([email protected][[1]]@Polygons, slot, "hole")
[1] FALSE FALSE FALSE FALSE
Veuillez signaler ce problème à r-sig-geo, afin que Roger puisse y jeter un coup d'œil. –
D'accord, c'est fait. – Grigory
A l'étape 1, le résultat attendu ne laisserait-il pas les trous blancs? Dans les deuxième et troisième trous, les trous sont remplis et la forme ne change pas sur ma machine. Vous devrez être plus expansif sur ce que vous obtenez et ce que votre système est configuré. Le mien est une fourche Mac SL de R 3.1.2; maptools 0.8-30; sp 1,0-17; version rgeos: 0,3-8, (révision SVN 460); Version d'exécution GEOS: 3.3.3-CAPI-1.7.4 –