Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am using raster data from Afripop.org and using the R package raster (raster_2.0-41) to do all my computation. Everything has been working out just fine until I tried sending some jobs to a remote linux machine. When I read in the raster on one machine the values are correct but on the other there are no NAs and the population (i.e. sum of all the values) WAY off.

On the linux machine I get:

> civpop <- raster("data/apciv10v3.flt")

> civpop[1:10]
[1]   0  60  28 198   0  60  28 198   0  60

> civpop
class       : RasterLayer 
dimensions  : 7656, 7327, 56095512  (nrow, ncol, ncell)
resolution  : 0.0008333, 0.0008333  (x, y)
extent      : -8.599802, -2.494213, 4.357029, 10.73677  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs 
data source : /home/andrewa/D4D/trunk/data/apciv10v3.flt 
names       : apciv10v3 
values      : 0, 255  (min, max)

One the other machine I (correctly) get:

R> civpop <- raster("data/apciv10v3.flt")
R> civpop[1:10]
 [1] NA NA NA NA NA NA NA NA NA NA
R> civpop
class       : RasterLayer 
dimensions  : 7656, 7327, 56095512  (nrow, ncol, ncell)
resolution  : 0.0008333, 0.0008333  (x, y)
extent      : -8.6, -2.494, 4.357, 10.74  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs 
data source : /Users/andrewa/Documents/D4D/trunk/data/apciv10v3.flt 
names       : apciv10v3 

If I use just rgdal I have the same issues so I guess it isn't an issue with raster. Any ideas?

Incorrect Machine (using GDAL 1.8.0, released 2011/01/12):

> civpop.gdal = readGDAL("data/apciv10v3.flt")
data/apciv10v3.flt has GDAL driver EHdr 
and has 7656 rows and 7327 columns
> civpop.gdal@data[1:10,1]
[1]   0  60  28 198   0  60  28 198   0  60

Correct machine (using GDAL 1.8.1, released 2011/07/09):

R> civpop.gdal = readGDAL("data/apciv10v3.flt")
data/apciv10v3.flt has GDAL driver EHdr 
and has 7656 rows and 7327 columns
R> civpop.gdal@data[1:10,1]
[1] NA NA NA NA NA NA NA NA NA NA`
share|improve this question
1  
try using readGDAL() directly in rgdal package to isolate whether it's a raster package issue or not –  mdsumner Feb 6 '13 at 11:12
    
thanks @mdsumner it seems like rgdal may be the issue. any ideas? –  scottyaz Feb 6 '13 at 11:25
    
How different are these machines? What version of gdal/ogr do they have? What does gdalinfo --version on the command line say? Could it be related to this problem I had with afripop data: geospaced.blogspot.co.uk/2011/12/reading-afripop-data.html –  Spacedman Feb 6 '13 at 11:43
    
@Spacedman adding pixeltype float to the hdr file did it! Want to post this as a solution so I can accept? –  scottyaz Feb 6 '13 at 11:49
    
sure, can you add the gdal version numbers to a comment on my answer? Or better still, edit your question... –  Spacedman Feb 6 '13 at 12:19
add comment

1 Answer 1

up vote 3 down vote accepted

Some versions of gdal/ogr have trouble inferring the floating point structure of these files. I blogged about it:

http://geospaced.blogspot.co.uk/2011/12/reading-afripop-data.html

and the essence is to add pixeltype float to the .hdr file.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.