-
-
Notifications
You must be signed in to change notification settings - Fork 585
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 with reprojecting code with latest version of terra and PROJ 8.0.1 #648
Comments
Does it work if sf is also installed? If it's Linux then that will sort out the pro files thing, or sf might have same problem |
I do not have this problem on slightly newer proj (and older gdal): library(terra)
#> terra version 1.4.3
library(spData)
sf::sf_extSoftVersion()
#> GEOS GDAL proj.4 GDAL_with_GEOS USE_PROJ_H
#> "3.9.1" "3.3.1" "8.1.0" "true" "true"
#> PROJ
#> "8.1.0"
cat_raster = rast(system.file("raster/nlcd.tif", package = "spDataLarge"))
crs(cat_raster)
#> [1] "PROJCRS[\"NAD83 / UTM zone 12N\",\n BASEGEOGCRS[\"NAD83\",\n DATUM[\"North American Datum 1983\",\n ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4269]],\n CONVERSION[\"UTM zone 12N\",\n METHOD[\"Transverse Mercator\",\n ID[\"EPSG\",9807]],\n PARAMETER[\"Latitude of natural origin\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8801]],\n PARAMETER[\"Longitude of natural origin\",-111,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8802]],\n PARAMETER[\"Scale factor at natural origin\",0.9996,\n SCALEUNIT[\"unity\",1],\n ID[\"EPSG\",8805]],\n PARAMETER[\"False easting\",500000,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8806]],\n PARAMETER[\"False northing\",0,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8807]]],\n CS[Cartesian,2],\n AXIS[\"(E)\",east,\n ORDER[1],\n LENGTHUNIT[\"metre\",1]],\n AXIS[\"(N)\",north,\n ORDER[2],\n LENGTHUNIT[\"metre\",1]],\n USAGE[\n SCOPE[\"Engineering survey, topographic mapping.\"],\n AREA[\"North America - between 114°W and 108°W - onshore and offshore. Canada - Alberta; Northwest Territories; Nunavut; Saskatchewan. United States (USA) - Arizona; Colorado; Idaho; Montana; New Mexico; Utah; Wyoming.\"],\n BBOX[31.33,-114,84,-108]],\n ID[\"EPSG\",26912]]"
cat_raster_wgs84 = project(cat_raster, "EPSG:4326", method = "near") Created on 2021-09-26 by the reprex package (v2.0.1) |
Good to see the problem is not there on new PROJ, thanks for testing Jakub... |
Good question. Contrary to my expectation, the CRS transformation worked for an remotes::install_github("rspatial/terra")
library(terra)
library(spData)
sf::sf_extSoftVersion()
cat_raster = rast(system.file("raster/nlcd.tif", package = "spDataLarge"))
cat_stars = stars::read_stars(system.file("raster/nlcd.tif", package = "spDataLarge"))
sf::st_crs(cat_stars)
cat_stars_4326 = sf::st_transform(cat_stars, 4326) # warnings
cat_sf = sf::st_as_sf(cat_stars)
plot(cat_sf[1:5, ]) # works
cat_sf_4326 = sf::st_transform(cat_sf[1:9, ], 4326) # warnings
mapview::mapview(cat_sf_4326) |
Warnings from transforming the stars object:
|
Any ideas how get the required file or make that warning go away? |
Full reprex below. remotes::install_github("rspatial/terra")
#> Skipping install of 'terra' from a github remote, the SHA1 (9cb87338) has not changed since last install.
#> Use `force = TRUE` to force installation
library(terra)
#> terra version 1.4.3
library(spData)
sf::sf_extSoftVersion()
#> GEOS GDAL proj.4 GDAL_with_GEOS USE_PROJ_H
#> "3.9.1" "3.3.2" "8.0.1" "true" "true"
#> PROJ
#> "8.0.1"
cat_raster = rast(system.file("raster/nlcd.tif", package = "spDataLarge"))
cat_stars = stars::read_stars(system.file("raster/nlcd.tif", package = "spDataLarge"))
sf::st_crs(cat_stars)
#> Coordinate Reference System:
#> User input: NAD83 / UTM zone 12N
#> wkt:
#> PROJCRS["NAD83 / UTM zone 12N",
#> BASEGEOGCRS["NAD83",
#> DATUM["North American Datum 1983",
#> ELLIPSOID["GRS 1980",6378137,298.257222101,
#> LENGTHUNIT["metre",1]]],
#> PRIMEM["Greenwich",0,
#> ANGLEUNIT["degree",0.0174532925199433]],
#> ID["EPSG",4269]],
#> CONVERSION["UTM zone 12N",
#> METHOD["Transverse Mercator",
#> ID["EPSG",9807]],
#> PARAMETER["Latitude of natural origin",0,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8801]],
#> PARAMETER["Longitude of natural origin",-111,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8802]],
#> PARAMETER["Scale factor at natural origin",0.9996,
#> SCALEUNIT["unity",1],
#> ID["EPSG",8805]],
#> PARAMETER["False easting",500000,
#> LENGTHUNIT["metre",1],
#> ID["EPSG",8806]],
#> PARAMETER["False northing",0,
#> LENGTHUNIT["metre",1],
#> ID["EPSG",8807]]],
#> CS[Cartesian,2],
#> AXIS["(E)",east,
#> ORDER[1],
#> LENGTHUNIT["metre",1]],
#> AXIS["(N)",north,
#> ORDER[2],
#> LENGTHUNIT["metre",1]],
#> USAGE[
#> SCOPE["Engineering survey, topographic mapping."],
#> AREA["North America - between 114°W and 108°W - onshore and offshore. Canada - Alberta; Northwest Territories; Nunavut; Saskatchewan. United States (USA) - Arizona; Colorado; Idaho; Montana; New Mexico; Utah; Wyoming."],
#> BBOX[31.332603454538,-114,84,-108]],
#> ID["EPSG",26912]]
cat_stars_4326 = sf::st_transform(cat_stars, 4326)
cat_sf = sf::st_as_sf(cat_stars)
# plot(cat_sf[1:5, ]) # works
cat_sf_4326 = sf::st_transform(cat_sf[1:9, ], 4326)
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: Unrecognized horizontal grid format
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: hgridshift: could not find required grid(s).
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: pipeline: Pipeline: Bad step definition: proj=hgridshift
#> (File not found or invalid)
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: Unrecognized horizontal grid format
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: hgridshift: could not find required grid(s).
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: pipeline: Pipeline: Bad step definition: proj=hgridshift
#> (File not found or invalid)
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: Unrecognized horizontal grid format
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: hgridshift: could not find required grid(s).
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: pipeline: Pipeline: Bad step definition: proj=hgridshift
#> (File not found or invalid)
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: Unrecognized horizontal grid format
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: hgridshift: could not find required grid(s).
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: pipeline: Pipeline: Bad step definition: proj=hgridshift
#> (File not found or invalid)
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: Unrecognized horizontal grid format
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: hgridshift: could not find required grid(s).
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: pipeline: Pipeline: Bad step definition: proj=hgridshift
#> (File not found or invalid)
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: Unrecognized horizontal grid format
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: hgridshift: could not find required grid(s).
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: pipeline: Pipeline: Bad step definition: proj=hgridshift
#> (File not found or invalid)
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: Unrecognized horizontal grid format
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: hgridshift: could not find required grid(s).
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: pipeline: Pipeline: Bad step definition: proj=hgridshift
#> (File not found or invalid)
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: Unrecognized horizontal grid format
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: hgridshift: could not find required grid(s).
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: pipeline: Pipeline: Bad step definition: proj=hgridshift
#> (File not found or invalid)
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: Unrecognized horizontal grid format
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: hgridshift: could not find required grid(s).
#> Warning in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
#> GDAL Error 1: PROJ: pipeline: Pipeline: Bad step definition: proj=hgridshift
#> (File not found or invalid)
warnings() Created on 2021-09-26 by the reprex package (v2.0.1) |
My guess:
Not sure either solution is possible/appropriate. Wider question: is there a way to download new transform grids from the R command line? Could be worth a section in the book if so. |
My suggestions:
sf_proj_network(TRUE) |
Minor update on this, issue still appears on Binder, this is the issue I get after running
Source: https://mybinder.org/v2/gh/robinlovelace/geocompr/main?urlpath=rstudio |
Could it be related to having PROJ 8.0.1 (as oppose to e.g., PROJ 8.1.0)? |
Could be... |
Fixed on the new version of binder discussed in #691 Test it here: https://mybinder.org/v2/gh/robinlovelace/geocompr/main?urlpath=rstudio
|
I think this may be an issue with
terra
/PROJ versions but reporting here as it affects the book, at least when it builds in the Binder environment.Reproducible example:
Result on computer with a recent version of PROJ:
Created on 2021-09-25 by the reprex package (v2.0.1)
Note, this error message does not appear on older versions of PROJ.
Created on 2021-09-25 by the reprex package (v2.0.1)
The text was updated successfully, but these errors were encountered: