08-19-2013 12:33 PM
I'm trying to figure out how to draw several lines between different pairs of points on a map, using PROC GMAP or some other mapping procedure. I've already done the prep work using PROC GPROJECT to get my annotation dataset projected in line with my source map dataset, and I can display my map and points with:
proc gmap data=States map=Map0 ;
choro state / annotate=Loc1 discrete nolegend;
In that code,
States comes from maps.states(where=(state not in(2 15 72))), it's basically the continental US.
Map0 comes from States, and then is processed similar to the dataset "Map" in this example: SAS Maps Online
Loc1 is my dataset of various coordinates I've plotted, and was processed similar to the dataset "Cities" in that same example. It has 30 records of coordinates, with a variable LocID numbered 1 through 30, which is how we identify them internally.
So far so good, and all the points in Loc1 come out exactly where they should be. Now, I'd like to be able to draw lines between the point with LocID=1 and LocID=2, or LocID=5 and LocID=7, or LocID=9 and LocID=22, and so on.
I haven't been able to figure out how to do this, either through PROC GMAP or some other mapping procedure. Does anyone have any suggestions for me to try or examples I could follow?
08-19-2013 01:13 PM
You can use an 'annotate' data set to place markers on the map (annotated function='pie') and connect them using annotated lines (function='move' and 'draw').
Here is the simplest example I have...
08-19-2013 02:12 PM
That's great, thanks so much! I was able to follow that example and get it to work:
Now, the next thing I need to figure out is if there's a way to calculate the distances of those line segments. That would probably take some data manipulation and using the GEODIST function, right? Or is there a way to do it within PROC GMAP or one of the other mapping procedures?
08-19-2013 02:47 PM
One other thing... is there a way to offset multiple lines that collect the same 2 points? For example, if these represent travel between 2 cities, and someone travels between the same two cities more than once, can there be multiple lines next to each other but slightly offset?
08-19-2013 02:50 PM
There is a way to offset text, using the annotate 'position' (position='5', position='2', etc), but there is not a built-in way to apply offsets to the drawn graphics (such as pie markers and lines/arrows). You will have to programmatically manipulate the x/y coordinates in your data to do that. (I think this will not be easy.)
08-19-2013 03:41 PM
Unless the number of trips is large, you might be able to summarize your data and get counts of duplicate trips. Then factor the number into a line width parameter.
08-19-2013 09:57 PM
Thanks to both of you for your responses. What you wrote makes sense, and is along the lines of what I was thinking... it's good to get confirmation on it, definitely.
08-20-2013 08:13 AM
Another option, besides the width or color of the line, would be to use alpha-transparent colors (if you have SAS 9.3 or higher). With the alpha-transparent colors, the more lines you overlay in the same location, the more color they will get.
An example of a red alpha-transparent color would be ... Aff000077