Data visualization with SAS programming

Help with GEOCODE/GPROJECT/Annotate

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 84
Accepted Solution

Help with GEOCODE/GPROJECT/Annotate

I am trying to map some street addresses and have them show up as icons (stars) using the maps.us table as my mapping table and the annotate process.  I've found some great examples of what I want to do online:

SAS/GRAPH(R) 9.2: Reference, Second Edition

http://www.nesug.org/proceedings/nesug08/np/np05.pdf

However, I can't seem to get my locations to show up.  Here is my process:

proc geocode

   method=STREET

   data=temp

   out=GEOCODED

   lookupstreet=SASHELP.GEOEXM

   attributevar=(TRACTCE00);

run;

data anno;

  set GEOCODED;

  length function style color text $8;

  format X Y comma12.10;

  xsys='2';

  ysys='2';

  hsys='3';

  when='A';

  function = 'label';

  style='special';

  text='M';

  color='Red';

  size=5;

  position='E';

  segment=1;

  x=atan(1)/45 * x;

  y=atan(1)/45 * y * -1;

run;

proc gproject data=anno out=annop;

  id segment;

run;

proc gmap

  map=maps.us

  data=maps.us

  anno=annop;

  id statecode;

  choro statecode / nolegend;

  where statecode not in ("AK", "HI", "PR");

run;

quit;

I think the problem has something to do with the radians/degrees conversion, but I'm not sure if I need to have my map set and annotate set in the same table.  Any help is appreciated.  Thank you!


Accepted Solutions
Solution
‎04-12-2013 07:36 PM
SAS Employee
Posts: 977

Re: Help with GEOCODE/GPROJECT/Annotate

Here's one example that uses Proc Geocode to look up lat/long, and then plots the results on a U.S. state map:

http://robslink.com/SAS/democd61/meningitis.htm

http://robslink.com/SAS/democd61/meningitis_info.htm

Note that it only looks up the address based on the zipcode (rather than street address) -- this is usually quicker, and depending on what you're plotting, zipcode centroids are usually adequate when plotting on a U.S. state map (of course, you could also use street-level geocoding with this code if you want!)

View solution in original post


All Replies
SAS Employee
Posts: 977

Re: Help with GEOCODE/GPROJECT/Annotate

In order to plot lat/long values on a map, you'll need to gproject those coordinates the exact same way the map was projected.  The way that you will see in most examples is to start with an unprojected map, combine the annotate & map, project them both at the same time, and then separate them again.  Before you combine the map and the annotate, you'll want to make sure their x/y (long/lat) are in the same units (degrees or radians, eastlong or westlong).

Note that maps.us is already projected (and doesn't contain unprojected coordinates), and therefore cannot be used with this technique.

I'd recommend you start with a working example, and then modify that to use your data.

Solution
‎04-12-2013 07:36 PM
SAS Employee
Posts: 977

Re: Help with GEOCODE/GPROJECT/Annotate

Here's one example that uses Proc Geocode to look up lat/long, and then plots the results on a U.S. state map:

http://robslink.com/SAS/democd61/meningitis.htm

http://robslink.com/SAS/democd61/meningitis_info.htm

Note that it only looks up the address based on the zipcode (rather than street address) -- this is usually quicker, and depending on what you're plotting, zipcode centroids are usually adequate when plotting on a U.S. state map (of course, you could also use street-level geocoding with this code if you want!)

Frequent Contributor
Posts: 84

Re: Help with GEOCODE/GPROJECT/Annotate

Thanks Robert, as always that was a big help!

Occasional Contributor
Posts: 9

Re: Help with GEOCODE/GPROJECT/Annotate

The concept of mapping some street addresses and have them show up as icons (stars) using the maps.us table and annotate processing is similar with adding annotation to document page or image within a document image annotation application. You can first save and store you map in any supportable image or document form, like jpeg, png, gif, tiff or pdf, and then embed and load your map into the annotation project to highlight and note and underline the necessary streets addresses.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 495 views
  • 3 likes
  • 3 in conversation