Chapter 4
Chapter 4
data
V I S U A L I Z I N G G E O S PAT I A L D ATA I N R
Charlo e Wickham
Assistant Professor at Oregon State
University
Median incomes in New York County
Census tracts are areas with roughly the
same number of people
Spatial objects:
Census tract polygons
dir("water")
"water-areas.dbf" "water-areas.prj"
"water-areas.shp" "water-areas.shx"
plot(water)
dir()
"usgrid_data_2000" "usgrid_data_2000_1"
dir("usgrid_data_2000")
class : RasterLayer
dimensions : 3120, 7080, 22089600 (nrow, ncol, ncell)
resolution : 0.008333333, 0.008333333 (x, y)
extent : -125, -66, 24, 50 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0
data source : /Users/wickhamc/Documents/Projects/courses-visualizing-geospatial-
data-in-r/data/census_grids/usgrid_data_2000/uspop300.tif
names : uspop300
values : 0, 65535 (min, max)
Charlo e Wickham
Assistant Professor at Oregon State
University
proj4string()
proj4string(countries_spdf)
proj4string(water)
proj4string(neighborhoods)
class : SpatialPoints
features : 1
extent : -123.262, -123.262, 44.5646, 44.5646 (xmin, xmax, ymin, ymax)
coord. ref. : NA
class : SpatialPoints
features : 1
extent : -123.262, -123.262, 44.5646, 44.5646 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
spTransform(x, proj4string(neighborhoods))
class : SpatialPoints
features : 1
extent : -11214982, -11214982, 5127323, 5127323 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=lcc +lat_1=40.66666666666666
+lat_2=41.03333333333333 +lat_0=40.16666666666666
+lon_0=-74 +x_0=300000 +y_0=0 +datum=NAD83
+units=us-ft +no_defs +ellps=GRS80 +towgs84=0,0,0
Charlo e Wickham
Assistant Professor at Oregon State
University
Income data from ACS
str(nyc_income)
class : SpatialPolygons
features : 4 "156" "157" "158" "159"
extent : -73.99022, (xmin)
-73.97875, (xmax) four_data
40.71413, (ymin)
40.73329 (ymax)
TRACTCE
coord. ref. : +proj=longlat +datum=NAD83
159 004000
+no_defs +ellps=GRS80
158 003200
+towgs84=0,0,0
157 002201
156 001401
SpatialPolygonsDataFrame(four_tracts, four_data)
class : SpatialPolygonsDataFrame
features : 4
extent : -73.99022, -73.97875, 40.71413, 40.73329 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0
variables : 1
names : TRACTCE
min values : 001401
max values : 004000
SpatialPolygonsDataFrame(four_tracts, four_data)@data
TRACTCE
156 001401
157 002201
158 003200
159 004000
TRACTCE
159 004000
158 003200
157 002201
156 001401
Recreate object being very careful to match polygons to the right rows
Charlo e Wickham
Assistant Professor at Oregon State
University
Polishing a map
Remove distractions, let data shine
Like any plot: check legend, title, and labels for readability
Add annotations:
Highlight important points
Charlo e Wickham
Assistant Professor at Oregon State
University
Final tweaks
Tweak labels "by hand"
Add $ to legend
S4 objects
Polishing a map