Open lawleyjw opened 1 month ago
Clearly the R code does not take into account the multiple polygons returned by the API @salvafern This works fine: https://marineregions.org/rest/getGazetteerGeometries.jsonld/26584/
The code was not considering a case when the geometry has one single source but two attributeValue(s) as here:
http://marineregions.org/mrgid/26584/geometries?source=80&attributeValue=25505 http://marineregions.org/mrgid/26584/geometries?source=80&attributeValue=25585
And only the first was being picked up. Should be fixed now.
library(mregions2)
library(ggplot2)
library(sf)
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
test <- gaz_geometry(26584, multipart=FALSE) #same things happens if multipart=TRUE
test_sf <- st_as_sf(test)
ggplot() +
geom_sf(data = test_sf, fill = 'blue', color = 'black') +
ggtitle("Pacific Part of Canada's EEZ") +
theme_minimal()
Created on 2024-06-03 with reprex v2.1.0
@lawleyjw Thanks a lot for spotting, please don't hesitate to raise more issues if you encountered any.
Thanks @salvafern !
I am still getting the same issue though with other regions. See example below:
> library(mregions2)
> library(ggplot2)
> library(sf)
Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
> test <- gaz_geometry(8940, multipart=FALSE) #same things happens if multipart=TRUE
> test_sf <- st_as_sf(test)
> ggplot() +
+ geom_sf(data = test_sf, fill = 'blue', color = 'black') +
+ theme_minimal()
I will have a look
I am trying to calculate the area for several marine regions and noticed that the area I was getting was smaller than expected. So I tried mapping the regions to look for inconsistencies. When I run the code below I get the image below it, but what it seems to be missing a large portion of the area that marine region should cover (see latest image). Am I missing any options with gaz_geometry or is there an issue here? I appreciate any assistance/advice.