SSA-Statistical-Team-Projects / GeoLink

GeoLink package
0 stars 1 forks source link

geolink_chirps() #27

Closed dasalm20 closed 6 days ago

dasalm20 commented 1 month ago
  1. When I run the geolink_chirps() for the monthly time unit using a survey , I get this error:

Error in unclass(x)[i] : invalid subscript type 'list'

code : test_dt <- geolink_chirps(time_unit = "month", start_date = "2020-01-01", end_date = "2020-05-01", survey_dt = st_as_sf(hhgeo_dt[1:10], crs = 4326), buffer_size = 1000, extract_fun = "mean")

  1. This might not be as urgent but when inputing a date in the wrong format, we do not get the expected error message:

expected error: "start_date argument is not a Date, did you specify it in the form as.Date('yyyy-mm-dd')

actual error: "Error in charToDate(x) : character string is not in a standard unambiguous format"

Although we still get an error about the date, this means that the code in downloadplugin_chirps_internal.R is not correctly displaying the error messaged that it is meant to display.

code : geolink_chirps(time_unit = "month", start_date = "12-2020-01", end_date = "2020-12-01", shp_dt = shp_dt[shp_dt$ADM1_PCODE == "NG001",], grid_size = 1000, extract_fun = "mean")

ifeanyi588 commented 3 weeks ago

@dasalm20,

I just ran the geolink_chirps() function and it worked. See console transcript below:

geolink_chirps(time_unit = "month", start_date = "2020-01-01", end_date = "2020-05-01", shp_dt[shp_dt$ADM1_PCODE == "NG001",], grid_size = 1000, extract_fun = "mean") trying URL 'https://data.chc.ucsb.edu/products/CHIRPS-2.0/global_monthly/tifs/chirps-v2.0.2020.01.tif.gz' Content type 'application/x-gzip' length 14474246 bytes (13.8 MB) downloaded 13.8 MB

trying URL 'https://data.chc.ucsb.edu/products/CHIRPS-2.0/global_monthly/tifs/chirps-v2.0.2020.02.tif.gz' Content type 'application/x-gzip' length 14550346 bytes (13.9 MB) downloaded 13.9 MB

trying URL 'https://data.chc.ucsb.edu/products/CHIRPS-2.0/global_monthly/tifs/chirps-v2.0.2020.03.tif.gz' Content type 'application/x-gzip' length 14504705 bytes (13.8 MB) downloaded 13.8 MB

trying URL 'https://data.chc.ucsb.edu/products/CHIRPS-2.0/global_monthly/tifs/chirps-v2.0.2020.04.tif.gz' Content type 'application/x-gzip' length 14478524 bytes (13.8 MB) downloaded 13.8 MB

trying URL 'https://data.chc.ucsb.edu/products/CHIRPS-2.0/global_monthly/tifs/chirps-v2.0.2020.05.tif.gz' Content type 'application/x-gzip' length 14540160 bytes (13.9 MB) downloaded 13.9 MB

[1] "Global Rainfall 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" |====================================================================================================================================| 100% |====================================================================================================================================| 100% |====================================================================================================================================| 100% |====================================================================================================================================| 100% |====================================================================================================================================| 100% [1] "Process Complete!!!" Simple feature collection with 5171 features and 13 fields Attribute-geometry relationships: constant (13) Geometry type: POLYGON Dimension: XY Bounding box: xmin: 7.14037 ymin: 4.821783 xmax: 7.987652 ymax: 6.042544 Geodetic CRS: GEOGCRS["unknown", DATUM["World Geodetic System 1984", ELLIPSOID["WGS 84",6378137,298.257223563, LENGTHUNIT["metre",1]], ID["EPSG",6326]], PRIMEM["Greenwich",0, ANGLEUNIT["degree",0.0174532925199433], ID["EPSG",8901]], CS[ellipsoidal,2], AXIS["longitude",east, ORDER[1], ANGLEUNIT["degree",0.0174532925199433, ID["EPSG",9122]]], AXIS["latitude",north, ORDER[2], ANGLEUNIT["degree",0.0174532925199433, ID["EPSG",9122]]]] First 10 features: poly_id ADM0_EN ADM0_PCODE ADM1_EN ADM1_PCODE ADM2_EN ADM2_PCODE poly_area rainfall_month1 rainfall_month2 rainfall_month3 1 1 Nigeria NG Abia NG001 Ukwa East NG001013 1 [km^2] 20.60878 14.98678 171.5479 2 10 Nigeria NG Abia NG001 Ukwa East NG001013 1 [km^2] 20.60878 14.98678 171.5479 3 100 Nigeria NG Abia NG001 Ukwa West NG001014 1 [km^2] 25.41247 16.51105 165.3354 4 1000 Nigeria NG Abia NG001 Aba North NG001001 1 [km^2] 10.61048 13.55089 153.9194 5 1001 Nigeria NG Abia NG001 Aba North NG001001 1 [km^2] 10.38497 13.79487 154.2887 6 1002 Nigeria NG Abia NG001 Aba North NG001001 1 [km^2] 10.38497 13.79487 154.2887 7 1003 Nigeria NG Abia NG001 Aba North NG001001 1 [km^2] 10.38497 13.79487 154.2887 8 1004 Nigeria NG Abia NG001 Aba North NG001001 1 [km^2] 10.38497 13.79487 154.2887 9 1005 Nigeria NG Abia NG001 Obi Ngwa NG001009 1 [km^2] 10.85151 13.68049 154.9910 10 1006 Nigeria NG Abia NG001 Obi Ngwa NG001009 1 [km^2] 13.16735 13.11274 158.4767 rainfall_month4 rainfall_month5 geometry 1 178.5929 247.9682 POLYGON ((7.474147 4.821783... 2 178.5929 247.9682 POLYGON ((7.483162 4.821796... 3 157.4339 212.5323 POLYGON ((7.492178 4.82181,... 4 155.7131 211.0143 POLYGON ((7.465118 4.830813... 5 156.3532 211.8019 POLYGON ((7.474133 4.830827... 6 156.3532 211.8019 POLYGON ((7.483149 4.83084,... 7 156.3532 211.8019 POLYGON ((7.492165 4.830854... 8 156.3532 211.8019 POLYGON ((7.438056 4.839815... 9 158.1047 212.8654 POLYGON ((7.447072 4.839829... 10 166.7988 218.1448 POLYGON ((7.456088 4.839843... 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

dasalm20 commented 3 weeks ago

Hi @DianaJaganjac , Can you run this code? I just ran it and it gives me : Error in unclass(x)[i] : invalid subscript type 'list'

test_dt <- geolink_chirps(time_unit = "month", start_date = "2020-01-01", end_date = "2020-05-01", survey_dt = st_as_sf(hhgeo_dt[1:10], crs = 4326), buffer_size = 1000, extract_fun = "mean")

DianaJaganjac commented 3 weeks ago

@dasalm20 I think the difference I see here is that you are running a survey and Ify is running a shapefile?

dasalm20 commented 2 weeks ago

@ifeanyi588, I keep getting this error when running it for a survey: Error in unclass(x)[i] : invalid subscript type 'list'

Can you run this code : geolink_chirps(time_unit = "month", start_date = "2020-01-01", end_date = "2020-05-01", survey_dt = st_as_sf(hhgeo_dt[1:10], crs = 4326), buffer_size = 1000, extract_fun = "mean")

ifeanyi588 commented 1 week ago

@ifeanyi588, the solution to the issue with error reformatting for readability is one of workflow. Streamline the process of user inputting dates and how it is checked.