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

Massimo Ventrucci massimo.ventrucci at unibo.it
Thu Aug 21 00:19:29 CEST 2008


Roger,
sorry if I reply so late to your, instead, really quick suggestion at my problem,
actually I revised the question and I am not yet able to do that plot. I try to explain clearly my problem. 
 
I need to plot a map, for instance, in the same way I can plot it with winbugs from the mapping tool menu. So I need to plot a value for each region of my map and to colour regions characterized by higher values. I have the map in a Spatial Polygons object, I do not have it in shape file unfortunately. So I am working with package "sp". Moreover I can not use the spplot because I do not have a SpatialPolygonsDataFrame object, just a SpatialPolygons. In other words I do not have a value for each x-y coords, but I would need a value for each region, hence for each polygon belonging to the list of polygons. 
 
 
Please, any suggestion about which is the easiest way to do it, if any? 
Thank you very much 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

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 <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> 
> 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 <https://stat.ethz.ch/mailman/listinfo/r-sig-geo> 




More information about the R-sig-Geo mailing list