duplisea / gslea

Gulf of St Lawrence Ecosystem Approach
GNU General Public License v3.0
17 stars 1 forks source link

Zone 50 and zone 5 overlap in gslea shapefile #4

Open guiblanchet opened 3 years ago

guiblanchet commented 3 years ago

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 : https://github.com/adsmithca/gslea_vis/issues/1#issuecomment-832888469

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)
duplisea commented 3 years ago

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.

guiblanchet commented 3 years ago

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

duplisea commented 3 years ago

merci Guillaume. Daniel

On Thu, 6 May 2021 at 14:13, Guillaume Blanchet @.***> wrote:

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 https://github.com/duplisea/gslea/files/6436788/gsleaClean.zip

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/duplisea/gslea/issues/4#issuecomment-833749178, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYKQDCZA3Q3L4SJLUMXL63TMLL53ANCNFSM44FTSJJQ .