Use PROC GPROJECT to Project Choromap Regions Successfully in PROC SGMAP


Sometimes it is difficult to know what parameters to use when projecting map data onto Esri or OpenStreetMaps in PROC SGMAP. The shapefile .PRJ file contains everything you need to set these parameters in PROC GPROJECT.

In a previous blog, you saw how to lookup projections at a web site, so they can be used with Esri or OpenStreetMaps. But, what if you can’t find the projection you need?

In this example, you are mapping boundaries for British Columbia using the PROC SGMAP CHOROMAP statement using projections you define yourself.

Here is the complete code for this example.

Import the Shapefile

Download the 2011 shapefile for British Columbia under “GIS Downloads” on this web site, then import the data using PROC MAPIMPORT and use PROC SGMAP.

proc mapimport out=BC1
  id cdname;
title1 "British Columbia Choromap with Non-Projected Data";
proc sgmap mapdata=BC1 noautolegend;
  choromap / mapid=cdname; 

Here is the output:

British Columbia using downloaded values
That looks good.

Next, try PROC SGMAP with an OpenStreetMap background:

title1 "British Columbia Choromap with Non-Projected Data";
proc sgmap mapdata=BC1 noautolegend;
  choromap / mapid=cdname; 

British Columbia using downloaded values on OpenStreetMap
Where did your map areas go?


There are many different map projections in use across the globe. The British Columbia shapefile is using a different map coordinate system and cannot be projected onto an OpenStreetMap.

To fix this, you need to use PROC GPROJECT like this:

proc gproject data=BC1 out=BC
  from="parameters from the .PRJ file"
  id cdname;

You need to supply the “from” information above, but what if you cannot find the correct projection parameters from web sites or from the SASHELP.PROJ4DEF dataset?

Build your own using data from the .PRJ file included with the shapefile package. Here is a web page that outlines the details about these parameters.

For our uses, the parameters can be summarized as follows:

    +proj = PROJCS
    +dataum = DATUM
    +ellps = Spheroid
    +x_0 = False_Easting
    +y_0 = False_Northing
    +lon_0 = Central_Merdian
    +lat_0 = Latitude_Of_Origin
    +lat_1 = Standard_Parallel_1
    +lat_2 = Standard_Parallel_2
    +units = UNIT

Here is the .PRJ file for your data:

PROJCS["NAD_1983_BC_Environment_Albers", GEOGCS["GCS_North_American_1983", DATUM["D_North_American_1983", SPHEROID["GRS_1980",6378137.0,298.257222101]], PRIMEM["Greenwich",0.0], UNIT["Degree",0.0174532925199433]], PROJECTION["Albers"], PARAMETER["False_Easting",1000000.0], PARAMETER["False_Northing",0.0], PARAMETER["Central_Meridian",-126.0], PARAMETER["Standard_Parallel_1",50.0], PARAMETER["Standard_Parallel_2",58.5], PARAMETER["Latitude_Of_Origin",45.0], UNIT["Meter",1.0]]

Using the .PRJ file and definitions on the web page, fill in the parameters and include them in PROC GPROJECT:

proc gproject data=BC1 out=BC
  from="+proj=aea +datum=NAD83 +ellps=GRS80
        +x_0=1000000.0 +y_0=0.0
        +lat_0=45.0 +lat_1=50.0 +lat_2=58.5      
        +units=m +no_defs"
  to="EPSG:4326";  /* always use EPSG:4326 for OSM and Esri */
  id cdname;

Run PROC SGMAP again using the projected data and the boundaries now match the OpenStreetMap:

British Columbia with projected values on OpenStreetMap
That is what you expected. The boundaries match the background map.

Do you see the dark jagged edges of the barrier islands on the coast? In the next blog you will work on making those easier to visualize by reducing the number of points used to draw the lines.


About Author

Kelly Mills

Principal Test Engineer

Kelly Mills is a Principal Test Engineer with over 30 years of manual and automated testing experience in computer, communications and analytics software industries. He's worked at companies such as Alcatel, IBM and SAS Institute.


  1. Could this be modified slightly to show the full PRJ file in the text? It's cutting off in Safari for me, so I resorted to checking the text file but it would be helpful to have it here as well. Less things to keep one when cross referencing things.

    • Kelly Mills

      I added spaces in the .PRJ text so it would wrap on different browsers. The text now wraps on Safari on my iPad.

      Thank you for pointing this out! I need to verify that my posts display correctly on browsers other than Edge.

Back to Top