Skip to content

Commit

Permalink
Merge branch 'release/v0.70beta3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Stepner committed Jul 26, 2014
2 parents 200ccbe + 2f52ef7 commit 9219db3
Show file tree
Hide file tree
Showing 13 changed files with 393 additions and 87 deletions.
42 changes: 27 additions & 15 deletions map_shapefiles/county1990_maptile.ado
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
*! 6feb2014, Michael Stepner, michaelstepner@gmail.com
*! 26jul2014, Michael Stepner, stepner@mit.edu

program define _maptile_county1990
syntax , [ geofolder(string) ///
mergedatabase ///
map var(varname) legopt(string) min(string) clbreaks(string) max(string) mapcolors(string) ndfcolor(string) ///
savegraph(string) replace resolution(string) map_restriction(string) spopt(string) ///
stateoutline(string) ///
/* Geography-specific options */ ///
stateoutline(string) ///
]

if ("`mergedatabase'"!="") {
Expand All @@ -19,7 +20,8 @@ program define _maptile_county1990
cap confirm file `"`geofolder'/state_coords_clean.dta"'
if (_rc==0) local polygon polygon(data(`"`geofolder'/state_coords_clean"') ocolor(black) osize(`stateoutline' ...))
else if (_rc==601) {
di as error `"stateoutline option requires 'state_coords_clean.dta' in the geofolder"'
di as error `"stateoutline() requires the {it:state} geography to be installed"'
di as error `"--> state_coords_clean.dta must be present in the geofolder"'
exit 198
}
else {
Expand All @@ -29,7 +31,8 @@ program define _maptile_county1990
}

spmap `var' using `"`geofolder'/county1990_coords_clean"' `map_restriction', id(id) ///
`legopt' legend(pos(5) size(*1.8)) ///
`legopt' ///
legend(pos(5) size(*1.8)) ///
clmethod(custom) ///
clbreaks(`min' `clbreaks' `max') ///
fcolor(`mapcolors') ndfcolor(`ndfcolor') ///
Expand All @@ -39,18 +42,27 @@ program define _maptile_county1990
`spopt'

* Save graph
if `"`savegraph'"'!="" {
* check file extension using a regular expression
if regexm(`"`savegraph'"',"\.[a-zA-Z0-9]+$") local graphextension=regexs(0)

* deal with different filetypes appropriately
if inlist(`"`graphextension'"',".gph","") graph save `"`savegraph'"', `replace'
else if inlist(`"`graphextension'"',".ps",".eps") graph export `"`savegraph'"', mag(`=round(100*`resolution')') `replace'
else if (`"`graphextension'"'==".png") graph export `"`savegraph'"', width(`=round(3200*`resolution')') `replace'
else if (`"`graphextension'"'==".tif") graph export `"`savegraph'"', width(`=round(1600*`resolution')') `replace'
else graph export `"`savegraph'"', `replace'
}
if (`"`savegraph'"'!="") __savegraph_maptile, savegraph(`savegraph') resolution(`resolution') `replace'

}

end

* Save map to file
cap program drop __savegraph_maptile
program define __savegraph_maptile

syntax, savegraph(string) resolution(string) [replace]

* check file extension using a regular expression
if regexm(`"`savegraph'"',"\.[a-zA-Z0-9]+$") local graphextension=regexs(0)

* deal with different filetypes appropriately
if inlist(`"`graphextension'"',".gph","") graph save `"`savegraph'"', `replace'
else if inlist(`"`graphextension'"',".ps",".eps") graph export `"`savegraph'"', mag(`=round(100*`resolution')') `replace'
else if (`"`graphextension'"'==".png") graph export `"`savegraph'"', width(`=round(3200*`resolution')') `replace'
else if (`"`graphextension'"'==".tif") graph export `"`savegraph'"', width(`=round(1600*`resolution')') `replace'
else graph export `"`savegraph'"', `replace'

end

42 changes: 27 additions & 15 deletions map_shapefiles/cz_maptile.ado
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
*! 6feb2014, Michael Stepner, michaelstepner@gmail.com
*! 26jul2014, Michael Stepner, stepner@mit.edu

program define _maptile_cz
syntax , [ geofolder(string) ///
mergedatabase ///
map var(varname) legopt(string) min(string) clbreaks(string) max(string) mapcolors(string) ndfcolor(string) ///
savegraph(string) replace resolution(string) map_restriction(string) spopt(string) ///
stateoutline(string) ///
/* Geography-specific options */ ///
stateoutline(string) ///
]

if ("`mergedatabase'"!="") {
Expand All @@ -19,7 +20,8 @@ program define _maptile_cz
cap confirm file `"`geofolder'/state_coords_clean.dta"'
if (_rc==0) local polygon polygon(data(`"`geofolder'/state_coords_clean"') ocolor(black) osize(`stateoutline' ...))
else if (_rc==601) {
di as error `"stateoutline option requires 'state_coords_clean.dta' in the geofolder"'
di as error `"stateoutline() requires the {it:state} geography to be installed"'
di as error `"--> state_coords_clean.dta must be present in the geofolder"'
exit 198
}
else {
Expand All @@ -29,7 +31,8 @@ program define _maptile_cz
}

spmap `var' using `"`geofolder'/cz_coords_clean"' `map_restriction', id(id) ///
`legopt' legend(pos(5) size(*1.8)) ///
`legopt' ///
legend(pos(5) size(*1.8)) ///
clmethod(custom) ///
clbreaks(`min' `clbreaks' `max') ///
fcolor(`mapcolors') ndfcolor(`ndfcolor') ///
Expand All @@ -39,18 +42,27 @@ program define _maptile_cz
`spopt'

* Save graph
if `"`savegraph'"'!="" {
* check file extension using a regular expression
if regexm(`"`savegraph'"',"\.[a-zA-Z0-9]+$") local graphextension=regexs(0)

* deal with different filetypes appropriately
if inlist(`"`graphextension'"',".gph","") graph save `"`savegraph'"', `replace'
else if inlist(`"`graphextension'"',".ps",".eps") graph export `"`savegraph'"', mag(`=round(100*`resolution')') `replace'
else if (`"`graphextension'"'==".png") graph export `"`savegraph'"', width(`=round(3200*`resolution')') `replace'
else if (`"`graphextension'"'==".tif") graph export `"`savegraph'"', width(`=round(1600*`resolution')') `replace'
else graph export `"`savegraph'"', `replace'
}
if (`"`savegraph'"'!="") __savegraph_maptile, savegraph(`savegraph') resolution(`resolution') `replace'

}

end

* Save map to file
cap program drop __savegraph_maptile
program define __savegraph_maptile

syntax, savegraph(string) resolution(string) [replace]

* check file extension using a regular expression
if regexm(`"`savegraph'"',"\.[a-zA-Z0-9]+$") local graphextension=regexs(0)

* deal with different filetypes appropriately
if inlist(`"`graphextension'"',".gph","") graph save `"`savegraph'"', `replace'
else if inlist(`"`graphextension'"',".ps",".eps") graph export `"`savegraph'"', mag(`=round(100*`resolution')') `replace'
else if (`"`graphextension'"'==".png") graph export `"`savegraph'"', width(`=round(3200*`resolution')') `replace'
else if (`"`graphextension'"'==".tif") graph export `"`savegraph'"', width(`=round(1600*`resolution')') `replace'
else graph export `"`savegraph'"', `replace'

end

59 changes: 59 additions & 0 deletions map_shapefiles/demo_maptile.ado
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
*! 26jul2014, Michael Stepner, stepner@mit.edu

/*XX update the date above. change the author and e-mail address to be your own. */
/*XX choose a name for your new geography and change the name of this ado-file to be: geoname_maptile.ado */

program define _maptile_demo /*XX change "demo" to your chosen geoname */
syntax , [ geofolder(string) ///
mergedatabase ///
map var(varname) legopt(string) min(string) clbreaks(string) max(string) mapcolors(string) ndfcolor(string) ///
savegraph(string) replace resolution(string) map_restriction(string) spopt(string) ///
/* Geography-specific options */ ///
/*XX you can add new options specific to your geography here (or delete XXexampleoption).
when a user includes options in their maptile command that aren't mentioned
in the maptile help file, they are passed to this program. */ ///
XXexampleoption(string) ///
]

if ("`mergedatabase'"!="") {
merge 1:m geoid /*XX change geoid to the geographic ID variable, ex: province*/ using `"`geofolder'/geoname_database.dta"', nogen /*XX change "geoname_database.dta" to the name of your shapefile database file*/
exit
}

if ("`map'"!="") {

spmap `var' using `"`geofolder'/geoname_coords.dta"' `map_restriction', id(id) /// /*XX change "geoname_coords.dta" to the name of your shapefile coordinates file*/
`legopt' ///
legend(pos(5) size(*1.8)) /// /*XX change the default placement and size of the legend as appropriate for your map*/
clmethod(custom) ///
clbreaks(`min' `clbreaks' `max') ///
fcolor(`mapcolors') ndfcolor(`ndfcolor') ///
oc(black ...) ndo(black) ///
os(vthin ...) nds(vthin) ///
`spopt'

* Save graph
if (`"`savegraph'"'!="") __savegraph_maptile, savegraph(`savegraph') resolution(`resolution') `replace'

}

end

* Save map to file
cap program drop __savegraph_maptile
program define __savegraph_maptile

syntax, savegraph(string) resolution(string) [replace]

* check file extension using a regular expression
if regexm(`"`savegraph'"',"\.[a-zA-Z0-9]+$") local graphextension=regexs(0)

* deal with different filetypes appropriately
if inlist(`"`graphextension'"',".gph","") graph save `"`savegraph'"', `replace'
else if inlist(`"`graphextension'"',".ps",".eps") graph export `"`savegraph'"', mag(`=round(100*`resolution')') `replace'
else if (`"`graphextension'"'==".png") graph export `"`savegraph'"', width(`=round(3200*`resolution')') `replace'
else if (`"`graphextension'"'==".tif") graph export `"`savegraph'"', width(`=round(1600*`resolution')') `replace'
else graph export `"`savegraph'"', `replace'

end

34 changes: 34 additions & 0 deletions map_shapefiles/demo_maptile.smcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{smcl}

{pstd}
{hi:maptile {hline 2} Geography: county1990}


{marker description}{...}
{title:Description}

{pstd}
{hi:county1990} generates a map of United States counties using 1990 boundaries.

{pstd}It displays Alaska and Hawaii rescaled and moved to the bottom left of the map, below the continental US, for ease of viewing.


{marker idvar}{...}
{title:Geographic ID variable}

{pstd}
{hi:county} {hline 2} FIPS county codes


{marker geooptions}{...}
{title:Geography-Specific Options}

{synoptset 32 tabbed}{...}
{synopt :{opth stateoutline(linewidthstyle)}}overlays the map with a (potentially thicker) line on state boundaries{p_end}


{marker author}{...}
{title:Author}

{pstd}Michael Stepner{p_end}
{pstd}stepner@mit.edu{p_end}
37 changes: 24 additions & 13 deletions map_shapefiles/state_maptile.ado
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
*! 6feb2014, Michael Stepner, michaelstepner@gmail.com
*! 26jul2014, Michael Stepner, stepner@mit.edu

program define _maptile_state
syntax , [ geofolder(string) ///
mergedatabase ///
map var(varname) legopt(string) min(string) clbreaks(string) max(string) mapcolors(string) ndfcolor(string) ///
savegraph(string) replace resolution(string) map_restriction(string) spopt(string) ///
/* Geography-specific options */ ///
geoid(varname) ///
]

Expand All @@ -22,7 +23,8 @@ program define _maptile_state
if ("`map'"!="") {

spmap `var' using `"`geofolder'/state_coords_clean"' `map_restriction', id(id) ///
`legopt' legend(pos(5) size(*1.8)) ///
`legopt' ///
legend(pos(5) size(*1.8)) ///
clmethod(custom) ///
clbreaks(`min' `clbreaks' `max') ///
fcolor(`mapcolors') ndfcolor(`ndfcolor') ///
Expand All @@ -31,18 +33,27 @@ program define _maptile_state
`spopt'

* Save graph
if `"`savegraph'"'!="" {
* check file extension using a regular expression
if regexm(`"`savegraph'"',"\.[a-zA-Z0-9]+$") local graphextension=regexs(0)

* deal with different filetypes appropriately
if inlist(`"`graphextension'"',".gph","") graph save `"`savegraph'"', `replace'
else if inlist(`"`graphextension'"',".ps",".eps") graph export `"`savegraph'"', mag(`=round(100*`resolution')') `replace'
else if (`"`graphextension'"'==".png") graph export `"`savegraph'"', width(`=round(3200*`resolution')') `replace'
else if (`"`graphextension'"'==".tif") graph export `"`savegraph'"', width(`=round(1600*`resolution')') `replace'
else graph export `"`savegraph'"', `replace'
}
if (`"`savegraph'"'!="") __savegraph_maptile, savegraph(`savegraph') resolution(`resolution') `replace'

}

end

* Save map to file
cap program drop __savegraph_maptile
program define __savegraph_maptile

syntax, savegraph(string) resolution(string) [replace]

* check file extension using a regular expression
if regexm(`"`savegraph'"',"\.[a-zA-Z0-9]+$") local graphextension=regexs(0)

* deal with different filetypes appropriately
if inlist(`"`graphextension'"',".gph","") graph save `"`savegraph'"', `replace'
else if inlist(`"`graphextension'"',".ps",".eps") graph export `"`savegraph'"', mag(`=round(100*`resolution')') `replace'
else if (`"`graphextension'"'==".png") graph export `"`savegraph'"', width(`=round(3200*`resolution')') `replace'
else if (`"`graphextension'"'==".tif") graph export `"`savegraph'"', width(`=round(1600*`resolution')') `replace'
else graph export `"`savegraph'"', `replace'

end

42 changes: 27 additions & 15 deletions map_shapefiles/zip3_maptile.ado
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
*! 6feb2014, Michael Stepner, michaelstepner@gmail.com
*! 26jul2014, Michael Stepner, stepner@mit.edu

program define _maptile_zip3
syntax , [ geofolder(string) ///
mergedatabase ///
map var(varname) legopt(string) min(string) clbreaks(string) max(string) mapcolors(string) ndfcolor(string) ///
savegraph(string) replace resolution(string) map_restriction(string) spopt(string) ///
stateoutline(string) ///
/* Geography-specific options */ ///
stateoutline(string) ///
]

if ("`mergedatabase'"!="") {
Expand All @@ -19,7 +20,8 @@ program define _maptile_zip3
cap confirm file `"`geofolder'/state_coords_clean.dta"'
if (_rc==0) local polygon polygon(data(`"`geofolder'/state_coords_clean"') ocolor(black) osize(`stateoutline' ...))
else if (_rc==601) {
di as error `"stateoutline option requires 'state_coords_clean.dta' in the geofolder"'
di as error `"stateoutline() requires the {it:state} geography to be installed"'
di as error `"--> state_coords_clean.dta must be present in the geofolder"'
exit 198
}
else {
Expand All @@ -29,7 +31,8 @@ program define _maptile_zip3
}

spmap `var' using `"`geofolder'/zip3_coords_clean"' `map_restriction', id(id) ///
`legopt' legend(pos(5) size(*1.8)) ///
`legopt' ///
legend(pos(5) size(*1.8)) ///
clmethod(custom) ///
clbreaks(`min' `clbreaks' `max') ///
fcolor(`mapcolors') ndfcolor(`ndfcolor') ///
Expand All @@ -39,18 +42,27 @@ program define _maptile_zip3
`spopt'

* Save graph
if `"`savegraph'"'!="" {
* check file extension using a regular expression
if regexm(`"`savegraph'"',"\.[a-zA-Z0-9]+$") local graphextension=regexs(0)

* deal with different filetypes appropriately
if inlist(`"`graphextension'"',".gph","") graph save `"`savegraph'"', `replace'
else if inlist(`"`graphextension'"',".ps",".eps") graph export `"`savegraph'"', mag(`=round(100*`resolution')') `replace'
else if (`"`graphextension'"'==".png") graph export `"`savegraph'"', width(`=round(3200*`resolution')') `replace'
else if (`"`graphextension'"'==".tif") graph export `"`savegraph'"', width(`=round(1600*`resolution')') `replace'
else graph export `"`savegraph'"', `replace'
}
if (`"`savegraph'"'!="") __savegraph_maptile, savegraph(`savegraph') resolution(`resolution') `replace'

}

end

* Save map to file
cap program drop __savegraph_maptile
program define __savegraph_maptile

syntax, savegraph(string) resolution(string) [replace]

* check file extension using a regular expression
if regexm(`"`savegraph'"',"\.[a-zA-Z0-9]+$") local graphextension=regexs(0)

* deal with different filetypes appropriately
if inlist(`"`graphextension'"',".gph","") graph save `"`savegraph'"', `replace'
else if inlist(`"`graphextension'"',".ps",".eps") graph export `"`savegraph'"', mag(`=round(100*`resolution')') `replace'
else if (`"`graphextension'"'==".png") graph export `"`savegraph'"', width(`=round(3200*`resolution')') `replace'
else if (`"`graphextension'"'==".tif") graph export `"`savegraph'"', width(`=round(1600*`resolution')') `replace'
else graph export `"`savegraph'"', `replace'

end

0 comments on commit 9219db3

Please sign in to comment.