Open ifeanyi588 opened 1 year ago
Hi Ify,
I tried to run a simple test to geolink_chirps() function using BDI shapefile. The download seems to be fine, but I am getting the error. I believe in the processing part, specifically, when reading the shapefile. For some reason, it is expecting a path rather than using the shapefile already in the environment.
Here is a copy of the error with a traceback :
Error in if (nchar(dsn) < 1) stop("dsn
must point to a source, not an empty string.", :
the condition has length > 1
7.
st_read.character(dsn, layer, ...)
6.
st_read.default(..., quiet = quiet, stringsAsFactors = stringsAsFactors,
as_tibble = as_tibble)
5.
st_read(..., quiet = quiet, stringsAsFactors = stringsAsFactors,
as_tibble = as_tibble)
4.
sf::read_sf(shp_dt) at zonalstats_plugin.R#165
3.
zonalstats_prepshp(shp_dt = shp_dt, shp_fn = shp_fn, grid_size = grid_size) at zonalstats_plugin.R#290
2.
postdownload_processor(shp_dt = shp_dt, raster_objs = raster_objs,
shp_fn = shp_dt, grid_size = grid_size, survey_dt = survey_dt,
survey_fn = survey_fn, survey_lat = survey_lat, survey_lon = survey_lon,
extract_fun = extract_fun, buffer_size = buffer_size, survey_crs = survey_crs, ... at geolink_mach.R#119
1.
geolink_chirps(time_unit = "month", start_date = "2019-01-01",
end_date = "2019-02-01", shp_dt = bdi_sf, grid_size = 1000,
extract_fun = "mean")
Dear Daylan,
Can you take a look at this? Please let know where the error is coming from. I think I have an idea but it’s essential for you to learn how the system works.
Best regards, Ify
On Tue, Nov 7, 2023 at 9:27 PM dasalm20 @.***> wrote:
Hi Ify,
I tried to run a simple test to geolink_chirps() function using BDI shapefile. The download seems to be fine, but I am getting the error. I believe in the processing part, specifically, when reading the shapefile. For some reason, it is expecting a path rather than using the shapefile already in the environment.
Here is a copy of the error with a traceback :
Error in if (nchar(dsn) < 1) stop("dsn must point to a source, not an empty string.", : the condition has length > 1 7. st_read.character(dsn, layer, ...) 6. st_read.default(..., quiet = quiet, stringsAsFactors = stringsAsFactors, as_tibble = as_tibble) 5. st_read(..., quiet = quiet, stringsAsFactors = stringsAsFactors, as_tibble = as_tibble) 4. sf::read_sf(shp_dt) at zonalstats_plugin.R#165 3. zonalstats_prepshp(shp_dt = shp_dt, shp_fn = shp_fn, grid_size = grid_size) at zonalstats_plugin.R#290 2. postdownload_processor(shp_dt = shp_dt, raster_objs = raster_objs, shp_fn = shp_dt, grid_size = grid_size, survey_dt = survey_dt, survey_fn = survey_fn, survey_lat = survey_lat, survey_lon = survey_lon, extract_fun = extract_fun, buffer_size = buffer_size, survey_crs = survey_crs, ... at geolink_mach.R#119 1. geolink_chirps(time_unit = "month", start_date = "2019-01-01", end_date = "2019-02-01", shp_dt = bdi_sf, grid_size = 1000, extract_fun = "mean")
— Reply to this email directly, view it on GitHub https://github.com/SSA-Statistical-Team-Projects/GeoLink/issues/11#issuecomment-1800908749, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZ6JKAIQGLWNO2ZIWOYDU3YDLUZJAVCNFSM6AAAAAA6WO7GACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBQHEYDQNZUHE . You are receiving this because you authored the thread.Message ID: @.***>
Hi Ify,
I see where the problem was. In line 165 of the zonalstats_pluin.R it was trying to do an st_read() if the shp_fun was null. All i did was instead of an st_read() I just put an st_to_sf() function and it worked. However, it broke when the survey_dt argument was not written in the parameters. I put it as NULL and it worked completely. I will move forward checking how to deal with the issue of having to specify a parameter as NULL instead of not writing it at all.
When running the latest version of the code for geolink_chirps() I also got the "nchar(dsn) < 1) stop("dsn must point to a source, not an empty string issue"
I was able to isolate the issue to the following section of code (geolink_machr 117 to 119):
dt <- postdownload_processor(shp_dt = shp_dt,
raster_objs = raster_objs,
shp_fn = shp_dt,
shp_fn is set to equal shp_dt. This leads to geolink_chirps running the shp_fn section of the code when it should be null.
This should be:
dt <- postdownload_processor(shp_dt = shp_dt,
raster_objs = raster_objs,
shp_fn = shp_fn
After that fix, I am getting the error for "no applicable method for 'st_transform' applied to an object of class "c('data.table', 'data.frame')" I assume Daylan's st_to_sf() fix should work for that one
@dasalm20,
Here are some tasks for you:
Best regards, Ify