[R-sig-Geo] Changing Shapefile's Coordinates
b.rowlingson at lancaster.ac.uk
Wed Jul 20 13:20:53 CEST 2011
On Wed, Jul 20, 2011 at 12:31 AM, Wang, Kevin (SYD)
<kevinwang at kpmg.com.au> wrote:
> I'm just wondering if it's possible, in R, to modify a shapefile's
> I've shapefiles for each state/territory of Australia, and in them there
> are local government areas coordinates. Using readShapePoly(), I am
> able to read them in and plot each state with its local government
> However, I also want to be able to "merge" local government areas into
> roughly north-east-south-west - i.e. draw a state then divide it roughly
> into four quadrants (or divide it in other ways by merging various local
> government areas). Is there any easy way that I can manipulate the
> shapefile to do this?
Another job for rgeos!
Can do something with gUnionCascaded?:
xx <- readShapeSpatial(system.file("shapes/sids.shp",
# plot it, label it:
# now suppose we want to merge these regions:
z1 = c(10,24,9,71)
# we do:
# which gives us a SpatialPolygons object with (in this case) one ring:
Repeat for each of your regions and splat everything together as a
SpatialPolygonsDataFrame if thats what you need.
Look out for digitising errors which result in slivers and other junk
where adjacent polygons dont match up.
More information about the R-sig-Geo