[R-sig-Geo] Graphing Canadian Cities via Forward Station Area (FSAs) Spatial Information

Michael Friendly friendly at yorku.ca
Mon Apr 9 21:17:54 CEST 2012


Look at ?subset.Spatial

Perhaps this will get you started, but you should probably buy & read
Applied Spatial Data Analysis with R by Bivand etal/

# examine  first letter of postal code for GTA
table(substr(canada.fsa.spatial$CENSUS_FSA,1,1))


inLM <- substr(canada.fsa.spatial$CENSUS_FSA,1,1) %in% c('L','M')
GTA <- subset(canada.fsa.spatial, inLM)

plot(GTA)




On 4/5/2012 4:33 PM, Mike Sukmanowsky wrote:
> Hi everyone,
>
> We're trying to overlay some internal information that we have regarding
> certain Canadian cities.  The data that we have is specified by Forward
> Station Area (FSA) which corresponds to the first three digits of a
> Canadian postal code.
>
> The Government of Canada provides a shapefile (.dbf, .shp, .prj, .shx) from
> the 2006 Census for all FSAs in Canada.
>
> The current question I have is how to use this shapefile to effectively
> "zoom in" to just a few Canadian cities / areas and then display a
> choropleth just of a certain area (the Greater Toronto Area for example
> which is roughly equivalent to all FSAs which start with the letter L or M).
>
> Here's the code I'm currently using as well as a link to the shapefile
> itself.  Can someone provide an example of how to "zoom in" to Toronto for
> example and display a choropleth with some randomized data as an example?
>   I'm just not positive how to use the maps, maptools, sp, etc libraries to
> limit the plot to a specific area and then add additional data to the data
> frame for the purpose of the choropleth.
>
> library(maps)
> library(maptools)
> library(sp)
>
> # Zip file available from
> https://s3.amazonaws.com/tgam.general/gfsa000a06a_e.zip
> # PDF explaining file available here
> https://s3.amazonaws.com/tgam.general/92-170-GIE2006001.pdf
> canada.fsa.spatial<-
> readShapePoly("~/Documents/Census/2006/gfsa000a06a_e/gfsa000a06a_e",
> IDvar="CENSUS_FSA",
> verbose=T)


-- 
Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    Web:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA



More information about the R-sig-Geo mailing list