Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using maptile to create maps with state border overlays

    I am trying to use maptile to create a map of the ZIP code level driving distances to the state border in a subset of US states with an overlay of the state borders. The ZIP code geography (zip5) allows this with the option stateoutline. However, when I add this option the map no longer displays just the 6 states I want, (given by a dummy state_include) but the whole US. Below is the simple code that creates the map

    Does anyone know a way to not only have state outlines on the borders but also just map a subset of the states?

    maptile Dist_drive, geo(zip5) mapif(state_include==1) stateoutline(thin)

    Thanks for any thoughts or help!

    Aaron

  • #2
    Hi Aaron. This reply is coming pretty late, but I just had to figure this out too and maybe other people have the same question. There are probably better ways of doing this, but one way is to edit the file that maptile uses to draw the state borders. Here is an example using "cbsa2013" from maptile:

    capture maptile_install using "http://files.michaelstepner.com/geo_cbsa2013.zip"
    //First, find the file that draws the state borders. On my computer it is saved here, which is hopefully where it is saved for you too:
    use "~/ado/personal/maptile_geographies/cbsa2013_stateborders_noAKHI.dta", clear
    //Next, keep only the _ID variables corresponding to the states that you want. I don't know a good way to know which states correspond to which _ID variables, but by trial and error and found that _ID==49 is Texas (I just picked different numbers here and then looked at the maps that are made later)
    keep if _ID==49
    //Then save that new state borders file
    save "~/ado/personal/maptile_geographies/cbsa2013_TX_stateborders.dta", replace

    //Then, load the data that you want to map. If you want to map out the variable "variable1" then you would do
    maptile variable1, geo(cbsa2013) mapif(!missing(varaible1)) ///
    nostateoutline ///
    spopt(polygon(data("~/ado/personal/maptile_geographies/cbsa2013_TX_stateborders.dta") ocolor(gs7)))

    I think the option "nostateoutline" is important, because otherwise maptile will also try to say what the stateborders should be.

    Hope that helps!

    Comment

    Working...
    X