[R-sig-Geo] Merging SpatialPolygonsDataFrame and SpatialLinesDataFrame

Kamran Safi ksafi at orn.mpg.de
Tue Mar 17 15:29:09 CET 2009


Hi all,

without having given it a lot of thought. Have you looked into PBSmapping?
you can use maptools to convert between sp spatial classes and PBS 
spatial classes.

In PBSmapping you have:

addLines(): Add a PolySet <PolySet.html> to an existing plot, where each 
unique (|PID|, |SID|) describes a polyline.
and
joinPolys(): Join one or two PolySet <PolySet.html>s using a logic 
operation, where |"DIFF"|, |"INT"|, |"UNION"|, or |"XOR"|, representing 
difference, intersection, union, and exclusive-or, respectively.

Sorry for the cryptic answer.

Kami

Edzer Pebesma wrote:
> 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
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3275 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090317/fb9386d4/attachment.bin>


More information about the R-sig-Geo mailing list