Announcement

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

  • #16
    Friedrich,

    As I tried to explain in my previous post, many projections have a "point of view" (my term, probably not what cartographers would use). I was able to generate the rather pleasant representation of Canada in #13 using the default parameters for the albers projection. As explained in geo2xy's help file, if you use the defaults, three of the 6 parameters (lat1 lat2 lon0) are dynamically generated and therefore depend on the contents of the shapefile:

    Code:
     Parameters       Description
        --------------------------------------------------------------------------------------
          a              semi-major axis of reference ellipsoid (default is 6378137)
          f              inverse flattening of reference ellipsoid (default is 298.257223563)
          lat1           1st standard parallel (default is minlat + (maxlat - minlat) / 6)
          lat2           2nd standard parallel (default is maxlat - (maxlat - minlat) / 6)
          lat0           projection's origin (default is 0)
          lon0           central meridian (default is mid-longitude)
        --------------------------------------------------------------------------------------
    You can use return list after a call to geo2xy to view the values of the parameters. Here are the ones for the albers Canada map in #13

    Code:
    . * convert coordinates using -geo2xy-
    . geo2xy _Y _X if _ID == 40, projection(albers) replace
    
    . return list
    
    macros:
                 r(aspect) : ".8554784976405909"
                  r(model) : "Ellipsoid (6378137,298.257223563)"
                  r(pname) : "Albers Equal-Area Conic Projection"
                   r(lon0) : "-96.82789557573588"
                   r(lat2) : "76.20924178062862"
                   r(lat1) : "48.58174639206324"
                   r(lat0) : "0"
                      r(f) : "298.257223563"
                      r(a) : "6378137"
    I think that geo2xy's defaults for the albers projection will work well for most maps (including the Canada map in #13). With a map of the whole world however, if lat1 and lat2 are automatically computed by geo2xy as described above, you will get one in the northern hemisphere and the other in the southern hemisphere (which explains the odd look of the map you showed).

    The Wikipedia image you show has the following caption

    Albers projection of the world with standard parallels 20°N and 50°N.


    In order to specify some projection parameters, you have to specify all of them. Here's code that duplicates the Wikipedia map of the world

    Code:
    use "worldcoord.dta", clear
    
    * fix overflow errors in the shapefile data
    replace _X = -180 if _X < -180
    replace _X = 180 if _X > 180 & !mi(_X)
    
    * convert coordinates using -geo2xy-
    geo2xy _Y _X if _ID!=13, proj(albers, 6378137 298.257223563 20 50 0 0) replace
    save "worldcoord_albers.dta", replace
    
    * create map
    use "UNfertdata.dta"
    spmap TFR1970 using "worldcoord_albers" if id!=13, ///
      id(id) fcolor(Rainbow) clmethod(custom) clbreaks(1 2 3 4 5 6 7 8) legcount
    And this is the map
    Click image for larger version

Name:	world2albers.png
Views:	1
Size:	228.1 KB
ID:	1324569
    Of course some would say that this is a biased representation of the world and would prefer

    Code:
    use "worldcoord.dta", clear
    
    * fix overflow errors in the shapefile data
    replace _X = -180 if _X < -180
    replace _X = 180 if _X > 180 & !mi(_X)
    
    geo2xy _Y _X if _ID!=13, proj(albers, 6378137 298.257223563 0 -30 0 15) replace
    save "worldcoord_albers.dta", replace
    
    * create map
    use "UNfertdata.dta"
    spmap TFR1970 using "worldcoord_albers" if id!=13, ///
      id(id) fcolor(Rainbow) clmethod(custom) clbreaks(1 2 3 4 5 6 7 8) legcount
    
    graph export "world3albers.png", width(600) replace
    which yields
    Click image for larger version

Name:	world3albers.png
Views:	1
Size:	156.7 KB
ID:	1324570

    Comment


    • #17
      @Fahim Ahmad
      Sure, you just need to find a shapefile that includes the province boundaries. Here's one I found from statscan (ArcGIS format, Carographic Boundary File, Provinces/Territories)

      Code:
      * Convert shapefile to Stata datasets
      shp2dta using "gpr_000b11a_e", data("dbf.dta") coor("coor.dta") replace
      
      use "coor.dta"
      geo2xy _Y _X, proj(albers) replace
      save "coor_albers.dta", replace
      
      * create map
      use "dbf.dta"
      spmap using "coor_albers", id(_ID)
      And the map produced
      Click image for larger version

Name:	canada.png
Views:	1
Size:	232.0 KB
ID:	1324577

      Comment


      • #18
        Robert, many thanks for the detailed and very helpful explanation.

        Comment

        Working...
        X