[R-sig-Geo] convertion to polygon for coloring, shading

Roger Bivand Roger.Bivand at nhh.no
Sat Oct 1 17:41:31 CEST 2005


On Sat, 1 Oct 2005, Sebastian Luque wrote:

> Roger Bivand <Roger.Bivand at nhh.no> wrote:
> 
> [...]
> 
> > Try:
> 
> >> getinfo.shape("your_file.shp")
> 
> Ok, I got:
> 
> --8<---------------cut here---------------start------------->8---
> R> getinfo.shape("general01.shp")
> Shapefile type: PolyLine, (3), # of Shapes: 11343
> R> maptools()
> maptools, version 0.5-2, 2005-09-13
> --8<---------------cut here---------------end--------------->8---
> 
> and because of the extent of the map, it's surely a mixture of rings
> (mostly tiny islands) and spaghetti (at the edges of the map, because the
> given shape doesn't fit entirely).  I cannot increase the extent of the
> map, so that all shapes are rings, because the map would have to be
> ridiculously large.  I guess I'll have to turn them into rings manually.
> In that case, what's a good tool to use for that?
> 

So the origin was a map of rings that has been clipped (by a rectangle?)? 
Could you try to simplify this for testing purposes to a small number of 
shapes (a much smaller rectangle) and let me see it? I've written a small 
functio using sp classes that just rbind()'s the line coordinates with the 
first coordinate if the first and last are not identical. It may work, if 
the lines start and stop on the same rectangle edge (but will not if they 
are on different edges). 

If the lines go outside the rectangle a little, the same approach will
work, but will need clipping with functions in spgpc on r-spatial, not a
big problem. If the rectangle is known, it could be given to the function
as an argument, which would maybe allow the corner case to be handled too.

Roger

> 
> [...]
> 
> > The scale and north arrow are available in sp - see ?"spplot-methods" for
> > how to use them in lattice graphics.
> 
> Excellent, I'll use that.
> 
> 
> Thank you,
> 
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list