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

Using getGridMET #19

Closed mhscott-usgs closed 3 years ago

mhscott-usgs commented 3 years ago

I am trying to use the getGridMET function but the coordinates/location identifier seems to be off. I am using simple example code:

AOI = aoi_get(state = "MN") p = getGridMET(AOI, param = c('tmax','tmin'), startDate = "2018-11-20")

r = raster::stack(p$tmax, p$tmin) names(r) = c('tmax', 'tmin') rasterVis::levelplot(r, main=AOI$state_abbr)

For Minnesota, I've attached the output plot (which looks like the bottom part of Texas).

climateR_test_MNtemp

Meanwhile, for Florida, the output looks like it's of the top part of Michigan.

climateR_test_FLtemp

The temperature values are also another indicator of the problem.

When I use getPRISM instead of getGridMET, the location is accurate and the output is fine. Additionally, using getGridMET for data from California seems to work properly as well. Could this be an issue with how the coordinate system used by the GridMET is read into either aoi_get or getGridMET functions? Do you have any solutions on how to get the state name input to match up properly with the physical location of the state?

Thank you for your help!

mikejohnson51 commented 3 years ago

Hi, Thank you for the comment! This was a recent change (I am actually not sure when it occurred) in some of the THREDDS servers related to the in the orientation of the X and Y variables of the datasets. In the first round of climateR I looked at these and hard coded the results. Needless to say this was a bad idea since a few have since changed. By the end of the week I hope to have a generalized solution up in the package!

Thank you again and hope the package is useful (when the data is correct of course :))

mhscott-usgs commented 3 years ago

Ok great, thank you very much! I anticipate the package will certainly be useful.

mikejohnson51 commented 3 years ago

I can confirm the change is coming šŸ‘ I can mimic your results with the GItHuv Install, and get this with the new version:

library(climateR)
library(raster)
#> Warning: package 'raster' was built under R version 4.0.2
#> Loading required package: sp
library(sf)
#> Warning: package 'sf' was built under R version 4.0.2
#> Linking to GEOS 3.8.1, GDAL 3.1.1, PROJ 6.3.1
library(AOI)

AOI = aoi_get(state = "MN")
p = getGridMET(AOI, param = 'tmax', startDate = "2018-11-20")

plot(p$tmax) 
plot(st_transform(AOI$geometry, st_crs(p$tmax)), add = TRUE, lwd = 3)


AOI = aoi_get(state = "FL")
p = getGridMET(AOI, param = 'tmax', startDate = "2018-11-20")

plot(p$tmax) 
plot(st_transform(AOI$geometry, st_crs(p$tmax)), add = TRUE, lwd = 3)

Created on 2020-10-07 by the reprex package (v0.3.0)

mhscott-usgs commented 3 years ago

Hi, I wanted to check in and ask whether the package had been updated yet? I tried reinstalling it a few days ago but was still getting the same results as before. Thanks!

mikejohnson51 commented 3 years ago

Hi @mhscott129 this should all be pushed in the new version 0.0.3. Hope it helps!