-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in st_warp convert NetCDF from rectilinear to regular grid #264
Comments
Cross post from https://stat.ethz.ch/pipermail/r-sig-geo/2020-March/027997.html |
This makes the following work: library(stars)
library(raster)
# prepare data
bc <- read_ncdf("pr_Amon_bcc-csm1-1_rcp45_r1i1p1_200601-209912.nc")
# create a new standard grid, with lat 0...360
grid_st <- st_as_stars(st_bbox(c(xmin=0,xmax=360,ymin=-90,ymax=90))) %>% st_set_crs(4326)
# change from rectilinear to regular grid
# stars package: use st_warp to change from rectilinear to regular raster with different methods
(bc_reg <- bc %>% st_warp(grid_st, method = "near"))
plot(bc_reg[,,,1:12]) Note that the new raster also needs to cover latitude 0-360, as the old one, that is something that also needs fixing. As the documentation says, the other |
Hi Edzer, I answer at r-sig-geo list (http://r-sig-geo.2731867.n2.nabble.com/Convert-rectilinear-to-regular-grid-in-R-stars-and-raster-td7593462.html#a7593477), but I think you did not see it. Now the code is working fine, but the structure of the output was changed. When I try extract the values converting to data.frame all values was replaced by NA. However the plot is OK as you have tested.
Best regards. |
This is caused by changing both |
@edzer I did it with other grids, but I have the same problem (i.e. the variable have only NA values).
Best regards. |
Your script has some typos, but the plot looks good to me. Which versions of stars and sf are you using? |
Sorry about the typos, now it is correct. The version of stars is 0.4-1 installed from github.
|
I am trying convert a NetCDF from rectilinear to regular grid with st_warp without success (see bellow). What am I doing wrong?
The data are available in:
GDrive: https://drive.google.com/file/d/1HKxFpAwvY9k_cFbasagKHAwi1luzLv90/view?usp=sharing
or
CMIP5 portal (you must make a login): http://aims3.llnl.gov/thredds/fileServer/cmip5_css01_data/cmip5/output1/BCC/bcc-csm1-1/rcp45/mon/atmos/Amon/r1i1p1/v20120705/pr/pr_Amon_bcc-csm1-1_rcp45_r1i1p1_200601-209912.nc
The text was updated successfully, but these errors were encountered: