[R-sig-Geo] Calculating what proportion of polygons is covered by rivers

Juta Kawalerowicz juta.kawalerowicz at nuffield.ox.ac.uk
Mon Dec 1 11:07:58 CET 2014


Many thanks for this suggestion Robert. Meanwhile, for anyone trying to
solve similar problem in the future a nice walk though is on page 139-140
of the new edition of Applied Spatial Data Analysis with R book!

Juta

On Mon, Dec 1, 2014 at 8:24 AM, Robert J. Hijmans <r.hijmans at gmail.com>
wrote:

> Juta,
> I think you can do something along these lines:
>
> library(raster)
> library(rgeos)
>
> x <- union(districts, rivers)
> a <- gArea(x, byid=TRUE)
> head(x)
> head(a)
>
> or
> x <- intersect(districts, rivers)
>
> and compare to 'districts'
>
> Robert
>
>
> On Sun, Nov 30, 2014 at 2:59 PM, Juta Kawalerowicz
> <juta.kawalerowicz at nuffield.ox.ac.uk> wrote:
> > Hi, I have question - I am looking for ideas how to proceed.
> >
> > I have a SpatialPolygonsDataFrame with polygons (300) representing
> > districts. Another SpatialPolygonsDataFrame has 700 polygons and these
> > polygons represent rivers and flooding areas. My question is how would
> you
> > go about calculating what proportion of districts is covered by rivers
> and
> > flooding areas?
> >
> > My first intuition was to rasterize it and then use the extract function
> > but maybe I am overcomplicating this. Any ideas would be appreciated.
> >
> > Thanks,
> > Juta
> >
> >         [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo at r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list