Database Reference
In-Depth Information
Taking Shape
To display a map of Philadelphia with our foreclosures, we need to find a polygon of the
county as well as a means of plotting our lat/long coordinates onto it. Both of these require-
ments are met by the ubiquitous ESRI shapefile format. The term shapefile collectively refers
to a .shpfile (which contains polygons), and related files that store other features, indices, and
metadata.
Finding a Usable Map
Googling “philadelphia shapefile” returns several promising results including this page: ht-
tp://www.temple.edu/ssdl/Shape_files.htm .
The “Philadelphia Tracts” maps on that website seem useful because they include US Census
Tract information. We can use these tract IDs to link to other census data. Tracts are stand-
ardized to contain roughly 1500‒8000 people, so densely populated tracts tend to be smaller.
This particular shapefile is especially appealing because the map “projection” uses the same
WGS84 Lat/Long coordinate system that our address geocoding service uses, as opposed to a
“state plane coordinate system,” which can be difficult to transform. Transformations require
the rgdal package and GDAL executables .
Save and unzip the following file to your project directory: http://www.temple.edu/ssdl/shp-
files/phila_tracts_2000.zip .
PBSmapping
PBSmapping is a popular R package that offers several means of interacting with spatial data.
It relies on some base functions from the maptools package to read ESRI shapefiles, so we
need both packages:
> install.packages(c("maptools","PBSmapping"))
As with other packages, we can see the functions using library(help=PBSmapping) and
view function descriptions using ?topic : (see http://cran.r-project.org/web/packages/
PBSmapping/index.html ).
We can use str to examine the structure of the shapefile imported by PBSmap-
ping::importShapeFile :
> library(PBSmapping)
PBS Mapping 2.61.9 -- Copyright (C) 2003-2010 Fisheries and Oceans
Search WWH ::




Custom Search