[R-sig-Geo] SpatialPolygons to SpatialLines?

Lyndon Estes lestes at princeton.edu
Wed Aug 10 02:10:15 CEST 2011


Hi Jonathan,

You can do this as follows:

x <- yourSpatialPolygons
xl <- as(x, "SpatialLines")

e.g.

library(maptools)
library(rgdal)
nc <- readShapePoly(system.file("shapes/sids.shp",
package="maptools")[1], proj4string=CRS("+proj=longlat +datum=NAD27"))
quartz()
plot(nc[1, ], col = "blue")
nc1l <- as(nc[1, ], "SpatialLines")
plot(nc1l, col = "blue")


Cheers, Lyndon



On Tue, Aug 9, 2011 at 6:51 PM, Jonathan Greenberg
<greenberg at ucdavis.edu> wrote:
> R-sig-geo'ers:
>
> Is there a quick way to create a line object from a polygon object
> (representing the boundary)?
>
> --j
>
> --
> Jonathan A. Greenberg, PhD
> Assistant Project Scientist
> Center for Spatial Technologies and Remote Sensing (CSTARS)
> Department of Land, Air and Water Resources
> University of California, Davis
> One Shields Avenue
> Davis, CA 95616
> Phone: 415-763-5476
> AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list