Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • better way to generate map of 50 states at the same time?

    So I can use -spmap- to generate a nice map of the 48 contiguous US states. Then I can use it to generate separate maps of AK and HI, then splice them together with photo-editing software. Somewhat annoying that the outline thicknesses and point-sizes get mangled in the re-sizing. I want publication-quality stuff, and the outline-thickness issue alone makes it iffy. If I deliberately thicken the lines for AK, the islands basically become blobs, so I'm stuck with thinner lines and smaller points for AK and HI.

    Is there a better way? Stata 13.1 all updates, latest spmap. I can provide my syntax and/or images if it would help, but think just describing my problem is enough?

  • #2
    Ben,

    Off the top of my head...how about modifying the shape file (the data set that has the coordinates of each line segment that forms the state borders) so that the coordinates of Alaska and Hawaii are closer to the continental US? It might take some experimentation, but should only involve subtracting a constant from the latitude and longitudes for both states (four constants in all).

    Regards,
    Joe

    Comment


    • #3
      I guess that my favorite geographer will confirm that the distance between longitudes is different at different latitudes, and that just subtracting constants may lead to some distortion. Dependent on purpose that may be or not be a problem.

      Comment


      • #4
        Good point, Svend. Although as we all know, there is no perfect way to represent areas at extreme latitudes without introducing distortion. The issue here, as you imply, is whether the distortion will render Alaska unrecognizable, or at least subject to ridicule (for reasons that have nothing to do with Sarah Palin).

        Comment


        • #5
          As far as I know, spmap does not do projection and controls proportions by choosing an appropriate aspect ratio for the map. Joe's idea of using an offset for coordinates is quite doable. Here's an example that shows Alaska over the lower 48 states.

          Code:
          * Shapefile from http://www2.census.gov/geo/tiger/GENZ2013/cb_2013_us_state_500k.zip
              
              shp2dta using "cb_2013_us_state_500k/cb_2013_us_state_500k.shp", ///
                  data("db.dta") coor("coor.dta") replace
          
              use "coor.dta", clear
              
              rename _X lon
              rename _Y lat
              
              
          * Ignore American Samoa, Marianas, Guam, Hawaii, Virgins Islands
          
              drop if inlist(_ID, 55,54,40,28,29)
              
          
          * Alaska crosses the international date line
          
              replace lon = 60 + cond(lon<0, lon,-180-(180-lon)) if _ID == 37
              
              
          * Proof of concept
              
              twoway line lat lon if _ID == 37, ///
                  cmissing(n) xscale(range(-160 -50)) lwidth(vvthin) || ///
                  line lat lon if _ID != 37, ///
                  xscale(range(-130 -50)) cmissing(n) lwidth(vvthin) aspectratio(1) xaxis(2)

          Comment


          • #6
            Great, thanks! Since I have point information, I'll need to teak those as well, but doable. I wonder if bringing Alaska farther south will make it's elongation go away (it's about twice as wide as it should be). Will check it out this evening, no chance to get to it right at the moment.

            Comment


            • #7
              You can overlay multiple maps at different scales by using multiple axes and playing with the scale of each axis. In that sense, there even no reason to offset coordinates, you can simply adjust the axis scale to position the map where you want it. As I mentioned above, when plotting unprojected geographic coordinates in decimal degrees, the best you can do is to use the aspect ratio to get a visually appealing result. Here's a reworked example that includes Hawaii and Alaska to the south west of the lower 48.

              The aspectratio(.56) is appropriate for the lower 48. For Hawaii and Alaska, it's just a matter to playing with the axis range to get scale and aspect ratio that looks right.

              Code:
              * Shapefile from http://www2.census.gov/geo/tiger/GENZ2013/cb_2013_us_state_500k.zip
                  
                  shp2dta using "cb_2013_us_state_500k/cb_2013_us_state_500k.shp", ///
                      data("db.dta") coor("coor.dta") replace
              
                  use "coor.dta", clear
                  
                  rename _X lon
                  rename _Y lat
                  
                  
              * Ignore American Samoa, Marianas, Puerto Rico, Guam, Virgins Islands
              
                  drop if inlist(_ID, 55,54,32,28,29)
                  
                  
              * Offset Alaska coordinates because they cross the international date line
              
                  replace lon = cond(lon<0, lon,-180-(180-lon)) if _ID == 37
                  
                  
              * Drop some small western islands in Hawaii
                  
                  gen obs = _n
                  bysort _ID (obs): gen subid = sum(mi(lat))
                  tab subid if _ID == 40
                  drop if subid > 9 & _ID == 40
              
                  
              * Get min and max coordinates
              
                  sum if !inlist(_ID,37,40)    // lower 48
                  sum if _ID == 37            // Alaska
                  sum if _ID == 40            // Hawaii
                  
                  
              * Overlay the lower 48, Alaska, and Hawaii
              
                      line lat lon if !inlist(_ID,37,40), cmissing(n) lwidth(vvthin) ///
                          ylabel(minmax) yscale(off) ///
                          xlabel(minmax) xscale(off) ///
                      || ///
                      line lat lon if _ID == 37, cmissing(n) lwidth(vvthin) ///
                          yaxis(2) xaxis(2) ///
                          yscale(range(50 140) axis(2) off) ///
                          xscale(range(-230 100) axis(2) off) ///
                      || ///
                      line lat lon if _ID == 40, cmissing(n) lwidth(vvthin) ///
                          yaxis(3) xaxis(3) ///
                          yscale(range(16 40) axis(3) off) ///
                          xscale(range(-150 -120) axis(3) off) ///
                      aspectratio(.56)  legend(off)

              Comment


              • #8
                D'oh! I finally got my hands on the real data. Turns out the place is a small teaching college, basically where teachers go to keep up on professional development, or teachers go to become principals. So there is remarkably little mobility, and nobody *in* AK and HI. I even needed to add jitter to the points to get cities and such to stand out better.

                I really appreciate all the effort, and am sorry if it was wasted effort. It won't be a total waste, though, since I'll play with your code and learn, so I can get it right next project. Thanks for showing me cool things! I'll need to figure out how to do choropleths and/or points with it... but not today.

                Comment


                • #9
                  This is easier to do now that map projections are available via geo2xy from SSC.

                  Comment

                  Working...
                  X