Skip to content

Step characteristics on raster maps

1 message · Tomislav Hengl

#
Hi Basile,

If you work with large data, then you should definitively consider using 
SAGA GIS. Here are some examples:

--------------

# download gridded data:
 > 
download.file("http://geomorphometry.org/sites/default/files/volcano_maungawhau.zip", 
destfile=paste(getwd(), "volcano_maungawhau.zip", sep="/"))
 > unzip("volcano_maungawhau.zip")
 > volcano <- readGDAL("volcano_maungawhau.asc")
 > writeGDAL(volcano, "volcano_dem.sdat", "SAGA")

# create a shape file:
 > tmp <- 
list(Lines(list(Line(data.frame(x=c(2667700,2667700),y=c(6479520,6478720)))), 
"1"))
 > trans <- SpatialLinesDataFrame(SpatialLines(tmp), 
data.frame(ID=c("1")), match.ID=FALSE)
 > writeOGR(trans, "trans.shp", "trans", "ESRI Shapefile")

# overlay shapes over grids:
 > rsaga.get.usage("shapes_grid", 1)
SAGA CMD 2.0.4
library path:   C:/PROGRA~1/R/R-211~1.1/library/RSAGA/saga_vc/modules
library name:   shapes_grid
module name :   Get Grid Data for Shapes
Usage: 1 -SHAPES <str> -GRIDS <str> -RESULT <str> [-INTERPOL <num>]
   -SHAPES:<str>         Shapes
         Shapes (input)
   -GRIDS:<str>          Grids
         Grid list (input)
   -RESULT:<str>         Shapes (Grid Information)
         Shapes (output)
   -INTERPOL:<num>       Interpolation
         Choice
         Available Choices:
         [0] Nearest Neighbor
         [1] Bilinear Interpolation
         [2] Inverse Distance Interpolation
         [3] Bicubic Spline Interpolation
 > rsaga.geoprocessor("shapes_grid", 1, param=list(SHAPES="trans.shp", 
GRIDS="volcano_dem.sgrd", RESULT="trans_ov.shp", INTERPOL=0))
# get's an error message; looks like a bug :(

# convert segments to points:
 > rsaga.geoprocessor("shapes_points", 5, 
param=list(POINTS="trans_pt.shp", LINES="trans.shp", ADD=TRUE, DIST=20))
# now overlay points and lines:
 > trans.pt <- readOGR("trans_pt.shp", "trans_pt")
 > ov.trans <- overlay(volcano, trans.pt)
 > summary(ov.trans)
Object of class SpatialPointsDataFrame
Coordinates:
               min     max
coords.x1 2667700 2667700
coords.x2 6478740 6479520
Is projected: NA
proj4string : [NA]
Number of points: 41
Data attributes:
    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
   109.0   134.0   158.0   150.7   166.0   195.0

--------------


T. Hengl
[http://www.wewur.wur.nl/popups/vcard.aspx?id=HENGL001]


Op 30-9-2010 20:57, Mathieu Basille schreef: