maptile mapping in Stata, made easy Michael Stepner MIT 7.36 23.67 - - PowerPoint PPT Presentation

maptile
SMART_READER_LITE
LIVE PREVIEW

maptile mapping in Stata, made easy Michael Stepner MIT 7.36 23.67 - - PowerPoint PPT Presentation

maptile mapping in Stata, made easy Michael Stepner MIT 7.36 23.67 4.59 7.36 3.07 4.59 1.95 3.07 0.92 1.95 0.40 0.92 . maptile population, geo(state) Ingredients for creating a map 1) Install maptile The installation


slide-1
SLIDE 1

maptile mapping in Stata, made easy

Michael Stepner MIT

slide-2
SLIDE 2
slide-3
SLIDE 3

. maptile population, geo(state)

7.36 − 23.67 4.59 − 7.36 3.07 − 4.59 1.95 − 3.07 0.92 − 1.95 0.40 − 0.92

slide-4
SLIDE 4

Ingredients for creating a map

. maptile population, geo(state)

1) Install maptile

The installation command is posted at: www.michaelstepner.com/maptile/ maptile depends on the Stata program spmap . ssc install spmap

slide-5
SLIDE 5

Ingredients for creating a map

2) Install a maptile geography template

Install templates from: www.michaelstepner.com/maptile/geographies

. maptile population, geo(state)

slide-6
SLIDE 6

Ingredients for creating a map

. maptile population, geo(state)

2) Install a maptile geography template

Install templates from: www.michaelstepner.com/maptile/geographies

slide-7
SLIDE 7

Ingredients for creating a map

3) Data with a geographic ID variable

slide-8
SLIDE 8

Ingredients for creating a map

3) Data with a geographic ID variable

Geographic ID in dataset must be compatible with template.

slide-9
SLIDE 9

Ingredients for creating a map

3) Data with a geographic ID variable

To learn template requirements and options, run: . maptile_geohelp state

slide-10
SLIDE 10

Making maps

“More an art than a science.”

slide-11
SLIDE 11

Ingredients for creating a map

slide-12
SLIDE 12

Ingredients for creating a map

. maptile_geohelp state

slide-13
SLIDE 13

Ingredients for creating a map

. rename statecode statefips . rename state statename

slide-14
SLIDE 14

Ingredients for creating a map

826 − 926 758 − 826 729 − 758 706 − 729 669 − 706 624 − 669

. maptile mort_white, geo(state) geoid(statefips)

slide-15
SLIDE 15

What’s happening under the hood

Equal-sized bins

Same number of states in each bin (up to integer rounding)

“Equal-spaced” colors

The color assigned to each bin depends only on the bin number, not on the values of the data in the bin

N.B. Color “spacing” is not well-defined except

  • n a fixed color spectrum.

Colors are ordinal, not cardinal

slide-16
SLIDE 16

669 624 706 729 758 826 926

NJ ND WA WI AK MD MA NH RI UT VT VA IL IA NE OR NM PA TX WY DE ID KS ME MT NV NC OH SC GA IN MI MO MS OK TN WV AL AR KY LA HI MN NY SD AZ CA CO CT FL

Q2 Q3 Q4 Q5 Q6 Q1

. xtile cutpoints_white=mort_white, nq(6)

slide-17
SLIDE 17

. maptile mort_white, geo(state)

0.2 0.4 0.6 0.8 1 Q2 Q3 Q4 Q5 Q6 Q1 Q2 Q3 Q4 Q5 Q6 Q1 669 624 706 729 758 826 926

NJ ND WA WI AK MD MA NH RI UT VT VA IL IA NE OR NM PA TX WY DE ID KS ME MT NV NC OH SC GA IN MI MO MS OK TN WV AL AR KY LA HI MN NY SD AZ CA CO CT FL

slide-18
SLIDE 18

Ingredients for creating a map

826 − 926 758 − 826 729 − 758 706 − 729 669 − 706 624 − 669

. maptile mort_white, geo(state)

slide-19
SLIDE 19

Proportional color spacing: captures dispersion

Equally-spaced colors are:

Informative about order Uninformative about dispersion

Can use “proportionally-spaced colors” instead:

1)

Compute the median value in each bin

2)

Place the lowest bin at the left, highest at the right

3)

Color the middle bins proportionally to the distance between them

à Bins containing similar values will have similar colors

N.B. There is nothing objective about color spacing. Proportionally-spaced colors on one color spectrum are equivalent to equally-spaced colors on a different spectrum.

slide-20
SLIDE 20

. maptile mort_white, geo(state)

Q2 Q3 Q4 Q5 Q6 Q1 669 624 706 729 758 826 926 100 45 37 23 29 68 0.2 0.4 0.6 0.8 1 Q2 Q3 Q4 Q5 Q6 Q1

slide-21
SLIDE 21

