SCM

[#1973] NA value not detected

Date:
2012-05-04 18:44
Priority:
3
State:
Open
Submitted by:
Neil Best (nbest)
Assigned to:
Nobody (None)
Hardware:
None
Product:
None
Operating System:
None
Component:
None
Version:
None
Severity:
None
Resolution:
None
URL:
Summary:
NA value not detected

Detailed description
I have often noticed that a GDAL dataset loaded via raster() does not pick up the No Data value indicated by GDALinfo() or gdalinfo in the shell. Why is this?

Here is a self-contained example:

library( RCurl)
library( XML)
library( raster)

queryUrl <- "http://nassgeodata.gmu.edu:8080/axis2/services/CDLService/GetCDLFile?year=2009&fips=19015";

fileUrl <-
xpathSApply( xmlInternalTreeParse( getURL( queryUrl)),
"//returnURL", fun= xmlValue, simplify= TRUE)

fn <- basename( fileUrl)

download.file( fileUrl, fn, mode= "wb")

r <- raster( fn)

r

NAvalue( r)

GDALinfo( fn)

Comments:

Message  ↓
Date: 2012-09-04 19:36
Sender: Robert Hijmans

This is because rgdal deals with the NA values and therefore the raster package does not set it for GDAL data sources. I could of course set (and return) the correct value. The reason for not doing that is that if the value gets set, reading values from file involves an additional operation (replacing that value with NA) which would be redundant as it has already been done. But I realize that this causes confusion so I will probably change this.

Date: 2012-05-17 17:54
Sender: Robert Hijmans

Nice self contained example! The NAvalue in the object is not 'picked up', because it is of no relevance as rgdal already translates the NA values to NA.

Attached Files:

Changes

No Changes Have Been Made to This Item

Thanks to:
Vienna University of Economics and Business Powered By FusionForge