mikejohnson51 / climateR

An R 📦 for getting point and gridded climate data by AOI
https://mikejohnson51.github.io/climateR/
MIT License
168 stars 40 forks source link

`st_bbox()` doesn't work with `getCHIRPS()` #22

Closed Aariq closed 3 years ago

Aariq commented 3 years ago

The example in the README using st_bbox() with getGridMET() doesn't work when it's swapped out for getCHRIPS(). The documentation doesn't seem to indicate that it should behave any differently.

library(climateR)
library(sf)
#> Linking to GEOS 3.8.1, GDAL 3.1.1, PROJ 6.3.1
AOI = st_bbox(c(xmin = -112, xmax = -105, ymax = 39, ymin = 34), crs = 4326) %>% 
  getCHIRPS(startDate = "2018-09-01")
#> Error in UseMethod("st_geometry"): no applicable method for 'st_geometry' applied to an object of class "bbox"

Created on 2020-11-23 by the reprex package (v0.3.0)

mikejohnson51 commented 3 years ago

Hi Eric,

Awesome, thank you. CHIRPS is a little bit of an odd-ball in this package since it doesn't come from a TDS server. I had forgotten to check this!

Thank you,

library(climateR)
library(sf)
#> Linking to GEOS 3.8.1, GDAL 3.1.1, PROJ 6.3.1

AOI = st_bbox(c(xmin = -112, xmax = -105, 
                ymax = 39, ymin = 34), crs = 4326) %>% 
  getCHIRPS(startDate = "2018-09-01")

plot(AOI$prcp_20180901)

Created on 2020-11-23 by the reprex package (v0.3.0)