SSA-Statistical-Team-Projects / GeoLink

GeoLink package
0 stars 1 forks source link

geolink_population() #48

Open dasalm20 opened 1 month ago

dasalm20 commented 1 month ago

Dear @DianaJaganjac,

I have tested the population function and it is currently failing. These are my findings:

  1. The name set is not being created properly. In lines 587 it is expecting a start and end year, but we do not pass on those arguments to the function. Thus, the name_set is null

I think that once it is created properly, the function should run without any issues.

This is the code that I am using:

test_dt <- geolink_population(iso_code = "NGA", UN_adjst = "N", constrained = "Y", shp_dt = shp_dt[shp_dt$ADM1_EN == "Abia",], grid_size = 1000, extract_fun = "mean", file_location = "/Users/nikos/Documents/temp")

dasalm20 commented 2 weeks ago

@DianaJaganjac ,

I tested the latest function for population and I get the following error:

test_dt <- geolink_population(iso_code = "NGA", UN_adjst = "N", constrained = "Y", shp_dt = shp_dt[shp_dt$ADM1_EN == "Abia",], grid_size = 1000, extract_fun = "mean", file_location = "/Users/nikos/Documents/temp") trying URL 'https://data.worldpop.org/GIS/Population/Global_2000_2020_Constrained/2020/maxar_v1/NGA/nga_ppp_2020_constrained.tif' Content type 'image/tiff' length 52433902 bytes (50.0 MB)

downloaded 50.0 MB

[1] "Population Raster Downloaded" [1] "Initiating shape object tesselation" [1] "Tesselation complete for shapefile extent, ensuring validity of shapefile ..." [1] "Limiting tesselated object to shapefile area ..." [1] "The shapefile is fully gridded!!" [1] "Ensuring geometries are properly fixed" [1] "The tesselated object represents a total area of 5171 km^2" [1] "The plot window should show you a distribution of the polygon sizes" [1] "Extracting raster/vector data into shapefile" [1] "CRS of raster objects: WGS 84" |============================================================================| 100% |============================================================================| 100% Error in if (!setting_geom) { : missing value where TRUE/FALSE needed In addition: Warning messages: 1: attribute variables are assumed to be spatially constant throughout all geometries 2: In st_collection_extract.sf(add_dt) : x contains no geometries of specified type

DianaJaganjac commented 2 weeks ago

Hi Daylan,

I just used this example and it worked for me:

Example usage

df <- geolink_population(iso_code = "NGA", UN_adjst = "N", constrained = "Y", shp_dt = shp_dt[shp_dt$ADM1_EN == "Abia",], grid_size = 1000, extract_fun = "mean", file_location = "C:/Users/Diana Jaganjac/Documents/New folder")

Please try again and let me know if it works for you.

You might need to double check your file location where you are downloading the data to.

Best wishes,

Diana

dasalm20 commented 2 weeks ago

Hi Diana,

You are right, I think the issue was with the file_location. I will further test it and let you know.

Best, Daylan