Roger,
Thanks for your help. I believe you are correct that the printed summary
values have been rounded. I couldn't quite figure out how to extract the
range specifically, but when I did a summary for the data.frame from each
grid I got what I was expecting for the one created by readAsciiGrid
(g1). However, the grid created by readGDAL (g2) still shows unexpected
min and
max values. See results below:
d1 <- g...@data
summary(d1)
distrail_100m.asc
Min. : 0
1st Qu.: 2878
Median : 6562
Mean : 7896
3rd Qu.: 11670
Max. : 37082
NA's :6483714
d2 <- g...@data
summary(d2)
band1
Min. : -32768
1st Qu.: 2844
Median : 6516
Mean : 7718
3rd Qu.: 11600
Max. : 32767
NA's :6483714
For my own purposes, I have found that I should continue using
readAsciiGrid to bring in my grids. But I would be happy to share my
dataset to help figure out why readGDAL has these strange results. My
Ascii file is 13Mb zipped, probably too large to email, and I don't have
an FTP site that can be accessed outside of the Forest Service. I can
send the file to you off list using YouSendIt.com if you would like, or
if you have an alternative suggestion for transferring the file, let me
know. Thanks again for your assistance, and if you need any additional
information from me, let me know.
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
Roger Bivand <roger.biv...@nhh.no>
01/13/2009 02:49 PM
Please respond to
roger.biv...@nhh.no
To
Brian R Miranda <brmira...@fs.fed.us>
cc
r-sig-geo@stat.math.ethz.ch
Subject
Re: [R-sig-Geo] ESRI Ascii Grid
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