[R-sig-Geo] Merging SpatialPolygonsDataFrame and SpatialLinesDataFrame

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Mar 17 13:58:35 CET 2009


Jim Burke schrieb:
> Hi everyone,
>
> Been scratching my head on this. A common
> operation. Google seems to be mute on this,
> so I turn to you.
>
> I have a nice SpatialPolygonsDataFrame that I
> can plot with wonderful colors using spplot.
>
> I would like to
>
> 1. MERGE SpatialLinesDataFrame (PolyLine) over
> the SpatialPolygonsDataFrame (Polygons). And
> plot with spplot().
add the SpatialLinesDataFrame as an object in the sp.layout argument to 
spplot, as in
spplot(x, ..., sp.layout = list("sp.lines", SLDF, col = 'black'))
>
> 2. CLIP the PolyLine to the area of the Polygons.
> The polygons are within the larger main_main roads
> Polyline
Hard to do; I just found out it can be done with aRT, which requires you 
to run TerraLib as the GIS on your computer.
>
> 3. COLOR PolyLine main_roads different than
> black for example; white or gray.
you could select, them, and nest, as in
..., sp.layout = list(list("sp.lines", SLDF1,col='red'), 
list("sp.lines", SLDF2, col='blue'))

Bests,
--
Edzer
>
>
> NOTES. FILE READS ARE BELOW
>
> >tx3_sp <- readShapePoly("tx3_sp.shp", IDvar="PCT",
> proj4string=CRS("+proj=aea +ellps=GRS80 +datum=WGS84"),
> verbose=TRUE, repair=FALSE)
> Shapefile type: Polygon, (5), # of Shapes: 39
>
> >main_roads <-readShapeLines("main roads.shp",
> proj4string=CRS("+proj=aea +ellps=GRS80 +datum=WGS84"),
> verbose=TRUE,repair=FALSE)
> Shapefile type: PolyLine, (3), # of Shapes: 29161
>
> > class(tx3_sp)
> [1] "SpatialPolygonsDataFrame"
> attr(,"package")
> [1] "sp"
>
> > class(main_roads)
> [1] "SpatialLinesDataFrame"
> attr(,"package")
> [1] "sp"
>
> Thanks and I am grateful for all thoughts and assistance,
> Jim Burke
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list