Open njtierney opened 8 months ago
(Following up a discussion with @njtierney) ... it's feasible to avoid explicit download with vsicurl
library(terra)
vect("/vsicurl/https://geodata.ucdavis.edu/gadm/gadm4.1/gpkg/gadm41_CRI.gpkg", "ADM_ADM_1")
class : SpatVector
geometry : polygons
dimensions : 7, 11 (geometries, attributes)
extent : -87.10185, -82.55232, 5.49857, 11.21976 (xmin, xmax, ymin, ymax)
source : gadm41_CRI.gpkg (ADM_ADM_1)
coord. ref. : lon/lat WGS 84 (EPSG:4326)
names : GID_1 GID_0 COUNTRY NAME_1 VARNAME_1 NL_NAME_1
type : <chr> <chr> <chr> <chr> <chr> <chr>
values : CRI.1_1 CRI Costa Rica Alajuela NA NA
CRI.2_1 CRI Costa Rica Cartago NA NA
CRI.3_1 CRI Costa Rica Guanacaste NA NA
TYPE_1 ENGTYPE_1 CC_1 HASC_1 ISO_1
<chr> <chr> <chr> <chr> <chr>
Provincia Province 2 CR.AL CR-A
Provincia Province 3 CR.CA CR-C
Provincia Province 5 CR.GU CR-G
That might provide a better ux. There are zipped GPKG with every country in them, but not as efficient to read with a query. I might make some suggestions to geodata. But another option is with CGAZ geoboundaries:
## there are ADM1 and ADM2 levels also
dsn <- "/vsizip//vsicurl/https://github.com/wmgeolab/geoBoundaries/raw/main/releaseData/CGAZ/geoBoundariesCGAZ_ADM0.zip"
vect(dsn, query = "SELECT * FROM geoBoundariesCGAZ_ADM0 WHERE shapeGroup IN ('AUS','NZL')")
class : SpatVector
geometry : polygons
dimensions : 2, 3 (geometries, attributes)
extent : -178.9278, 179.0695, -54.76208, -8.538777 (xmin, xmax, ymin, ymax)
source : geoBoundariesCGAZ_ADM0.zip
coord. ref. : lon/lat WGS 84 (EPSG:4326)
names : shapeGroup shapeType shapeName
type : <chr> <chr> <chr>
values : AUS ADM0 Australia
NZL ADM0 New Zealand
Thanks for this @mdsumner !
I think that overall from this we can address this issue in a vignette, by detailing how we would encourage people to use geotargets for things like this.
Using the vsicurl
approach here means users don't have to set a specific download file. So I think we could describe the ideal approach we would like users to use, demonstrate it, and potentially point to https://github.com/njtierney/demo-geotargets as a resource for people to look at for how this can be done?
Ok, finally getting this as I'm using gadm()
now for the first time. So, should I have one target that is the URL (e.g. tar_url(CRI_url, "https://geodata.ucdavis.edu/gadm/gadm4.1/gpkg/gadm41_CRI.gpkg")
and a tar_terra_vect()
that does something like vect(paste0("vsicurl/", CRI_url))
? It does seem like it might be nice to have a target factory for this eventually.
geodata::gadm
is commonly used to get shapefiles for countries at various levels of boundaries.This issue is to talk about how to use gadm within geotargets - related to #5.
Some code to download a country shapefile might be something like:
My question is how should we recommend that users implement and use something like this in a targets workflow? At this stage I haven't tested this code out with the latest version of {geotargets} so it might all just work, but my specific concerns are around:
Also porting in @brownag 's comment from #5 in here as it is relevant: