ropensci / chirps

API Client for CHIRPS
https://docs.ropensci.org/chirps/
Other
31 stars 12 forks source link

as.raster = TRUE doesn't return a raster object #42

Closed adamhsparks closed 2 years ago

adamhsparks commented 2 years ago
lonlat <-
  structure(list(
    lon = c(-60.03947, -54.7838828),
    lat = c(-3.031387,
            -2.4221716)
  ),
  class = "data.frame",
  row.names = c(NA, -2L))
dates <- c("2000-01-01", "2000-01-05")
x_raster <-
  get_chirps(
    data.frame(lonlat),
    dates = dates,
    server = "ClimateSERV",
    as.raster = TRUE
  )

results in

x_raster
       id    lon   lat       date chirps
    <int>  <dbl> <dbl>     <date>  <dbl>
1:      1 -60.04 -3.03 2000-01-01   0.00
2:      1 -60.04 -3.03 2000-01-02   0.00
3:      1 -60.04 -3.03 2000-01-03   0.00
4:      1 -60.04 -3.03 2000-01-04   0.00
5:      1 -60.04 -3.03 2000-01-05  20.18
6:      2 -54.78 -2.42 2000-01-01  38.35
7:      2 -54.78 -2.42 2000-01-02   0.00
8:      2 -54.78 -2.42 2000-01-03  38.35
9:      2 -54.78 -2.42 2000-01-04   0.00
10:     2 -54.78 -2.42 2000-01-05   0.00

A data.frame object.

kauedesousa commented 2 years ago

I think it only works if the server is CHC.

adamhsparks commented 2 years ago

OK, there's no error or checks if the wrong server is used. I'll investigate further.

adamhsparks commented 2 years ago

Yes. You are correct. I'll implement a fix to emit a message and switch servers.

adamhsparks commented 2 years ago

ah, I see, it has to be a raster input. This is easier to fix. Update the documentation. :)

adamhsparks commented 2 years ago

Or maybe I just didn't read the docs closely enough. 😬