[R-sig-Geo] reading img files with rgdal

Matthew Landis landis at isciences.com
Wed Jul 11 16:04:40 CEST 2007


Dear R-sig-Geo,

I'm trying to get started with rgdal, and not having much luck so far.  
I'm running R 2.5.0 on an i386-pc-mingw32 with rgdal 0.5-9 and sp 0.9-14. 

For starters, I'd like to read in an .img file created in ArcGIS 9.2. As 
you can see below, the file is a global map in geographic coordinates 
with 0.5 degree resolution.

 > GDALinfo('swe20070615.img')
Closing GDAL dataset handle 0x020d8660...  destroyed ... done.
rows        360
columns     720
bands       1
ll.x        -180
ll.y        90.0321
res.x       0.5
res.y       0.5
oblique.x   0
oblique.y   0
driver      HFA
projection  +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
file        swe20070615.img

The result of readGDAL is initially promising, but ultimately fails, 
apparently due to a problem with the projection.

 > test <- readGDAL('swe20070615.img')
swe20070615.img has GDAL driver HFA
and has 360 rows and 720 columns
Closing GDAL dataset handle 0x056988a8...  destroyed ... done.
Closing GDAL dataset handle (nil)... done.
Closing GDAL dataset handle 0x020dade8...  destroyed ... done.
Closing GDAL dataset handle 0x05699470...  destroyed ... done.
Error in `proj4string<-`(`*tmp*`, value = <S4 object of class "CRS">) :
        Geographical CRS given to non-conformant data
 > str(test)
Error in str(test) : object "test" not found

Can anyone suggest what might be going wrong and how to fix it?

In addition, I've had some trouble finding a good point of entry for how 
to use rgdal.  I have checked the standard documentation in the R help 
files and the GDAL websites, but having a bit of trouble penetrating it 
all.  If anyone can point me to a concise overview of how to use rgdal, 
I'd be most grateful.

Many thanks in advance,

Sincerely,

Matt Landis

-- 
**********************************
Matthew Landis
Research Analyst
Isciences, LLC
61 Main St., Suite 200
Burlington VT 05401 USA




More information about the R-sig-Geo mailing list