Closed goergen95 closed 11 months ago
Please use Markdown Code blocks (use: ``) to wrap your code, or, even better, use the [
{reprex}`](https://reprex.tidyverse.org/) package to provide a reproducible example in a very clear format. This is reall hard to read!
To me this looks like none of the assets in your portfolio intersects with the mangrove data layer thus in the value
column you should find just NA
s. Could you please confirm if this is the case?
Hello,
Alright, sorry about that.
Yes the value column is just NAs, whereas I know my protected areas contains mangroves ... And the gmw ressources have been well and fully downloaded.
Thanks again
Could you somehow share some of those geometries?
For instance, I have Moheli National Park (WDPAID = 313046) , Sao Tomé Natural Park (124355), Ankarea(555548848), Ankivonjy (555548847), Nanumea (555547863), Helen Reef Convervation Area (555645473)
Could you please Export them to Geopackage and Post theme here or somewhere else?
Here is a sample of coastal PAs
Hello, Does this file work for you?
Yes, the following code works for me:
library(mapme.biodiversity)
library(sf)
st_read("ecos_cot_shp.shp") %>%
st_cast("POLYGON") %>%
init_portfolio(years = 2010,
outdir = "data",
tmpdir = "data/tmp",
cores = 4,
aria_bin = "/usr/bin/aria2c",
add_resources = TRUE) %>%
get_resources(resources = "gmw") %>%
calc_indicators(indicators = "mangroves_area") %>%
dplyr::select(mangroves_area) %>%
tidyr::unnest(mangroves_area)
Do you get any more error/warning messages that could help us?
You mean you get some value of extent of mangroves (no NA) ?
Yes, for the polygons that do intersect with the mangrove layer. Could you please run the above code and also report the version of mapme.biodiversity you are using?
'Reading layer 'BDD_SHP_nodupl' from data source /Users/lea/Desktop/AP/base/BDD_SHP_nodupl.shp' using driver
ESRI Shapefile'
Simple feature collection with 88 features and 80 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -171.9129 ymin: -24.17141 xmax: 179.0909 ymax: 33.80984
Geodetic CRS: WGS 84
Starting process to download resource 'gmw'........
Checking URLs for existence. This may take a while...
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=02m 05s
Translating shapefiles to GeoPackages. This may take a while....
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=21s
Simple feature collection with 152 features and 1 field
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -171.9129 ymin: -24.17141 xmax: 179.0909 ymax: 33.80984
Geodetic CRS: WGS 84
A tibble: 152 × 2
value geometry
It seems there is still only NA ...
I use the mapme version 0.2.1 ...
I'm now trying to calculate some indicators such as mangroves area evolution with these codes :
----- Mangrove Area -----
download relevant data
afd_portfolio2<- get_resources(afd_portfolio, resources = c("gmw") )
calculate indicators
afd_portfolio2<- calc_indicators(x = afd_portfolio2, indicators = "mangroves_area", overwrite=T)
unnest results data for further analysis
colnames(afd_portfolio2) # check the columns at the end to derive the relevant column names afd_mangroves<-tidyr::unnest(afd_portfolio2, cols="mangroves_area")
view unnested data (only relevant columns are selected for the view and geometry is dropped)
colnames(afd_mangroves) # check the columns at the end to derive the relevant column names afd_mangroves %>% sf::st_drop_geometry() %>% dplyr::select(ID_pr,WDPAID,year,mangrove_extent) %>% View()
However, when I run "colnames(afd_mangroves) ", I get :
WHERE you can see there is no "year" column, nor "mangrove_extent" column, so I'm getting an error message " Can't subset columns that don't exist".
Why don't the year and mangrove_extent appear ?
Thank you so much
Originally posted by @APAF13 in https://github.com/mapme-initiative/mapme.biodiversity/issues/102#issuecomment-1286186725