DATA Step, Macro, Functions and more

Geo distance calculation GEODIST

Reply
Frequent Contributor
Posts: 87

Geo distance calculation GEODIST

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
PROC Star
Posts: 227

Re: Geo distance calculation GEODIST

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?

 

Frequent Contributor
Posts: 87

Re: Geo distance calculation GEODIST

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

PROC Star
Posts: 227

Re: Geo distance calculation GEODIST

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

Super Contributor
Posts: 448

Re: Geo distance calculation GEODIST

[ Edited ]

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
PROC Star
Posts: 227

Re: Geo distance calculation GEODIST

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

Ask a Question
Discussion stats
  • 5 replies
  • 68 views
  • 2 likes
  • 3 in conversation