. maptile mort_white, geo(state) propcolor

Q2 Q3 Q4 Q5 Q6 Q1 Q2 Q3 Q4 Q5 Q6 Q1 657 687 714 738 799 903 657 687 714 738 799 903

slide-22
SLIDE 22

Ingredients for creating a map

826 − 926 758 − 826 729 − 758 706 − 729 669 − 706 624 − 669

. maptile mort_white, geo(state) propcolor

slide-23
SLIDE 23

Equal-spaced bins: directly represent values

Equal-sized bins split the data into quantiles. Equal-spaced bins split the data into fixed ranges.

slide-24
SLIDE 24

Ingredients for creating a map

650 624 700 750 800 900 926

NJ ND WA WI AK MD MA NH RI UT VT VA IL IA NE OR NM PA TX WY DE ID KS ME MT NV NC OH SC GA IN MI MO MS OK TN WV AL AR KY LA HI MN NY SD AZ CA CO CT FL

B7 669 624 706 729 758 826 926 Q2 Q3 Q4 Q5 Q6 Q1 B6 B5 B4 B3 B2 B1 850

OK WV AL KY MS HI MN SD MA NH NJ NY ND WA AK AZ CA CO CT FL MD OR RI UT VT VA WI WY DE ID IL IA KS MT NE NM NC PA TX GA ME MI MO OH SC IN NV TN AR LA

slide-25
SLIDE 25

Ingredients for creating a map

900 − 926 850 − 900 800 − 850 750 − 800 700 − 750 650 − 700 624 − 650

. maptile mort_white, geo(state) cutvalues(650(50)900)

slide-26
SLIDE 26

Loops

foreach race in white black { maptile mort_`race', geo(state) /// savegraph(fig/map_mort_`race'.eps) }

Same way you would do any loop in Stata

slide-27
SLIDE 27

Ingredients for creating a map

826 − 926 755 − 826 729 − 755 702 − 729 668 − 702 466 − 668

. maptile mort_white, geo(state)

White Mortality Rates

slide-28
SLIDE 28

Ingredients for creating a map

967 − 1,050 918 − 967 805 − 918 740 − 805 582 − 740 246 − 582

. maptile mort_black geo(state)

Black Mortality Rates

slide-29
SLIDE 29

Absolute comparisons between groups

When each group uses its own bins, the map shows a relative comparison between the groups

“Where are black Americans worst off, relative to other black Americans?” “Where are white Americans worst off, relative to other white Americans?”

An absolute comparison is also interesting:

“How do black Americans fare, relative to white Americans?” To see this comparison, hold the bins fixed.

slide-30
SLIDE 30

Absolute comparisons between groups

Generate a variable containing the break points using the distribution of white mortality:

pctile mort_white_breaks=mort_white, nq(6)

Map both white and black mortality using the same break points:

maptile mort_white, geo(state) cutp(mort_white_breaks) maptile mort_black, geo(state) cutp(mort_white_breaks)

slide-31
SLIDE 31

Ingredients for creating a map

826 − 926 755 − 826 729 − 755 702 − 729 668 − 702 466 − 668

. maptile mort_white, geo(state) cutp(mort_white_breaks)

White Mortality Rates

slide-32
SLIDE 32

Ingredients for creating a map

826 − 1,050 755 − 826 729 − 755 702 − 729 668 − 702 246 − 668

Black Mortality Rates

. maptile mort_black, geo(state) cutp(mort_white_breaks)

slide-33
SLIDE 33

Making maps

“More an art than a science.”

Data values are cardinal Color spectrum is ordinal

à Choice of binning procedure and color spacing

should depend on the features of the data that you want to highlight.

slide-34
SLIDE 34

How maptile works

Data + Shapefile spmap maptile Highly customizable

Template Information

Easy to use

slide-35
SLIDE 35

How maptile works

Data + Shapefile spmap maptile Highly customizable

Template Information

Easy to use

slide-36
SLIDE 36

Making a new template

There are detailed instructions in the maptile help file Requires you to:

Find a shapefile for the region you want to map Edit an ado-file that connects maptile to your shapefile

If you make a new template, consider sharing it!

Send it to me and I will post it on the maptile website with your name. With your help, people will be able to quickly make maps

  • f many different places.
slide-37
SLIDE 37

Making a new template

Useful resources:

demo_maptile.ado (linked from the help file) provides a base and a step-by-step guide to each line of code you need to edit. Download the “Creation Files” for any template posted on the maptile website to see how the shapefile was processed. To copy a feature from an existing template, download the template’s zip file and look at the code in the ado-file. (Instead of copying and pasting the maptile_install command into Stata, copy and paste the URL in your browser.)

slide-38
SLIDE 38

. maptile median_income, geo(can_prov)

slide-39
SLIDE 39

Making maps? No problem.