[R-sig-Geo] plot a variable in a SpatialPolygons object

Roger Bivand Roger.Bivand at nhh.no
Mon Jul 28 17:44:30 CEST 2008


On Mon, 28 Jul 2008, Massimo Ventrucci wrote:

> Dear all,

> sorry my question seems to me quite basic and perhaps is already posted 
> but at a first sight I did not find it. Basically I have a map of 
> contiguous areas in the form of a SpatialPolygons object. In all areas I 
> need to display the value of a binary value (e.g. to color the areas 
> corresponding to value 1). I have to say in a guide to the package 
> "spdep" I found the code to do a map (it was a map of probabilities 
> buillt by using plot coomand after having used probmap command), but in 
> that case the plot is done starting from an object of class polylist if 
> I say well. Instead I need to do a plot starting from a SpatialPolygons 
> object because I do not have the map in other formats.

I'm planning to update the now very obsolete vignette in spdep soon. The 
easiest way to plot a variable from a SpatialPolygonsDataFrame object is 
the spplot method in the sp package (which spdep loads). Just try:

spplot(my_SpolDF, "myvar")

for a first cut.

Base graphics methods, such as plot(), are also available. The best online 
guide may be one of the units at:

http://www.bias-project.org.uk/ASDARcourse/

either "Vizualising Spatial Data" for the description, or your choice of 
the worked examples. There are also code examples and figures on the ASDAR 
book website: www.asdar-book.org; though this is still under construction, 
most things are there.

Roger

>
> Moreover, in future I will also need to plot values graduated by colors.
>
> Please, can you help me?
> thanks in advance
> massimo
>
> Massimo Ventrucci
> Ph.D Student in Statistics
> Dipartimento di Scienze Statistiche
> Università degli studi di Bologna
> Via Belle Arti 41
> 40126 Bologna-Italy
> _____________________________________
>
> Phone +39(051)264182 (office)
> Fax     +39(051)232153
> E-mail massimo.ventrucci at unibo.it
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

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