I have been having problems importing a ASCII raster that has values that go from Min. :-69826220
to Max. :167780500
. The problem I am encountering is that when I use the raster function to import the ASCII file then every value smaller than -9999
is reported as NA
and the minimum value is -9458
.
Is this a bug of the function and is there a workaround? When I import the same ASCII file as a data frame everything is fine and I get the whole range of values. Also I am using the same procedure to import other ASCII rasters and don't have any problem.
here is the link to the ASCII file https://dl.dropboxusercontent.com/u/24234831/ps0011yme.asc
Here is the session info, I opened a new session just in case.
sessionInfo() R version 3.0.0 (2013-04-03) Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] raster_2.1-16 sp_1.0-8
loaded via a namespace (and not attached): [1] grid_3.0.0 lattice_0.20-15
Any help is appreciated
You can try to use setMinMax()
on your raster file to try and work out the min and max values and store them in the returned Raster* object. Try it like so:
r <- setMinMax( raster("path/to/myraster.asc") )
I am not sure what is happening because if I downlaod you data and do:
r1 <- raster( "~/Downloads/test.asc")
summary(values(r1))
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
-69830000 -4789000 737300 16950000 13880000 167800000 71468
Please add the output of sessionInfo()
into your question , i.e. not as a comment.
The errors in this case were being caused by not having rgdal
installed, which are bindings to the Geospatial Data Abstraction Library and are very important for importing/exporting raster and shapefile data.