To all STATA users,
I am new to making maps so I need some help to make this happen ( I run successfully the spmap example).
What I need to do is to plot the USA map highlighting selected cities (30) and its average freight rate.
Thus, I got the following .shp and .dbf files:USA_Major_Cities.shp and USA_Major_Cities .dbf available at https://hub.arcgis.com/datasets/esri....479736%2C4.65.
This is my code:
The resulting map doesn't look like the USA.
Any help, I appreciate it!!!
Tank you all!!
I am new to making maps so I need some help to make this happen ( I run successfully the spmap example).
What I need to do is to plot the USA map highlighting selected cities (30) and its average freight rate.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte kma str31 NAME str2 ST double(price_V price_R distance_V distance_R distance_F) 1 "Phoenix" "AZ" 1.9528870292887024 2.39418410041841 1210.1204184100422 1250.167615062762 599.8294560669452 2 "Los Angeles" "CA" 2.3603765690376566 3.0724686192468615 1804.7005857740605 1615.934225941423 1006.4151464435139 3 "Ontario" "CA" 2.4219665271966524 3.3889121338912136 1670.3484518828452 1396.542552301254 736.5871548117153 4 "Denver" "CO" 1.3128870292887032 1.6721757322175719 965.5429288702936 1021.2196234309621 701.215941422594 5 "Lakeland" "FL" 1.18205020920502 1.668117154811716 1013.9206276150626 1072.9160251046028 615.5800418410045 6 "Atlanta" "GA" 2.058577405857741 2.5402092050209215 852.7332635983265 707.1748953974896 553.9581171548117 7 "Chicago" "IL" 2.7413389121338922 3.6408786610878647 795.4190376569044 747.5263179916317 537.6868619246859 8 "Joliet" "IL" 2.762803347280334 3.7043514644351467 751.3896234309631 694.1074476987447 473.4064016736401 9 "Indianapolis" "IN" 2.538912133891214 2.999623430962343 700.8556903765692 744.4402510460252 382.61050209205035 10 "Lexington" "KY" 2.547405857740586 2.820334728033472 701.8749790794977 681.9120083682006 453.34652719665263 11 "Grand Rapids" "MI" 2.4091631799163165 3.0076987447698755 774.3450627615061 698.7157740585774 341.13941422594127 12 "Cape Girardeau" "MO" 2.8252301255230137 3.3221757322175733 532.7318410041842 556.3044572927562 352.07538928171584 13 "Kansas City" "MO" 2.163807531380752 2.778912133891212 795.053472803347 843.9476150627613 486.8151882845189 14 "St. Louis" "MO" 2.6475732217573213 2.9923849372384925 681.4937656903766 503.4105439330545 417.10790794979084 15 "Charlotte" "NC" 2.16255230125523 2.6012552301255236 883.9582008368197 746.6806276150629 497.91046025104606 16 "Elizabeth" "NJ" 2.0728033472803347 2.9602092050209214 1015.2129707112975 871.6861924686197 455.9187866108784 17 "Cleveland" "OH" 2.313221757322176 3.2135983263598336 787.5803765690381 565.1951046025106 533.4076569037654 18 "Columbus" "OH" 2.4802510460251046 3.1242259414225946 763.4554811715482 668.732510460251 430.4138075313811 19 "Toledo" "OH" 2.4676569037656906 2.861841004184101 705.3012552301252 649.0774476987448 340.24004184100414 20 "Medford" "OR" 2.0425941422594147 2.4111297071129703 674.8842259414222 556.0107478619822 623.5564435146445 21 "Allentown" "PA" 2.0987029288702925 3.2071129707112966 885.9850627615062 715.5852719665269 427.0093723849373 22 "Harrisburg" "PA" 2.1538912133891213 3.4218410041840994 814.9279079497913 582.6354811715481 570.3993305439327 23 "Greenville" "SC" 2.185020920502092 2.759246861924686 759.1958158995822 598.3794560669457 432.55619246861926 24 "Memphis" "TN" 2.412259414225942 2.836569037656904 779.9539330543935 726.0156485355651 514.1379916317992 25 "Dallas" "TX" 1.868870292887029 2.6724267782426776 978.5201255230122 894.3630543933045 735.4059414225945 26 "Fort Worth" "TX" 1.8744351464435145 2.6941422594142255 961.8895815899579 898.2823012552305 731.4466527196652 27 "Houston" "TX" 1.8789539748953983 2.2630543933054406 1059.3253974895397 702.3247698744768 939.6071966527189 28 "Salt Lake City" "UT" 1.7731799163179922 2.2032635983263593 1015.289288702928 856.6120083682008 692.6344351464431 29 "Green Bay" "WI" 2.529707112970713 3.1435983263598315 804.4558577405857 784.2226778242679 428.3644769874473 30 "Milwaukee" "WI" 2.684979079497907 3.2616736401673627 757.0217573221755 858.8495815899583 398.4223849372387 end
This is my code:
Code:
** Build maps cls clear all * Assign a working directory cd "C:\Users\Max\Desktop\Max\Artigos\Elasticity_Freight\stata" *There are three files associated with a map: a .shp shape file, a .dbf dBASE file, and an .shx index file. * * Translate necessary files into a format usable by Stata with the shp2dta command. * Doing so creates two .dta datasets: counties and cntycoord. clear shp2dta using USA_Major_Cities.shp, /// database(Cities) coordinates(citycoord) genid(id) replace use Cities, clear describe sort ST NAME * Merge average price dta file with Cities.dta file. use "C:\Users\Max\Desktop\Max\Artigos\Elasticity_Freight\stata\map_stats_mean.dta", clear merge 1:m NAME ST using "Cities.dta" * keep only matched database drop if _merge!=3 drop _merge spmap price_V using citycoord, id(id) fcolor(Blues)
Any help, I appreciate it!!!
Tank you all!!