-
Notifications
You must be signed in to change notification settings - Fork 96
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
Unexpected project
results
#1356
Comments
Here is a simplified version of your example that does not require an additional download.
And the projections
This is mysterious. Especially that it works when coercing from a RasterLayer! I will have a look. |
fwiw, looks ok through 'GDALWarp()` api (with 'by_util'), also no need to download with the /vsicurl protocol library(terra)
url <- "https://os.zhdk.cloud.switch.ch/envicloud/chelsa/chelsa_V2/GLOBAL/climatologies/1981-2010/bio/CHELSA_gdd5_1981-2010_V.2.1.tif"
f <- file.path("/vsicurl", url)
GridR <- rast(ncols=469, nrows=404, nlyrs=1, xmin=2630000, xmax=7320000, ymin=1380000, ymax=5420000, names=c('Grid'), crs='EPSG:3035')
r1 <- rast(f)
r1_p <- project(r1, GridR, method = "average", threads = TRUE, by_util = TRUE) |
Thanks @mdsumner and @rhijmans for your feedback. This seems to be a temporary solution to avoid extremely high values shown in the above example. However, there are value differences when coercing raster to spatraster vs using
The difference between both approaches:
Please note differences in the pattern of NA values (e.g. north Italy and Iceland) when using
Any explanation/suggestion? Thanks.. |
This bug occurs because the input has a scale that is 0.1 (not 1). This is why if you first make a copy it works (that removes the scale). With a SpatRaster created from a RasterLayer, a copy is first made by project. That is why it works. |
Thanks @rhijmans for your explanation. For another CHELSA map (which also has a scale factor of 0.1), this problem did not occur.
The difference between both files is mainly in the NA value (using In the first example, the problematic Among all current bio variables in CHLESA, extremely high values in projected maps existed in the following three maps (all having a NoData value of 2147483647)
Thanks |
The following example suggests that the problem is how the NoData is treated.
Now, projecting the original and edited tiff file
|
Hello,
I would like to use
terra::project()
to project CHELSA data into a custom grid atEPSG:3035
projection. However, the values of some of the projected maps are not as expected. Here is an example:download the tif file
reference grid [attached]
reading as raster, then convert to spatraster
projecting to the reference grid
slow, but values are within the expected range
reading directly as spatraster
projecting to the reference grid
The output is not expected
It seems that the NA values in the original tif file [NoData Value=2147483647 for
CHELSA_gdd5_1981-2010_V.2.1.tif
] are considered in the calculation of new values.description of input files
Session info
reference grid
Thanks
The text was updated successfully, but these errors were encountered: