You can change the limits of a plot using the xlim
and ylim
arguments of the plot
function:
library("rgdal")
shp <- readOGR("tl_2009_48_zcta5.shp", "tl_2009_48_zcta5")
plot(shp, xlim=c(-97.13, -96.47), ylim=c(32.47, 33.08), col="orange")
or you can subset shp
(an object of class SpatialPolygonsDataFrame
):
zip_dallas <- c(75019, 75039, 75043, 75048, 75050, 75051, 75060, 75062, 75081,
75089, 75098, 75104, 75125, 75134, 75141, 75146, 75149, 75154,
75159, 75172, 75181, 75182, 75217, 75232, 75241, 75247, 75253,
75001, 75006, 75248, 75254, 75180, 75007, 75234, 75287, 75115,
75137, 75249, 75211, 75063, 75067, 75041, 75052, 75061, 75080,
75088, 75116, 75150, 75201, 75202, 75203, 75204, 75205, 75206,
75207, 75208, 75209, 75210, 75212, 75214, 75215, 75216, 75218,
75219, 75220, 75223, 75224, 75225, 75226, 75227, 75228, 75229,
75230, 75231, 75233, 75235, 75236, 75237, 75238, 75240, 75243,
75244, 75246, 75251, 75252, 75270, 75040, 75042, 75044, 75038,
75082, 76051)
ind <- x[["ZCTA5CE"]] %in% zip_dallas
plot(x[ind, ], col="orange")
Applied Spatial Data Analysis with R is a good reference for basic R usage and advanced spatial statistics.