[R] Graphically show population density for a specific geographicarea using R

Greg Snow Greg.Snow at intermountainmail.org
Mon May 21 21:28:52 CEST 2007


1. Yes you need a shape file with that information.

2. One place to look is:
http://www.census.gov/geo/www/cob/bdy_files.html There are shapefiles
(the .shp ones) for counties and zip codes (as well as many other
things).  These work pretty directly with the tools in the maptools and
sp packages.

3. Read the .shp file in using maptools, the .dbf information is
automatically read in as well (with whatever details come with the
shapefile), then look at the structure of what you read in, you will see
the data frame and you should be able to just add your data into that
data frame, or use it seperately.

4. plot.Map has an option auxvar, though it is now prefered to use the
plot methods for the more specific objects (SpatialLinesDataFrame object
from the readLinesShape function).  I would expect that they would have
an auxvar or similar argument also.  Or you can decide what color you
want to use, plot the overall map, then add each county/zipcode
individually using the specified color.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Liu, Ningwei
> Sent: Monday, May 21, 2007 1:05 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Graphically show population density for a 
> specific geographicarea using R
> 
> Hi, 
> 
> 
> we all know that R is powerful in dealing with graphics. 
> 
> I am now trying to use R to show some geographic attributes 
> for a specific geographic area on a graph. For example, if I 
> would like to generate a graph showing the population 
> densities (in terms of the intensity of colors) for Illinois 
> State by zip codes. I did some research; and it seems that 
> package "maptools" is relevant. But I have the following 
> couple of questions regarding to the application. 
> 
> 1.  A State is grouped by several counties, and sometimes we 
> could further divide it into many areas by zip codes. Will 
> there be any differences in the shapefiles (.shp)? Do I need 
> to get a specific shapefile in order to graph on a zip code level? 
> 
> 2. Where can I get this kind of shapefiles? 
> 
> 3. There is another type of file (.dbf) which includes the 
> attributes of a geographic area. It seems I could put the 
> population densities in it.
> But then how could I relate it to the shapefile (.shp)? I 
> mean how to link a population density to its corresponding 
> zip code area? 
> 
> 4. Finally, how could I use intensity of colors to show the 
> differences in the population densities? 
> 
> 
> I would greatly appreciate it if someone could provide me a 
> simple example. Thanks a lot! 
> 
> 
> Ningwei
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list