[R] Data for use in maps()

White.Denis@epamail.epa.gov White.Denis at epamail.epa.gov
Tue Feb 17 22:17:06 CET 2004

> I am interested in plotting maps visualizing spatial statistics in an
> aggregated fashion, according to administrative boundaries.
> More specifically, I have fitted a cross-section model on data
> Italian "counties" (province, for Italian readers) and I would like to
> visualize residual behavior on a map, in order to have a first
> assessment of their spatial autocorrelation. I would also make some
> on the spatial patterns (if any) of the regressors.
> I have found the maps package (and related) and would be able to do
> I want, e.g., for the USA, essentially by
> >map("state",fill=T,col=color)
> where color is dependent on the statistic of interest, but I still
> a data file for counties' boundaries in Italy. Does anybody know where
> to find one? Is there any convenient tool for converting from other
> formats? I would like to do everything in R if possible.
> Thanks in advance
> Giovanni Millo
> R&D Dept.

Dear Millo Giovanni:

Attached is a zip file containing three files.  The file
is a R/Splus format polygon file of the provinces.  In this file, there
are NA records in the $y column where the polygons end.  The
$x column are polygon identifiers.

The file 'italy.prov.pat' has three columns: the first are the polygon
identifiers used in 'italy.prov.pol', the second are the NUTS3
and the third are the names.  The file 'italy.prov.crf' has commas
separating the fields.

The file italy.prov.e00 is an arc/info export file of a polygon coverage
of the province boundaries.  This was extracted from the European NUTS3
file of third level political boundaries available at:
http://www.grid.unep.ch/data/grid/gnv159.php.  The R/S format files
were made from this arc/info file.

All location coordinates in the above files are geographic
(longitude, latitude).

In Becker and Wilks document "Constructing a Geographical Database" that
accompanies the 'maps' package there is a description of how to make a
database that can be used by the maps package.  I am not aware that
has made this capability available in R, and I have not done this

You can read the .pol file like this:

prov <- read.table ("italy.prov.pol", header=TRUE)

You can then use this function:

plot.map <- function (x, y) {
  rx <- range (x[!is.na(y)], na.rm=TRUE)
  ry <- range (y[!is.na(x)], na.rm=TRUE)
  plot.new ()
  plot.window (rx, ry, asp=1)

and say

plot.map (prov$x, prov$y)
polygon (prov)

You can read the .pat file like this:

pat <- read.table ("italy.prov.pat", sep=",", header=TRUE, quote="")

With this file you can connect the polygon boundaries in the .pol file
with names in .pat and with your statistics.  There is a crude mapping
facility available in contributed package "maptree".

Best wishes,

Denis White
   US EPA, 200 SW 35th St, Corvallis, Oregon, 97333 USA
   voice: 541.754.4476, email: white.denis at epa.gov
   web: www.epa.gov/wed/pages/staff/white/

< attachment deleted>

More information about the R-help mailing list