[R-sig-Geo] changing a polygon feature of position.

Roger Bivand Roger.Bivand at nhh.no
Fri Jan 18 14:39:29 CET 2008


On Thu, 17 Jan 2008, Milton Cezar Ribeiro wrote:

> Hi there,
>
> I have a shapefile with several non-contiguos polygons, and I identifyed 
> the centroid of each one. I modified some midpoints of polygons and now 
> I need to place those polygon which had its midpoints changed in a way 
> that the new centroid position come to be aproximately the new 
> midpoints.
>
> In other words, can I change de position of polygons of interest, 
> shifting the x and y midpoints?

Yes, although it will be a bit messy. First subset the input polygons so 
that your SpatialPolygons or SpatialPolygonsDataFrame object only has the 
polygon(s) to be manipulated in a particular way. Then find the new 
mid-point, and use the elide() methods in maptools, argument shift=c(), to 
move the midpoint from the old to the new, and the polygon will be 
shifted. Repeat for all the different shifting operations.

So what you need for the shift= arguments are the offsets in x and y 
directions between the old and new positions, and elide will move the 
polygon coordinates.

Roger

>
> Kind regards,
>
> Miltinho.
> Brazil
>
>
>
> para armazenamento!
>
> 	[[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