[R] thematic maps, missing data, gmap
John P. Burkett
burkett at uri.edu
Sat Aug 2 22:40:16 CEST 2008
Running R version 2.6.1 under Gentoo Linux, I'm trying to produce a
thematic map of the USA using the gmap package and its function
USALevelPlot. The variable whose levels are to be plotted is observed
for 49 states but missing for one (Delaware).
I would like to produce a map in which the states for which data exist
are shaded and Delaware is represented only by an outline. In contrast
the command
grid.pack("map",USALevelPlot(states=statenames,levels=spc,col.fun=greens,normalize=T),height=unit(1,'null'))
produces a map in which Delaware's borders with New Jersey and Maryland
appear (because data for the latter two states are observed) but
Delaware's coastline is omitted. The result looks like there is a bay
where Delaware should be. If anyone could suggest a method for drawing
in the missing coastline or Delaware's complete boundary, I would be
most grateful.
My .R code for the map is as follows:
********Code starts here**********************************************
library(gmaps)
grid.newpage()
grid.frame(name="map") # Create a frame for packing objects.
statenames <- list("Alabama", "Alaska", "Arizona", "Arkansas",
"California", "Colorado", "Connecticut",
"Florida", "Georgia", "Hawaii", "Idaho",
"Illinois", "Indiana", "Iowa", "Kansas",
"Kentucky", "Louisiana", "Maine", "Maryland",
"Massachusetts", "Michigan", "Minnesota", "Mississippi",
"Missouri", "Montana", "Nebraska", "Nevada",
"New Hampshire", "New Jersey", "New Mexico", "New York",
"North Carolina", "North Dakota", "Ohio", "Oklahoma",
"Oregon", "Pennsylvania", "Rhode Island", "South Carolina",
"South Dakota", "Tennessee", "Texas", "Utah",
"Vermont", "Virginia", "Washington", "West Virginia",
"Wisconsin", "Wyoming") # Delaware is not observed
grid.pack("map",USALevelPlot(states=statenames,levels=spc,col.fun=greens,normalize=T),height=unit(1,'null'))
**************Code ends here*******************************************
If the data would be helpful, I can supply them.
John
--
John P. Burkett
Department of Environmental and Natural Resource Economics
and Department of Economics
University of Rhode Island
Kingston, RI 02881-0808
USA
phone (401) 874-9195
More information about the R-help
mailing list