[R-sig-Geo] generating distance map for Large map
Tomislav Hengl
T.Hengl at uva.nl
Mon Jul 28 16:56:27 CEST 2008
Yes, buffer distances can be smoothly calculated using SAGA (I do not if it will work for your HUGE
image, but you can try). Here is an example:
.........
# Import the contour data (from the 1:5k and 1:50k topo maps):
> library(maptools)
> getinfo.shape("contours.shp")
> contours.50 <- readShapeLines("contours.shp", proj4string=CRS(as.character(NA)))
> contours.5 <- readShapeLines("contours2.shp", proj4string=CRS(as.character(NA)))
# estimate the initial cell size based on the spacing between the contours:
dem.area <- (contours.5 at bbox[1,2]-contours.5 at bbox[1,1])*(contours.5 at bbox[2,2]-contours.5 at bbox[2,1])
# for beginning, we take a cell size that corresponds to the effective scale:
dem.pixelsize <- 25
# estimate the buffer distance between the contour lines
library(RSAGA)
# Download SAGA GIS from www.saga-gis.org and unzip the binaries to:
rsaga.env(path="C:/Program Files/saga_vc")
# first, convert the contour map to a raster map:
rsaga.geoprocessor(lib="grid_gridding", module=3, param=list(GRID="contour50_buff.sgrd",
INPUT="contours.shp", FIELD=1, LINE_TYPE=0, USER_CELL_SIZE=dem.pixelsize,
USER_X_EXTENT_MIN=contours.5 at bbox[1,1], USER_X_EXTENT_MAX=contours.5 at bbox[1,2],
USER_Y_EXTENT_MIN=contours.5 at bbox[2,1], USER_Y_EXTENT_MAX=contours.5 at bbox[2,2]))
# now extract a buffer distance map (for 'contours') and load it back to R:
# the parameters DIST and IVAL are estimated based on the grid properties:
rsaga.geoprocessor(lib="grid_tools", module=10, param=list(SOURCE="contour50_buff.sgrd",
DISTANCE="contours50_dist.sgrd", ALLOC="contours50_alloc.sgrd", BUFFER="contours50_bdist.sgrd",
DIST=sqrt(dem.area)/3, IVAL=dem.pixelsize))
rsaga.sgrd.to.esri(in.sgrds="contours50_dist.sgrd", out.grids="contours50_dist.asc",
out.path=getwd(), prec=1)
contours50.dist <- readGDAL("contours50_dist.asc")
.........
and the complete sample R script:
http://spatial-analyst.net/PIXEL/pixelR.zip
cheers,
Tom Hengl
http://spatial-analyst.net
-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of
milton ruser
Sent: maandag 21 juli 2008 21:11
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] generating distance map for Large map
Dear all,
I have a very large BINARY image (60,000x50,000 pixels) and need to generate
the distance map from the 1 values.
When the images are small than my image, I can generate the distance map
using ArcGis (my image is in .IMG format), but ArcGis return error for this
large one.
I am running R 2.7.1 under windows/xp. Is there a way of do this job using R
ou RSaga? (unfortunately I don´t have GRASS installed), and my experience
with RSAGA is near zero. My computer is 4GB ram. I can load the images on
ArcGis and Erdas without problem, but I only don´t know how do this task.
Sorry for not send a reproducible code.
Any help are welcome.
Miltinho Astronauta
Brazil
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list