[R-sig-Geo] Intersect & Plot a Polygon and wkbLineString

Jim Burke j.burke at earthlink.net
Tue Feb 17 14:34:53 CET 2009


Sorry, we seem to have misunderstood each other.  Basically I have a 
county-wide set of roads called "major roads".  Then originally I had an 
identically sized county-wide set of polygons of which I select (via R) 
a smaller than county-wide subset of adjacent polygons and plot that 
subset.

The "add = TRUE" in plot operations suggestion sounds interesting. 

Your last paragraph is indeed all I am trying to achieve.  I need a GIS 
program to do this? I thought that R might be able to clip the major 
roads file (via an intersect) to conform to the polygon shapes.

I don't know, maybe I am approaching this the wrong way (i.e. trying to 
find the SQL style intersection of these two blobs). Perhaps another 
approach may be better. I think I will do the following.

1. Plot the major roads and try to get the street names on them. No 
polygon here.

2. Overlay what's going to be the large major roads over the smaller 
polygon set. The "add = TRUE" suggestion. Thanks.

3. Figure out how to trim that major roads set.

I have your book "Applied Spatial Data Analysis with R (Use R)" on order 
and it should arrive later today. Then also I am looking forward to a 
good read of "Lattice Multivariate Visualization".

Thanks,
Jim Burke



Roger Bivand wrote:
> On Mon, 16 Feb 2009, Jim Burke wrote:
>
> (Just stick to plain text, but don't use fonts or bold or stuff - keep 
> it simple).
>
>> I have a nice solid SpatialPologonsDataFrame and a new line file 
>> (wkbLineString) called "major roads.shp".
>>
>> MY QUESTIONS.
>>
>> *I would appreciate examples of*
>>
>> *a)How to merge the intersection of a **SpatialPologonsDataFrame and 
>> a wkbLineString **
>>
>
> Why, and what do you mean? You have some 30000 road lines, what do you 
> want to know? How much of which road is in which polygon? Again, you 
> need to think through your workflow. My inclination would be to 
> rasterise the lines in a GIS, and overlay the raster cell centre 
> points on the polygons, but maybe you want line length, or to retain 
> the line IDs (all 30000 of them).
>
>
>> b)How to plot the result
>
> You can of course overplot lines on polygons, with add=TRUE in plot() 
> methods and sp.layout= in spplot() methods. But plotting the result of 
> the "intersection" means what?
>
>> c)How to display the street name on the plot (that's FNAME from the 
>> major roads.dbf file).
>
> 30000 names? Do you have a very large screen? Lines objects have IDs, 
> but no label point, so there is no easy way of doing it, even label 
> alignment is hard.
>
> I can't actually see the statistical question here, could you please 
> make it clearer?
>
> Do you simply want to plot a subset of the road lines on your solid 
> polygons, adding names? Then you need to find out how to subset them, 
> perhaps by cookie-cutting using the union of your polygons, add label 
> points and rotation angles (probably by hand), and off you go, but 
> these are essentially GIS operations.
>
> Roger
>
>> *
>>
>>
>> ADDITIONAL INFORMATION.
>>
>> The SpatialPologonsDataFrame is a garden variety collection of 
>> geographical polygons.
>>> tx1_sp <- readShapePoly("precinct08.shp", IDvar="PCT", 
>> proj4string=CRS("+proj=aea +ellps=GRS80 +datum=WGS84"))
>>
>>
>>
>> The new file to intersect merge is major roads line map that should 
>> overlay part of my SpatialPolygons. It does not behave like a Shapfile.
>>
>>> main_roads <-readOGR("main roads.shp", layer = "main roads")
>> OGR data source with driver: ESRI Shapefile
>> Source: "main roads.shp", layer: "main roads"
>> with  29161  rows and  33  columns
>> Feature type: wkbLineString with 2 dimensions
>>
>>
>> Thanks,
>> 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