simon-smart88 / disagapp

R shiny app for disaggregation regression
https://simon-smart88.github.io/disagapp/
0 stars 0 forks source link

More covariates download #4

Open timcdlucas opened 7 months ago

simon-smart88 commented 6 months ago

Was this about adding more covariates or about improving load times by downloading them to the server (where licences permit)

timcdlucas commented 6 months ago

I was referring to just accessing more different covariates. So long term aim.

simon-smart88 commented 6 months ago

Thanks. Ones on my radar and in various states of readiness are vegetation (fcover), air pollution and african rainfall (CHIRPS). Anything else?

timcdlucas commented 6 months ago

Uuuuh, can't remember what we've said before. But nightlights, land-use, human footprint could all be useful. I've got a pdf of geospatial variables that DHS use that might be a useful reference.

Also some derived variables like "distance to national border" and "distance to water" could be useful. But again, way in the future.

simon-smart88 commented 6 months ago

Yes I remember that doc but not sure I have a copy. Nightlight and land use are already included, land use includes a built-up layer - is that the same as human footprint? https://www.arcgis.com/home/item.html?id=46cbfa5ac94743e4933b6896f1dcecfd might be a good source for the distance to water - they've released a new R package which should make it easier to incorporate. The downside is needing to authenticate which makes things less user-friendly for local use (this is already an issue for the nightlight data).

simon-smart88 commented 5 months ago

@timcdlucas

Accessing distance to water was pretty simple in the end. Tokens are stored as environment variables like for nightlights but it should be okay for users to provide them as inputs if they are running locally, but I do need to look into the security of that. The free ArcGIS account will probably suffice (at least for now).

library(arcgis)
library(terra)
library(disagapp)

shpdf <- data.frame(datapath = list.files(system.file("extdata/shapes", package="disagapp"), full.names = TRUE),
                    name = list.files(system.file("extdata/shapes", package="disagapp")))
shape <- resp_shape(shpdf)

token <- auth_client()
set_arc_token(token)

furl <- "https://landscape6.arcgis.com/arcgis/rest/services/World_Distance_to_Surface_Water/ImageServer"

flayer <- arc_open(furl)

bbox <- sf::st_bbox(shape)

ras <- arc_raster(flayer, xmin = bbox[[1]], xmax = bbox[[3]], ymin = bbox[[2]], ymax = bbox[[4]], crs = sf::st_crs(shape))

ras <- clamp(ras, upper = 300, value = FALSE)

plot(ras)
simon-smart88 commented 4 months ago

@timcdlucas Do you think this is worth having: https://dataforgood.facebook.com/dfg/tools/relative-wealth-index there's a package for interacting with their API so it shouldn't be too difficult to integrate: https://gitlab.com/dickoa/rhdx

timcdlucas commented 4 months ago

Yes definitely. I've been meaning to integrate something like this to my general mapping workflow for ages. Some of it doesn't look quite right to me (China looks lower on average than India for example). And lots of it will be driven by night lights (you can see cities pop out). But yes still definitely useful!