[R-sig-Geo] Appending numerous polygons to a single shapefile

Roger Bivand Roger.Bivand at nhh.no
Sun Oct 4 20:13:08 CEST 2009


On Sun, 4 Oct 2009, McIlwee, Allen (DEH) wrote:

> Hi all
>
> I have a script that plots alpha hulls, which I am using to investigate 
> the timing & extent of range size collapses for hundreds of plant 
> species across South Australia.
>
> I'm sure this must be an easy question for most - but I am having 
> trouble generating a shapefile that contains all the remaining triangles 
> for a species, given a particular alpha value. The script below will 
> give me a separate shapefile for every polygon, but I don't fancy 
> piecing these together manually in ArcGIS.
>
> Is there an easy way to join together consecutive polygons so that the 
> last item is the union of them all?
>
> Thanks
> Allen
>
> alpha1a<-data.frame(xx, yy)
> alpha1b<-rbind(alpha1a,alpha1a[1,])
> alpha1c<-Polygon(alpha1b)
> alpha1d<-Polygons(list(alpha1c),"1")
> alpha1e<-SpatialPolygons(list(alpha1d),1:1)
> alpha1_data<-data.frame(cbind(alpha1a))
> alpha1_df<-SpatialPolygonsDataFrame(alpha1e,alpha1_data)
> writeOGR(alpha1_df,"c:/R/AlphaHulls/Shapefiles",paste(this.sp,"alpha1",i,sep=" "),"ESRI Shapefile")
>
> I can provide more detail on other parts of the script if need be?

If they do not overlap, you could simply build a SpatialPolygons object 
from a list of the Polygons objects, one for each alpha hull. If you need 
polygon union as such, see unionSpatialPolygons() in maptools, or the 
interface there to gpclib polygon handling. The gpclib package could also 
handle overlaps.

Hope this helps,

Roger

>
> Allen McIlwee
> NatureLinks Policy Support Officer
> Nature Conservation Branch
>
> Department for Environment and Heritage
> Richmond Rd, KESWICK
> T: 61+ 8+ 8124 4733
> F: 61+ 8+ 8463 4818
> E: allen.mcilwee at sa.gov.au
> M: 0427 255 367
> A: GPO Box 1047, Adelaide, SA, 5001 AUSTRALIA
>
> <http://www.environment.sa.gov.au>
>
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list