On Tue, 13 Jan 2009, Brian R Miranda wrote:
Hello,
I have an Ascii grid that was created using the GridAscii command in
ArcGrid. The grid represents cell distance to railroads and has values
ranging from 0 to 37,082. When I bring this grid into R as a
SpatialGridDataFrame, the maximum and/or the minimum values in the grid do
not exactly match the original grid. I have tried using both readGDAL and
readAsciiGrid for this purpose. I have confirmed in a text editor that
the Ascii file does contain the maximum value of 37,082. Below are the
results I have seen. Note the differences in the Max. value and Min.
value (from readGDAL).
First, beware of the possible difference between the printed summary value
and the actual value - printed summaries may round. What does range() of
the variable say? The difference between the two functions is puzzling -
could you make the data available (off list for example, zipped,
preferably for download) to try to see what is going on?
Roger
g1 <- readAsciiGrid("G:/Oconto/WI_Fire/distrail_100m.asc")
summary(g1)
Object of class SpatialGridDataFrame
Coordinates:
min max
coords.x1 -263487.6 149512.4
coords.x2 358821.1 666821.1
Is projected: NA
proj4string : [NA]
Number of points: 2
Grid attributes:
cellcentre.offset cellsize cells.dim
1 -263437.6 100 4130
2 358871.1 100 3080
Data attributes:
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
0 2878 6562 7896 11670 37080 6483714
g2 <- readGDAL("G:/Oconto/WI_Fire/distrail_100m.asc")
G:/Oconto/WI_Fire/distrail_100m.asc has GDAL driver AAIGrid
and has 3080 rows and 4130 columns
summary(g2)
Object of class SpatialGridDataFrame
Coordinates:
min max
x -263487.6 149512.4
y 358821.1 666821.1
Is projected: NA
proj4string : [NA]
Number of points: 2
Grid attributes:
cellcentre.offset cellsize cells.dim
x -263437.6 100 4130
y 358871.1 100 3080
Data attributes:
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
-32770 2844 6516 7718 11600 32770 6483714
The results from readAsciiGrid are pretty close (Max = 37,080) to the
original grid, but readGDAL results in much different values. I would
expect both functions to create an object with exactly the same values as
the Ascii grid. Can anyone explain why this occurs, and if there is a
different way to get my grid into R (I eventually need an 'im' to work
with)? I am new to spatial analysis using R, so if there is something
obvious I am missing I apologize. Thanks in advance for any help!
Cheers,
-Brian
=======================
Brian R. Miranda
USDA Forest Service
Northern Research Station
brmira...@fs.fed.us
Institute for Applied Ecosystem Studies
5985 Highway K
Rhinelander, WI 54501
phone: 715-362-1186
fax: 715-362-1166
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo