Closed dasalm20 closed 1 month ago
Hi Daylan, I just ran this and it works, could you try again?
Best wishes, Diana
Dear @DianaJaganjac ,
I tried running the code the past days and I get the same error. Did you move your code to the R folder?
Dear @DianaJaganjac ,
The function seems to work only for a shapefile. One thing to note is that in your function, you are reading the tiff with terra and then reading them again with raster. We need to fix that. In the testings, using raster is fine because it is a small area, but when trying to a whole country the terra package is way faster. That is when we see a big difference.
@ifeanyi588,
The function for buildings is breaking when using a survey. In line 237 of the zonalstats_plugin.R in the postdownload_processor(), there is an else if statement:
else if (!missing(shp_dt)){ shp_dt <- zonalstats_prepshp(shp_dt = shp_dt, grid_size = grid_size) }
When passing a survey, the shp_dt is NULL, and for some reason it is still running:
shp_dt <- zonalstats_prepshp(shp_dt = shp_dt, grid_size = grid_size)
Rather than computing the zonal prep to the survey.
I did not go ahead a made any changes because I was not a 100% sure, and I did not want to mess any of your code.
This is the code that reproduces the error with the survey:
test_dt <- geolink_buildings(version = "v1.1", iso_code = "NGA", survey_dt = st_as_sf(hhgeo_dt[1:50], crs = 4326))
Best regards, Daylan
@dasalm20 Do you get that error in other functions when extracting into a survey? If not, the building function itself will need to be fixed.
Dear @ifeanyi588,
I think the issue is with the building function. Let me explain, see image below ( from the chirps function).
When passing a survey:
The building function goes into line 238, which results in an error because our shp_dt is NULL.
The chirps function, on the other hand, does go into line 245, which is what the buildings function should do.
Could you run the following on debug mode to make sure I am not the only one getting this error?
test_dt <- geolink_buildings(version = "v1.1", iso_code = "NGA", survey_dt = st_as_sf(hhgeo_dt[1:50], crs = 4326))
Let me know if you have any questions.
Best, Daylan
Hi Diana,
When I ran this : test_dt <- geolink_buildings(version = "v1.1", iso_code = "NGA", shp_dt = shp_dt[shp_dt$ADM1_PCODE == "NG001",])
I got the following error, could you please rerun the code and check the output?
Error in UseMethod("st_as_sf") : no applicable method for 'st_as_sf' applied to an object of class "NULL" 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