BookmarkSubscribeRSS Feed
ANLYNG
Pyrite | Level 9

Hi,

I am stucked with this. I need to calculate distance in SAS between 2 set of coordinates. I only got UTM coodinates and

I use geodist function. But is does not create any output on distance and distance2.

 

Can you help or have some ideas ?

 

Thanks in advance,

 

data test_distance;

set all_koordinater;

distance=geodist(GIS_koor_X,GIS_koor_Y,Latitude2,Longitude2)*1000;

distance2=geodist(726021,6272193,726031,6272193)*1000;

run;

 

GIS_koor_XGIS_koor_YLatitude2Longitude2
736021,686272193,06731728,96256273181,548
737435,516274983,35731728,96256273181,548
737221,526274654,31731728,96256273181,548
737043,376274223,31731728,96256273181,548
747060,376274518,13721728,96256273181,548
727043,376274223,31721728,96256273181,548
727497,956272526,8721728,96256273181,548
727056,146273195,25721728,96256273181,548
7 REPLIES 7
s_lassen
Meteorite | Level 14

I think that your problem is the coordinates. The numbers should be in degrees, between 0 and 360, what you have is much too high.

Maybe you have the wrong unit.

I assume that your longitudes and latitudes are 10,000 times too big, but it could be something else.

 

distance2=geodist(726021,6272193,726031,6272193)*1000;

gives a missing value,

distance2=geodist(72.6021,62.72193,72.6031,62.72193)*1000;

gives a distance of 111 meters and 59 centimeters. Is that what you expected?

 

ANLYNG
Pyrite | Level 9

the unit is UTM coordinates and should be fine. I am not sure if geodist accepts this input?

s_lassen
Meteorite | Level 14

According to the documentation, no. UTM coordinates are not an option. Coordinates can be degrees or radians.

SuryaKiran
Meteorite | Level 14

GEODIST() function cannot use UTM values as parameters. Convert those values to supported values. This function has a 5th argument <Options> (M- Miles, K- Kilometers, D-Degree and R- Radians) and the default will be 'D'. In your case it is interpreting the values as Degrees.

 

Document :http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003113162.htm

Thanks,
Suryakiran
s_lassen
Meteorite | Level 14

If you have SAS/Graph, you can convert to degrees with PROC GPROJECT.

michokwu
Quartz | Level 8

I don't think the UTM coordinates can be used in the SAS geodist function, try using the steps below to compute the distance 

data test_distance;

set all_koordinater;

Long_diff = Longitude1 - Longitude2
Lat_diff = Latitude1 - Latitude2;
dist = sqrt ( Long_diff**2 + Lat_diff**2 );
distance = dist*0.000189394; * Convert feet to mile;

run;

PGStats
Opal | Level 21

GEODIST is for calculating geographic distances from latitudes and longitudes. UTM coordinates are expressed in meters from the equater (y value) and one of 60 central meridians (x value). So, within a given zone, the distance between two coordinates (in meters) is given by :

 

distanceInMeters = EUCLID(UTMx_1-UTMx_2, UTMy1-UTMy_2);

PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1844 views
  • 2 likes
  • 5 in conversation