-
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
19 changed files
with
1,356 additions
and
412 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
map_shapefiles/ | ||
map_shapefiles_creation_code/ | ||
raw_data/ | ||
map_shapefiles/*.dta | ||
raw_data/ | ||
tests/ |
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,4 @@ | ||
maptile: simple mapping in Stata | ||
-------------------------------- | ||
|
||
[See the project webpage for more information.](http://michaelstepner.com/maptile "maptile: a Stata program that makes mapping easy") |
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,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org/> |
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,56 @@ | ||
*! 31jan2014, Michael Stepner, michaelstepner@gmail.com | ||
|
||
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 /// | ||
] | ||
|
||
if ("`mergedatabase'"!="") { | ||
merge 1:m county using `"`geofolder'/county1990_database_clean"', nogen update replace | ||
exit | ||
} | ||
|
||
if ("`map'"!="") { | ||
|
||
if ("`stateoutline'"!="") { | ||
cap confirm file `"`geofolder'/state_coords_clean.dta"' | ||
if (_rc==0) local polygon polygon(data(`"`geofolder'/state_coords_clean"') ocolor(black) osize(thin ...)) | ||
else if (_rc==601) { | ||
di as error `"stateoutline option requires 'state_coords_clean.dta' in the geofolder"' | ||
exit 198 | ||
} | ||
else { | ||
error _rc | ||
exit _rc | ||
} | ||
} | ||
|
||
spmap `var' using `"`geofolder'/county1990_coords_clean"' `map_restriction', id(id) /// | ||
`legopt' legend(pos(5) size(*1.8)) /// | ||
clmethod(custom) /// | ||
clbreaks(`min' `clbreaks' `max') /// | ||
fcolor(`mapcolors') ndfcolor(`ndfcolor') /// | ||
oc(black ...) ndo(black) /// | ||
os(vvthin ...) nds(vvthin) /// | ||
`polygon' /// | ||
`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' | ||
} | ||
|
||
} | ||
|
||
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,56 @@ | ||
*! 31jan2014, Michael Stepner, michaelstepner@gmail.com | ||
|
||
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 /// | ||
] | ||
|
||
if ("`mergedatabase'"!="") { | ||
merge 1:m cz using `"`geofolder'/cz_database_clean"', nogen | ||
exit | ||
} | ||
|
||
if ("`map'"!="") { | ||
|
||
if ("`stateoutline'"!="") { | ||
cap confirm file `"`geofolder'/state_coords_clean.dta"' | ||
if (_rc==0) local polygon polygon(data(`"`geofolder'/state_coords_clean"') ocolor(black) osize(thin ...)) | ||
else if (_rc==601) { | ||
di as error `"stateoutline option requires 'state_coords_clean.dta' in the geofolder"' | ||
exit 198 | ||
} | ||
else { | ||
error _rc | ||
exit _rc | ||
} | ||
} | ||
|
||
spmap `var' using `"`geofolder'/cz_coords_clean"' `map_restriction', id(id) /// | ||
`legopt' legend(pos(5) size(*1.8)) /// | ||
clmethod(custom) /// | ||
clbreaks(`min' `clbreaks' `max') /// | ||
fcolor(`mapcolors') ndfcolor(`ndfcolor') /// | ||
oc(black ...) ndo(black) /// | ||
os(vvthin ...) nds(vvthin) /// | ||
`polygon' /// | ||
`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' | ||
} | ||
|
||
} | ||
|
||
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,48 @@ | ||
*! 31jan2014, Michael Stepner, michaelstepner@gmail.com | ||
|
||
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) /// | ||
geoid(varname) /// | ||
] | ||
|
||
if ("`mergedatabase'"!="") { | ||
if ("`geoid'"=="state" | "`geoid'"=="") merge 1:1 state using `"`geofolder'/state_database_clean"', nogen keepusing(state id) | ||
else if ("`geoid'"=="statefips") merge 1:1 statefips using `"`geofolder'/state_database_clean"', nogen update replace | ||
else if ("`geoid'"=="statename") merge 1:1 statename using `"`geofolder'/state_database_clean"', nogen update replace | ||
else { | ||
di as error "with geography(state), geoid() must be 'state', 'statefips', 'statename', or blank" | ||
exit 198 | ||
} | ||
exit | ||
} | ||
|
||
if ("`map'"!="") { | ||
|
||
spmap `var' using `"`geofolder'/state_coords_clean"' `map_restriction', id(id) /// | ||
`legopt' legend(pos(5) size(*1.8)) /// | ||
clmethod(custom) /// | ||
clbreaks(`min' `clbreaks' `max') /// | ||
fcolor(`mapcolors') ndfcolor(`ndfcolor') /// | ||
oc(black ...) ndo(black) /// | ||
os(vthin ...) nds(vthin) /// | ||
`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' | ||
} | ||
|
||
} | ||
|
||
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,56 @@ | ||
*! 31jan2014, Michael Stepner, michaelstepner@gmail.com | ||
|
||
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 /// | ||
] | ||
|
||
if ("`mergedatabase'"!="") { | ||
merge 1:m zip3 using `"`geofolder'/zip3_database_clean"', nogen | ||
exit | ||
} | ||
|
||
if ("`map'"!="") { | ||
|
||
if ("`stateoutline'"!="") { | ||
cap confirm file `"`geofolder'/state_coords_clean.dta"' | ||
if (_rc==0) local polygon polygon(data(`"`geofolder'/state_coords_clean"') ocolor(black) osize(thin ...)) | ||
else if (_rc==601) { | ||
di as error `"stateoutline option requires 'state_coords_clean.dta' in the geofolder"' | ||
exit 198 | ||
} | ||
else { | ||
error _rc | ||
exit _rc | ||
} | ||
} | ||
|
||
spmap `var' using `"`geofolder'/zip3_coords_clean"' `map_restriction', id(id) /// | ||
`legopt' legend(pos(5) size(*1.8)) /// | ||
clmethod(custom) /// | ||
clbreaks(`min' `clbreaks' `max') /// | ||
fcolor(`mapcolors') ndfcolor(`ndfcolor') /// | ||
oc(black ...) ndo(black) /// | ||
os(vvthin ...) nds(vvthin) /// | ||
`polygon' /// | ||
`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' | ||
} | ||
|
||
} | ||
|
||
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,56 @@ | ||
*! 31jan2014, Michael Stepner, michaelstepner@gmail.com | ||
|
||
program define _maptile_zip5 | ||
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 /// | ||
] | ||
|
||
if ("`mergedatabase'"!="") { | ||
merge 1:m zip5 using `"`geofolder'/zip5_database_clean"', nogen update replace | ||
exit | ||
} | ||
|
||
if ("`map'"!="") { | ||
|
||
if ("`stateoutline'"!="") { | ||
cap confirm file `"`geofolder'/state_coords_clean.dta"' | ||
if (_rc==0) local polygon polygon(data(`"`geofolder'/state_coords_clean"') ocolor(black) osize(thin ...)) | ||
else if (_rc==601) { | ||
di as error `"stateoutline option requires 'state_coords_clean.dta' in the geofolder"' | ||
exit 198 | ||
} | ||
else { | ||
error _rc | ||
exit _rc | ||
} | ||
} | ||
|
||
spmap `var' using `"`geofolder'/zip5_coords_clean"' `map_restriction', id(id) /// | ||
`legopt' legend(pos(5) size(*1.8)) /// | ||
clmethod(custom) /// | ||
clbreaks(`min' `clbreaks' `max') /// | ||
fcolor(`mapcolors') ndfcolor(`ndfcolor') /// | ||
oc(black ...) ndo(black) /// | ||
os(vvthin ...) nds(vvthin) /// | ||
`polygon' /// | ||
`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' | ||
} | ||
|
||
} | ||
|
||
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
Oops, something went wrong.