[R-sig-Geo] changing the area of a shapefile to a new value

Tom_R tom.richardson at bristol.ac.uk
Sun Jan 2 19:41:45 CET 2011


Hi List,
I would appreciate some help regarding resizing shapefile areas.
I have several different animals, each with a different home-range (HR). To
test whether the overlap between HR's is more or less than expected, I would
like to reassign the HR areas amongst the different HR's. THen I will
compare the permuted overlap to the observed overlap. 

My (inelegant) code goes:

## load data & set up HR
xy <-  data.frame(cbind(points$x,  points$y))                ## x,y coords
ud <-  kernelUD(xy, id=NULL, h = "href",  kern = c("epa"))  ## 
kernel-estimate of the home range (from adehabitat)
ver <- getverticeshr(ud, home.range)     ## The HR; may have >1 disjoint
areas, & also have empty lakes
shapefile_HR <- kver2shapefile(ver)                              ##
shapefile for an individual animal
blobby <- shape2poly(shapefile_HR, region.id=NULL)	## convert shapefile  to
a polygon
HR_polygons <-  lapply(ver, area2spol)   			## convert "shapefile" to
"spatial polygons"

## Sum the area across all of the (potentially) disjoint parts
for (h in 1:length(blobby)  )                             ## loop for each
of the disjoint parts of the HR
	{
	regions <- slot(HR_polygons[[1]], "polygons")
	regions <- lapply(regions, function(x) {SpatialPolygons(list(x))})
	windoze <- lapply(regions, as.owin)			                  ## A spatstat
window		
	wind_shape <- writePolyShape(as(windoze[[h]], "spatialPolygons")
	if (h == 1) {blob_area <- area.owin(windoze[[h]])}                 
	if (h > 1)  {blob_area <- blob_area + area.owin(windoze[[h]])} ## sums the
disjoint HR areas
	}

The above gives me the HR area for a single animal ("blob_area"). But what I
would now like to do is to enlarge or shrink the HR's (i.e. modify
"shapefile_HR") of each animal. If all I wanted to do was to increase the HR
size by a factor x, then I could use the "scaleXY" function. However, I
actually need to change the AREA, to a new value, e.g. enlarge 
"shapefile_HR" from 130 mm^2 to  350mm^2. I can't find a simple function to
do that...

I imagine there is a simple function to do this, & I have spent all day
looking, to no avail...

Thanks list & happy 2011!
Tom


-- 
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/changing-the-area-of-a-shapefile-to-a-new-value-tp5879842p5879842.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list