duplisea/gslea

Zone 50 and zone 5 overlap in gslea shapefile

Opened this issue · 3 comments

I posted this issue on the gslea_vis repository maintained by Andrew Smith (@adsmithc) where the gslea shapfile are available (gslea_shp) and Andrew suggest that I post it here. Here is a link to the answer Andrew gave me : adsmithca/gslea_vis#1 (comment)

I have been playing with the gslea shapefile available on gslea_vis and I do not know if it is on purpose, but I found that the polygon defining zone 5 in gslea_shp is actually under the polygon that defines zone 50. I understand why the decision to build the SpatialPolygons object this way could be make sense. However, this overlap can also easily cause mistakes.

Regardless of the reason why these two polygons overlap, I suggest to mention this particularity of the polygon somewhere. It would also be worth it to give a bit of code explaining how to remove the section of zone 5 under zone 50. In case that could be of some help, bellow is bit of code I wrote to do this task.

library(rgdal)
library(rgeos)

# Read the shapefile
gsleaMap <- readOGR("gslea_shp")

# Split polygons 5 to remove the overlap with 50
gsleaMapSplit <- gDifference(gsleaMap[5,], gsleaMap[9,])

# Make sure polygon ID match with previous one
gsleaMapSplit@polygons[[1]]@ID <- "4"

# Add the data
gsleaSplit <- SpatialPolygonsDataFrame(gsleaMapSplit,
                                       data = gsleaMap[5,]@data)

# Build a list of spatial polygons
gsleaList <- list(gsleaMap[1,],
                  gsleaMap[2,],
                  gsleaMap[3,],
                  gsleaMap[4,],
                  gsleaSplit,
                  gsleaMap[6,],
                  gsleaMap[7,],
                  gsleaMap[8,],
                  gsleaMap[9,])

# Build the new SpatialPolygons
gslea <- SpatialPolygons(lapply(gsleaList, function(x){x@polygons[[1]]}),
                         proj4string = gsleaMap@proj4string)

Thanks very much Guillaume. I also am not sure why the polygons were made that way, it was decided by others to make the polysets like that. The good thing is that is does not make a difference to the data when extracted by EAR but I agree that when someone wants to take the polyset and make their )own maps it is problematic. We did not create the shapefile you are using though, I think Andrew made it from the polyset (that still has the issue you are talking about). Would you mind sending me a copy of your shapefile with zones 5 and 50 separated and I can put it in the data directory? Alternatively, you could make a pull request to get it in there. That way we could solve the overlapping polygons problem and also have a proper shapefile for people to use for their own plots if they wish. Thanks Dan.

Hi ! Here is the shapefile (and all the other related files) saved in the .zip file. I gave it a different name in case you want to have look to compare with the original one. As a note, I built this shapefile using R and I did not check how it reads other software (e.g. ArcGIS).

gsleaClean.zip