mikejohnson51 / climateR

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

Error in masking #68

Closed Heed725 closed 1 year ago

Heed725 commented 1 year ago

Hello guys, @mikejohnson51 and @raspodia Hopefully you're doing well,I had a question on climateR..... there's been an update everything have been going well on this code except one part on masking

library(terra) library(rasterVis) library(sf) library(climateR) library(RColorBrewer) library(raster)

Get 6 years of tmax data for New York

KGZ <- st_read("c:/Dodoma.shp") plot(KGZ)

test_data <- getTerraClim( KGZ, varname = "ppt", startDate = "2010-01-01", endDate = "2019-12-31" ) index = rep(1:10, each = 12)

annualmax = app(rast(test_data$ppt), fun = "mean") |> mask(vect("c:/Dodoma.shp"))

Plot

levelplot(annualmax, par.settings = rasterTheme(region = brewer.pal('blues', n = 9)), names.attr = as.character(c(2010:2019)))

The annual max part is giving me error

Error: [mask] SpatRaster has no values

Is there a solution for that

Rapsodia86 commented 1 year ago

See #58