plotstatacartographycartogram

Issue with Plotting Counties Using spmap


I am trying to plot the counties in the continental U.S. by a value that the counties have associated with them. I am using the spmap package. My shape files comes from: https://www.census.gov/geo/maps-data/data/cbf/cbf_counties.html. I am using the 500k version.

capture ssc install spmap
capture ssc install shp2dta

I unzip the file. I then load the map as follows:

shp2dta using "cb_2015_us_county_500k.shp", database(county2015db) coordinates(county2015coord) replace
use county2015db, clear
destring STATEFP, replace
destring GEOID, replace

If I don't want to shade the counties, everything works perfectly:

spmap using county2015coord if STATEFP<60 & STATEFP!=2 & STATEFP!=15, id(GEOID)

However, only a handful of counties are filled in (and the map is much smaller and Alaska appears) if I do the following (just using _ID as the values for this toy example):

spmap _ID using county2015coord if STATEFP<60 & STATEFP!=2 & STATEFP!=15, id(GEOID) fcolor(Blues)

What to do?


Solution

  • I should have used _ID in the id( ) field instead of using GEOID. That solves the problem.