[R-sig-Geo] Add interpolated coordinates to SpatialPolygons

Karl Ove Hufthammer karl at huftis.org
Thu Sep 9 14:23:33 CEST 2010


Is there a simple way to add (lineraly interpolated) coordinates to 
SpatialPolygons; i.e., between each pair of connected points (coordinates),
add a bunch of points that lie *on* the line connecting the two points?

Here’s a very simple ASCII art example. I have a rectangle polygon:

*--------------*
|              |
|              |
|              |
*--------------*

To this I want to add more coordinates, to get:

*--*--*--*--*--*
|              |
*              *
|              |
*--*--*--*--*--*

The actual polygon would look identical when plotted. Of course my polygons 
are more complex (but non-self-intersecting).

The reason I need this is that I want to transform simple shapes from one 
projection (e.g., latlong) to a different one (e.g., Mercator). If I do a 
simple spTransform, straight lines in one projection are projected into 
straight lines in the other projection, instead of into curves, which is how 
the original polygon *should* look if reprojected.

I have tried searching for functions to do this, but it isn't easy to come 
up with the right search terms (given that such a function *does* exist).

-- 
Karl Ove Hufthammer



More information about the R-sig-Geo mailing list