[R-sig-Geo] subsetting

Tomislav Hengl T.Hengl at uva.nl
Fri Oct 24 10:18:27 CEST 2008

to get statistics of grids over polygons, you might also consider using the Grid Statistics for
Polygons method in SAGA GIS:

> rsaga.get.modules("shapes_grid")
   code                             name interactive
1     0        Add Grid Values to Points       FALSE
2     1         Get Grid Data for Shapes       FALSE
3     2     Grid Statistics for Polygons       FALSE
4     3            Grid Values to Points       FALSE
5     4 Grid Values to Points (randomly)       FALSE
6     5          Contour Lines from Grid       FALSE
7     6         Vectorising Grid Classes       FALSE
8     7           Clip Grid with Polygon       FALSE
9     8               Gradient from Grid       FALSE

> rsaga.get.usage("shapes_grid", 2)

*Note that SAGA can handle even large grids/polygons (up to 2GB size).


Tom Hengl

-----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
Pieter Beck
Sent: Thursday, October 23, 2008 9:15 PM
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] subsetting

Dear all,

I am a new user to the world of spatial applications of R and am wondering
about this trivial question:

What is the easiest way to subset a SpatialGridDataFrame, based on 4 corner


The reason I ask is that I want to do an overlay of a polygon file on a
large raster dataset, to extract summary statistics from it. Both files are
extremely large, however, and just applying overlay causes memory trouble. I
was hoping to loop through the polygons, subset the SpatialGridDataFrame
using the bounding box surrounding a polygon and then create the summary
statistics one polygon at-a-time. To do this, I'd need to subset the
SpatialGridDataFrame based on the bounding box corner coordinates.

Thanks in advance for the help,


Kind Regards,

Pieter Beck


	[[alternative HTML version deleted]]

R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch

More information about the R-sig-Geo mailing list