Skip to content

rgdal error when trying to import raster

4 messages · john polo, Ben Tupper, Jeff Newmiller

#
Dear useRs,

I am trying to import a raster with the line:

nlcd <- raster("/home/jpolo/NRI/nlcd_nri5000.tif")

And I keep getting an error like this:

"Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, 
logical.return = TRUE,? :
 ? there is no package called 'rgdal'
Error in .rasterObjectFromFile(x, band = band, objecttype = 
"RasterLayer",? :
 ? Cannot create RasterLayer object from this file; perhaps you need to 
install rgdal first
Calls: raster -> raster -> .local -> .rasterObjectFromFile
Execution halted"

This is the session info:

"R version 3.2.5 (2016-04-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS release 6.3 (Final)

locale:
[1] C

attached base packages:
[1] methods?? stats???? graphics? grDevices utils datasets? base

other attached packages:
[1] raster_2.5-8 sp_1.2-4???? rgeos_0.3-23

loaded via a namespace (and not attached):
[1] Rcpp_0.12.10??? grid_3.2.5????? lattice_0.20-35 "

I know the R version is old, but this is a system that I can not update, 
I have no control over it. Because the version of R is old, the admin 
told me that they cannot install rgdal. I am not using library(rgdal) 
and none of the other libraries that are loaded require rgdal. The 
package raster does suggest it though. Is that causing the problem? Is 
there a way to avoid this? Any help is welcome.

best,

John
#
Hi,

The message "there is no package called 'rgdal'" means that you don't have rgdal installed.

https://cran.r-project.org/web/packages/rgdal/index.html

Also, you will get very good patial-centric help if you subscribed to r-sig-geo here

https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Cheers,
Ben
Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Ecocast Reports: http://seascapemodeling.org/ecocast.html
Tick Reports: https://report.bigelow.org/tick/
Jellyfish Reports: https://jellyfish.bigelow.org/jellyfish/
#
Indeed, Ben, but the question was something more like it is not a Dependency, just Suggested, so why the error...

John:

If you read the Introduction to the 'raster' package vignette, it indicates that some input formats are supported within the raster package and some rely on other packages. Clearly the attempt to read a TIFF was an example of the latter. Had you used a different input file format the issue of rgdal might never have appeared... ergo, Suggests rather than Depends. 

Note that someone may feel pity for your plight, John, and give you a convenient alternative way to import the data to raster (there are other packages that read TIFF but you would probably have to roll the geolocation yourself... an avenue for which help would be better pursued on R-sig-geo), but the premise of your email (cannot upgrade) does put it squarely in the off-topic category according to the Posting Guide. Fortunately R is open-source so if you are diligent you can write/borrow R code as needed or even recompile R and necessary packages entirely within your personal development directories with no system installation to bother your sysadmin about... but you might also just go find another computer to do your work on.
#
Ah, I didn't read the entire message.  Sorry about that!
Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Ecocast Reports: http://seascapemodeling.org/ecocast.html
Tick Reports: https://report.bigelow.org/tick/
Jellyfish Reports: https://jellyfish.bigelow.org/jellyfish/