Data visualization with SAS programming

map creation

Reply
Contributor
Posts: 37

map creation

[ Edited ]

Hi. I have confronted to a problem on map creation. I need to add the shops on the map.

the code that creates the map is below. 

So, please give me a hint how to add the coordinates on the map. 

Thanks beforehand. 

%annomac;
%maplabel (mapsgfk.armenia, mapsgfk.armenia_attr, work.labelout, idname, id,
           font=Albany AMT, color=black, size=1.5, hsys=3);
proc gmap map=mapsgfk.armenia data=mapsgfk.armenia;
	*where id eq "AM-01";
   id  id;
   choro id / nolegend annotate=labelout coutline=gray stat=first;
run;
quit;

 

 

proc gproject data=myxlfl.sc_coord_idd

 out = sc_coord_id_XY;
 id Segment;
run; 

I have tried to project the coordinates in such way but it was wrong.

 The coordinates of the shops is here. 

 

 

IDZoneXY
AM-01Yerevan40.1974129544.5678061
AM-10Vayots Dzor39.7604964345.33073236
AM-10Vayots Dzor39.6893762745.47180898
AM-10Vayots Dzor39.8353452645.66534589
AM-11Tavush41.2298856244.83745333
AM-01Yerevan40.141661544.52101183
PROC Star
Posts: 1,673

Re: map creation

You could just get the closest X and Y for your LAT on LONG.

 


data SHOPS;
 input ROW ID $ LAT LONG;
cards;
1 AM-01 40.19741295 44.5678061
2 AM-10 39.76049643 45.33073236
3 AM-10 39.68937627 45.47180898
4 AM-10 39.83534526 45.66534589
5 AM-11 41.22988562 44.83745333
6 AM-01 40.1416615 44.52101183
run;

proc sql; 
  create table ANNO as
  select SHOPS.ROW, SHOPS.ID, la.Y ,lo.X  
         , 'label' as FUNCTION, put(ROW,z2.) as TEXT, '2' as XSYS, '2' as YSYS
  from SHOPS  
      ,MAPSGFK.ARMENIA la   
      ,MAPSGFK.ARMENIA lo   
  where SHOPS.ID=la.ID 
    and   SHOPS.ID=lo.ID 
  group by 1,2 
  having abs(SHOPS.LAT-la.LAT)  =min(abs(SHOPS.LAT -la.LAT)) 
     and abs(SHOPS.LONG-lo.LONG)=min(abs(SHOPS.LONG-lo.LONG)) ;
quit;

proc gmap  map=MAPSGFK.ARMENIA data=MAPSGFK.ARMENIA; 
   id  id;
   choro id / nolegend annotate=ANNO coutline=gray stat=first;
run;
quit;

Capture.PNG

PROC Star
Posts: 1,673

Re: map creation

Moved to "SAS/GRAPH" board

Contributor
Posts: 37

Re: map creation

Hi. many thanks for help.  one more question.

 

The code you have written, creates "ANNO" data set, in which X and Y ccordinates exist. So, please explain, what is the format of the "X" and  "Y" . 

I tried to use proc gproject, but in vain.

 

11AM-010.0022782902-0.006334428label0122
22AM-10-0.0054011110.0039082507label0222
33AM-10-0.0066600530.0058276305label0322
44AM-10-0.0040024350.0083556018label0422
55AM-110.0202396895-0.002652059label0522
66AM-010.0012979944-0.006904374label0622
PROC Star
Posts: 1,673

Re: map creation

[ Edited ]

Not too sure, they are the coordinates used by the SAS maps, but as long as you have a way to map X and Y to LAT and LON as I did, I doesn't really matter for what you want to do.

Contributor
Posts: 37

Re: map creation

So, to be more clear. I have a bunch of coordinates of shops, as I wrote before. I want to understand how  you converted the coordinates into the coordinates that SAS uses (X, Y ). are there another methods besides the way you used for converting. the way of converting the coordinates that you used is not familiar to me.

 

I know several formats of coordiantes such as decimal, cartesian, degree, polar which are explaind in sas documents. but the said is not known. 

could I use 

proc gprogect for converting the coordinates.

 

 

Thanks.

Super User
Posts: 19,151

Re: map creation

@Garik I think you're overthinking this. You need the latitude and longitude, X=Longitude and Y=Latitude

 

If you're source data is projected onto a different coordinate system then you need some modifications or GPROJECT. But try it with just your latitude and longitude first.

PROC Star
Posts: 1,673

Re: map creation

My method is really simple: find the same latitude in the map file as what you have, and get the matching Y.

 

A slightly more sophisticated method, since for most countries the projection is essentially flat: you can probably create a first degree polynomial equation to transform LAT/LON into Y/X just by looking the four columns in the maps file.

 

If you want to project, see the post by @ballardw for a third method to match LAT/LON to X/Y.

 

 

Super User
Posts: 11,134

Re: map creation

You projection is incomplete. You want to reference the map data set to have the "bounds" of the map area and some other options.

I don't know how/what you pasted for the Proc Gproject code but I can't copy and paste to edit to something close to what you need.

 

From the online documentation example for projecting an annotate data set:

proc gproject data=cities
              degrees
              latlon
              out=citiesp
              parmentry=us48p
              dupok;
id;
run;

Data=cities would be the equivalent of your coordinate set

 

Degrees says that the data for latitude and longitude are measured in degrees not radians

Latlon says to use the Lat and Long variables from the MAP data set for projection

Out= output data set

Parmentry= the map data set with X, Y and Lat Long variables

Dupok and option not to remove duplicate projections.

Id does not have a variable because you want to project points (cities) not polygons that require identification of area units.

Ask a Question
Discussion stats
  • 8 replies
  • 215 views
  • 1 like
  • 4 in conversation