treblemaker24
treblemaker24

Reputation: 11

Making Maps of Individual US Counties in R

I'm wondering how to make a map of ONLY a county in R, and if possible, how to do this without using a shapefile.

For example, I'd like to make a map of Los Angeles county in California. Is there anyway for me to call up a map of just LA county?

What I tried is to set xlim and ylim to manually "crop" the map that is displayed (finding the coordinates on Google Maps), but I'm looking for a easier way to make maps of counties.

Here's what I did to plot LA county:

map("county", interior=TRUE, regions="california",
    xlim=c(-119.023098 ,-117.435574), ylim=c(33.70319 ,34.941657))

And here's an example of the type of map that I'm looking for:

enter image description here

Suggestions on an easier way to create substantively the same map would be greatly appreciated.

Upvotes: 1

Views: 2399

Answers (2)

Feral Fern
Feral Fern

Reputation: 75

I would suggest using ggmap to map the counties. You could simply get a map of the county using a string:

library(ggmap)
la_county<-get_map('los angeles county')
ggmap(la_county)

Or you could use the x and y coordinates to center the map view:

library(ggmap)
la_county<-get_map(c(-118.2218,34.3582)) #or get_map(c(mean(-119.023098 ,-117.435574), mean(33.70319 ,34.941657)))
ggmap(la_county)

You can also adjust the basemap aesthetics and zoom level:

library(ggmap)
la_county<-get_map('los angeles county', zoom=9, type='toner')
ggmap(la_county)

Upvotes: 0

Molx
Molx

Reputation: 6931

Just use regions with the county name:

map("county", regions="california,los angeles")

Upvotes: 2

Related Questions