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

Matthew Landis landis at isciences.com
Wed Jul 11 21:45:11 CEST 2007


Dear Roger,

Many thanks for your rapid reply!  I guess I was so caught up in the 
details of rgdal that I completely failed to see that obvious problem.   
I've  managed to fix the coordinates, and now rgdal reads the image just 
fine. 

I'm still searching for a good overview of rgdal or gdal though - any 
pointers would be wonderful.

Sincerely,

Matt


Roger Bivand wrote:
> On Wed, 11 Jul 2007, Matthew Landis wrote:
>
>> 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
>
> This is the problem, since > 90N is not defined for geographical 
> coordinates, and leads to the projection being rejected. Why Arc wants 
> to believe in > 90N is probably not known. If you can find out where 
> the fuzz is coming from, perhaps you can remove it?  If correcting the 
> data is not an option, please ask again, and a work-round may be 
> possible (reading the data without its projection information, and 
> placing it in a correct grid).
>
> Roger
>
>> 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
>>
>>
>




More information about the R-sig-Geo mailing list