- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 02-09-2011 07:44 PM
(2004 views)
Hi All,
Im trying to map some data on to the australian map (called austral i believe).
Say the data is as follows:
lat long expenditure
-31.5 149.8 $5000
-30.5 148.2 $3000
-29.6 147.3 $7000
How do I plot the above data onto the australian map? Is using Gproject an absolute must?
Thanks,
Sachin
Im trying to map some data on to the australian map (called austral i believe).
Say the data is as follows:
lat long expenditure
-31.5 149.8 $5000
-30.5 148.2 $3000
-29.6 147.3 $7000
How do I plot the above data onto the australian map? Is using Gproject an absolute must?
Thanks,
Sachin
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
yes - using Proc Gproject is an absolute must, to get lat/long data to line up in the correct location on a map.
The following code should get you started:
data foo;
input lat long expenditure;
datalines;
-31.5 149.8 5000
-30.5 148.2 3000
-29.6 147.3 7000
;
run;
data foo; set foo;
/* convert degrees to radians, and longitude to 'eastlong' */
x=atan(1)/45 * long * -1;
y=atan(1)/45 * lat;
anno_flag=2;
run;
/* combine and project the lat/long radian values */
data combined; set maps.austral (drop = x y rename=(lat=y long=x)) foo;
run;
proc gproject data=combined out=combined dupok;
id id;
run;
/* separate the map and point data again */
data austral foo; set combined;
if anno_flag eq 2 then output foo;
else output austral;
run;
/* convert projected point data into annotated text */
data foo; set foo;
length color $8 text $50;
xsys='2'; ysys='2'; hsys='3'; when='a';
function='label'; size=2;
color='red';
text=put(expenditure,dollar10.0);
run;
pattern1 v=solid color=cornsilk;
title "Australia Expenditures";
proc gmap map=austral data=austral anno=foo;
id id;
choro id / levels=1 nolegend coutline=grayaa;
run;
The following code should get you started:
data foo;
input lat long expenditure;
datalines;
-31.5 149.8 5000
-30.5 148.2 3000
-29.6 147.3 7000
;
run;
data foo; set foo;
/* convert degrees to radians, and longitude to 'eastlong' */
x=atan(1)/45 * long * -1;
y=atan(1)/45 * lat;
anno_flag=2;
run;
/* combine and project the lat/long radian values */
data combined; set maps.austral (drop = x y rename=(lat=y long=x)) foo;
run;
proc gproject data=combined out=combined dupok;
id id;
run;
/* separate the map and point data again */
data austral foo; set combined;
if anno_flag eq 2 then output foo;
else output austral;
run;
/* convert projected point data into annotated text */
data foo; set foo;
length color $8 text $50;
xsys='2'; ysys='2'; hsys='3'; when='a';
function='label'; size=2;
color='red';
text=put(expenditure,dollar10.0);
run;
pattern1 v=solid color=cornsilk;
title "Australia Expenditures";
proc gmap map=austral data=austral anno=foo;
id id;
choro id / levels=1 nolegend coutline=grayaa;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Rob,
That helped heaps.
Any suggestions as to how to use a heat map on this (or atleast a traffic light one) such that I get a red dot for the $7000, amber for $5000 and so on.
Cheers,
Sachin
That helped heaps.
Any suggestions as to how to use a heat map on this (or atleast a traffic light one) such that I get a red dot for the $7000, amber for $5000 and so on.
Cheers,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Just modify the code where you create the annotate dataset.
Where it currently says:
color='red';
Add some logic like this:
if (expenditure >= 7000) then color='red';
else if (expenditure < 7000 and expenditure >= 5000) then color='orange';
else color='green';
Tweak it according to your needs.
Where it currently says:
color='red';
Add some logic like this:
if (expenditure >= 7000) then color='red';
else if (expenditure < 7000 and expenditure >= 5000) then color='orange';
else color='green';
Tweak it according to your needs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
To see some sample code for annotating colored dots on Australia, see the following thread from last month:
http://support.sas.com/forums/thread.jspa?messageID=49103
http://support.sas.com/forums/thread.jspa?messageID=49103