SSA-Statistical-Team-Projects / GeoLink

GeoLink package
1 stars 1 forks source link

geolink_electaccess() #29

Open dasalm20 opened 4 months ago

dasalm20 commented 4 months ago

I have 3 issues:

A): When I run the function for 2 years, it returns only one column names "elect_". I assume there is an issue in the paste0() part.

B) :

This is the region of Nigeria that I chose:

Screenshot 2024-05-30 at 10 40 26 AM

This is the same region after running the electricity function:

Screenshot 2024-05-30 at 10 42 14 AM

It seems that some grids were dropped, I assumed it was because of NA values, however, when I do a summary of the gridded object I get 1684 NAs.

If the function is not dropping NAs, why is it dropping those grids?

C) When using a shapefile the code runs, but when using a survey, there is not default for shp_dt. Can you make sure that this function can be run using a survey?

code used: test_dt <- geolink_electaccess(time_unit = "annual", start_date = "2020-01-01", end_date = "2022-01-01", shp_dt = shp_dt[shp_dt$ADM1_EN == "Abia",])

test_dt <- geolink_electaccess(time_unit = "annual", start_date = "2020-01-01", end_date = "2022-01-01", survey_dt = st_as_sf(hhgeo_dt[1:50], crs = 4326), buffer_size = 1000, extract_fun = "mean")

DianaJaganjac commented 3 months ago

Hi @dasalm20 , I have fixed the dates and survey issue you mention, I have tested it with this call and it works: df <- geolink_electaccess(start_date = "2018-12-31", end_date = "2019-12-31", shp_dt = shp_dt[shp_dt$ADM1_EN == "Lagos",])

As for the actual data we are getting, I am using lightscore and we should be getting back 0s and 1s and not NaN, I think this might have something to do with the raster being passed through zonalstats() ? @ifeanyi588

dasalm20 commented 3 months ago

Hi @DianaJaganjac and @ifeanyi588,

Thanks for fixing this, I am having other issues when using a survey:

geolink_electaccess(time_unit = "annual", start_date = "2020-01-01", end_date = "2022-01-01", survey_dt= st_as_sf(hhgeo_dt[1:50], crs = 4326), buffer_size = 1000, extract_fun = "mean") Error in UseMethod("st_bbox") : no applicable method for 'st_bbox' applied to an object of class "NULL"

dasalm20 commented 3 months ago

Dear @DianaJaganjac and @ifeanyi588 ,

Everything above is sorted out. The main issue now is the following:

1- Regardless of what year you input, you will get back a column for each year from 2012-2019.

2- We are only getting lightscore, I am not sure if there is demand for the other indicators. But if there is, please add it to teh function. @ifeanyi588 should be able to tells us if we only need lightscore or the others too.

This is the sample code I used:

test_dt <- geolink_electaccess(start_date = "2020-01-01", end_date = "2021-01-01", shp_dt = shp_dt[shp_dt$ADM1_EN == "Abia",])

dasalm20 commented 2 weeks ago

Dear @ifeanyi588 - @DianaJaganjac ,

Did anybody work on this function ?

Best, Daylan