Announcement

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

  • Legend in spmap

    Dear All,

    I noticed than Stata uses the same color as the polygon contours to make the contour of the polygon symbol in the legend, when using spmap. Is there a way to change it?

    In the attached map, the state borders contours are black and so are the contours around their symbol in the legend.

    Thank you!
    Click image for larger version

Name:	usa.png
Views:	1
Size:	23.7 KB
ID:	1306289

  • #2
    Which line colors specifically are you interested in changing/not changing.

    Comment


    • #3
      Joshua, your map looks distorted because you are plotting unprojected coordinates (latitude and longitude). The spmap command (from SSC) does not do map projections but geo2xy (from SSC) can. To install it, type in Stata's command window

      Code:
      ssc install geo2xy
      Here's a quick example that replicates the shape of your map and then produces 2 more familiar representations of the contiguous U.S.

      Code:
      * Use the U.S. Census Cartographic Boundary Shapefiles - States
      * from http://www.census.gov/geo/maps-data/data/cbf/cbf_state.html
      * converted to Stata using -shp2dta- (from SSC) without
      * Alaska, Hawaii, Puerto Rico, and U.S. territories and
      * create a map with unprojected (lat/lon) coordinates
      use "states_data.dta", clear
      spmap using "states_coordinates.dta", id(_ID)
      graph export "unprojected.png", width(800) replace
      
      * Redo using Google Maps projection (Spherical Mercator)
      use "states_coordinates.dta", clear
      geo2xy _Y _X, replace
      save "states_coordinates_google.dta", replace
      use "states_data.dta", clear
      spmap using "states_coordinates_google.dta", id(_ID)
      graph export "google.png", width(800) replace
      
      * Redo using a USGS recommended projection for the contiguous US
      use "states_coordinates.dta", clear
      geo2xy _Y _X, proj(albers) replace
      save "states_coordinates_albers.dta", replace
      use "states_data.dta", clear
      spmap using "states_coordinates_albers.dta", id(_ID)
      graph export "Albers.png", width(800) replace
      The unprojected map looks like

      Click image for larger version

Name:	unprojected1.png
Views:	1
Size:	75.2 KB
ID:	1306329

      The Google Maps projection looks like

      Click image for larger version

Name:	google1.png
Views:	1
Size:	82.7 KB
ID:	1306330

      And finally the USGS recommended projection (Albers) looks like
      Click image for larger version

Name:	Albers1.png
Views:	1
Size:	109.9 KB
ID:	1306331

      Comment


      • #4
        Originally posted by wbuchanan View Post
        Which line colors specifically are you interested in changing/not changing.
        The contour of the legend symbols only (i.e. the black lines along the blue rectangular in the legend)

        Attached Files

        Comment

        Working...
        X