[R-sig-eco] Extract polygons from Shape file

Jess jessie.a.berndt at gmail.com
Fri Jul 26 10:46:13 CEST 2013


Hi

I am working on nest data which is point set data. I have changed my nest
point GPS data  to polygons with a width of 6km, as this is the territory
size of a Martial Eagle. I want to extract this polygon (territory) from a
shape file I will overlay the polygon on. for example I have a primary
productivity layer and I want to average the primary productivity over the
6km Martial Eagle territory. Previously I would have used the gbuffer
function to extract the polygon, but reading the help files I have
discovered that you cannot extract a polygon (territory) from a polygon
shape file i.e SpatialPolygonDataFrame. How on earth do I do this?

The other thing I need to find out is how to do the above but with a shape
file that contains categorical variables? So extract the polygon (territory
) from a shape file that contains for example vegetation type. Extract the
vegetation type from within the polygon (territory) from the vegetation
shape file and average,  the vegetation structure (which is obviously
qualitative data).

Here is what I did for extracting my polygon (territory) from a raster
rainfall image, now I need the same thing using SpatialPolygonDataFrame and
a shape file that contains qualitative data instead of raster image

RainMA<- readGDAL("mean_an_prec")  # this is the rainfall rasta image I am
pulling into R

test <- gBuffer(Eagles.me06, width = 6) # makes my GPS  points into polygons

proj4string(test)<- proj4string(RainMA)# add a projection

library(raster)

rain.rast <- raster(RainMA)

rain.vals <- extract(rain.rast, Eagles.me06, buffer = 6) # extracted the
rainfall values from the raster image inside my polygon # I still need to
average these




--
View this message in context: http://r-sig-ecology.471788.n2.nabble.com/Extract-polygons-from-Shape-file-tp7578318.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.



More information about the R-sig-ecology mailing list