-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
393 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.