Open andysouth opened 4 years ago
Aha, getting there, this returns a single dataset (note lowercase throughout)
querytext <- 'name:"kenya-healthsites"'
Now to see if I can get to the one shp data layer ...
Will close this if I do.
The download works but it won't open the shapefile and read into an sf object, i think because the shapefiles are within a subfolder in the zip. Is there a way of coping with that ?
library(rhdx)
rhdx::set_rhdx_config()
querytext <- 'name:"kenya-healthsites"'
datasets_list <- rhdx::search_datasets(query = querytext)
#query needs to return a single dataset (with multiple resources)
ds <- datasets_list[[1]]
#get list of resources
list_of_rs <- rhdx::get_resources(ds)
list_of_rs
#selecting resource
ds_id <- which( rhdx::get_formats(ds) %in% c("zipped shapefiles","zipped shapefile"))
rs <- rhdx::get_resource(ds, ds_id)
# find which layers in file (fails)
#mlayers <- rhdx::get_resource_layers(rs, download_folder=getwd())
#should read 1st layer by default
sflayer <- rhdx::read_resource(rs, download_folder=getwd())
#the zip does download but fails to read into R with
#Cannot open data source /vsizip/C:/rsprojects/afriadmin/kenya-shapefiles.zip
#Error in CPL_get_layers(dsn, options, do_count) : Open failed.
Hi Ahmadou,
I see that hdx has monthly updated healthsites data by country. I wonder if this could be an easier way of getting at the healthsites data.
I've been trying to do something like this to be able to identify the healthsites data but haven't been able to get it to work yet.
Any tips appreciated. Thanks, Andy