Interact, learn and grow

Join Now
Reply
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.
Highlighted
SAS Employee
Posts: 2
Juletip #4 - Get your coordinate ready for the maps in Visual Analytics with SAS
[ Edited ]

This juletip covers bought Visual Analytics 7.x and 8.x

 

Visual Analytics 7.x 

Requires SAS/GRAPH 

 

If you want to visualize your data using a map object in Visual Analytics with custom coordinates, you better hope that your longitude and latitude coordinates are in WGS84 format, or at least that was what I thought until recently. 

I found out that the dataset SASHELP.PROJ4DEF contains 7124 different coordinate definitions and that we can convert between these with the help of PROC GPROJECT. 

 

Step one, find your coordinate system 

My suggestion would be to search the DESC variable in SASHELP.PROJ4DEF (see code example below). Identify name of the target coordinate system, for WGS 84 the name is "EPSG:4326". 

 

 

proc sql; 
select *  
from SASHELP.PROJ4DEF 
where upcase(DESC) like '%SWEREF99 TM%'; 
quit; 

 

When you have found the names for the source and target coordinate systems we can move on to converting the data. In my example below there is one observation containing the coordinates for the city of Malmö in SWEREF99 TM format. 

 

 

data coordinates; 
input City $ Longitude Latitude; 
datalines; 
Malmö 373547 6163386 
; 
run; 

 

Step two, convert the data 

To do this you need to rename your longitude and latitude variables to X and Y, specify the output dataset and the names of the from and to coordinate systems. You also need to specify City as ID.

 

 

/* Convert SWEREF99 TM to WGS84 */ 
proc gproject  
data=coordinates (rename=(Longitude=X Latitude=Y))  
out= coordinates_WGS84 
project=proj4  
from="EPSG:3006" /* SWEREF99 TM */ 
to="EPSG:4326";  /* WGS 84 */ 
id City; 
run; 

 

Step three, visualize and PROFIT! 

Screen Shot 2017-12-06 at 09.28.22.png

 

 

Visual Analytics 8.x 

When you are using Visual Analytics 8.x the conversion above aren’t necessary! You create your custom geography item like you are used to do in the 7.x version but when you specify the coordinate space you choose Custom and then enter the name of the coordinate system you found in the SASHELP.PROJ4DEF table. In my case “EPSG:3006” for SWEREF99 TM. 

 Screen Shot 2017-12-06 at 09.27.32.png

 

Contributor
Posts: 54
Re: Juletip #4 - Get your coordinate ready for the maps in Visual Analytics with SAS

Very good.

Please tell SAS support and Consultants about this. They have tell us there is no solution.

 

/Anders

SAS Super FREQ
Posts: 768
Re: Juletip #4 - Get your coordinate ready for the maps in Visual Analytics with SAS

hi Joel

 

Thanks for the tip, helped me find the right information for coordinates used in Switzerland. Should have have this tip a year ago;-)

 

Here are some websites with additional information:

https://epsg.io/ and http://spatialreference.org/

 

So for Switzerland I have found https://epsg.io/21781 or in GPROJECT from="EPSG:21781"