[R-sig-Geo] convertion to polygon for coloring, shading (was: clipping in maptools)

Roger Bivand Roger.Bivand at nhh.no
Sat Oct 1 10:47:15 CEST 2005


On Fri, 30 Sep 2005, Sebastian Luque wrote:

> On Fri, 30 Sep 2005 23:38:39 +0200 (CEST),
> Roger Bivand <Roger.Bivand at nhh.no> wrote:
> 
> [...]
> 
> > Using the plot method for sp class SpatialPolygons, the xlim= and ylim=
> > arguments do what you want. They do in plot.polylist() too, but in
> > plot.Map() you get warnings when the arguments are passed to plotting
> > functions that don't know about them.
> 
> I should have imagined that xlim and ylim could be passed to these
> functions.  Thank you, that helped!
> 
> On a related note, I'm also trying to color some of these maps, so IIUC
> they need to be converted to polygons.  I thought that Map2poly would be a
> good candidate, but I its main argument needs to be a Map object as
> imported from a GIS polygon vector file.  It seems my Map object doesn't
> fit this description, as I'm getting this error:
> 

Try:

> getinfo.shape("your_file.shp")

and see what it says. If it is not type (5)  - or since version 0.4-15
(15) - it is not a polygon file. If the lines are known to form rings,
there are ways of doing this using sp classes, but you have to know
definitely that the lines are rings, not spaghetti. Ask again if you have 
a type (3) or (13), and know that all the lines really are rings.

Which version of maptools are you using - enter maptools() to see?

> ,-----
> | Error in Map2poly(myMap) : maptype not poly
> `-----
> 
> Finally and with apologies if it's somewhat OT: for things like including
> a scale and north arrow, is it better to export the shape file and do
> these in Arcview or Grass, or can it be done within R?  I thought I'd ask
> more experienced users.

The scale and north arrow are available in sp - see ?"spplot-methods" for 
how to use them in lattice graphics. In base graphics, arrows() and a 
combination of lines() and/or rect() should do it, but they are not 
pre-programmed (yet).

> 
> Any pointers would be most welcome.  Thanks a lot once again.
> 
> 
> Cheers,
> 
> 

-- 
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