How to get the unit of a Geometry? Or gets the distance in specified units between two geometries

591
3
Jump to solution
03-05-2022 04:28 AM
YangYifei
New Contributor II

Hi there. I'm trying to get the distance of two geometries by this api ArcGIS Pro 2.8 API Reference Guide - Distance Method—ArcGIS Pro.

But I found that I will get a result in meter from some .shp files. But when I use another .shp file, it seems to be kilometer...

I'm so confused about it. And I have searched API document, and found that I can set the LinerUnit if I use  GeodesicDistance refers in ArcGIS Pro 2.9 API Reference Guide - GeodesicDistance(Geometry,Geometry,LinearUnit) Method—ArcGIS Pr...

But I have used 2.8 API, there's no this implement...

 

And I have tried to get the elevation unit format of the map, they're all meter in different .shp file.

 

So how can I get the unit type of a Geometry? Or can I change the distance result to meter directly?

Thanks a lot!

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
YangYifei
New Contributor II

I found that GeodesicDistance  can return the distance in meteres by default

ArcGIS Pro 2.8 API Reference Guide - GeodesicDistance Method—ArcGIS Pro

So I can use it to get the distance in LinearUnit.Meteres

And then convert it to other LinearUnit. It solved my problem.

Thank you so much!

View solution in original post

0 Kudos
3 Replies
CharlesMacleod
Esri Regular Contributor

use the geometry spatial reference:

https://pro.arcgis.com/en/pro-app/2.8/sdk/api-reference/#topic8178.html

specifically, its Unit property.

https://pro.arcgis.com/en/pro-app/2.8/sdk/api-reference/#topic8797.html

In your case it sounds like it is of type LinearUnit.

 

 

 

0 Kudos
YangYifei
New Contributor II

Thanks for your reply!

I found that the special reference of my geometry is AngularUnit.Degrees.

And I try to convert it to LinearUnit.Meters.

But there's no such implement that can convert the unit from angular to linear...

So any other methods can I try?

Thank you!

0 Kudos
YangYifei
New Contributor II

I found that GeodesicDistance  can return the distance in meteres by default

ArcGIS Pro 2.8 API Reference Guide - GeodesicDistance Method—ArcGIS Pro

So I can use it to get the distance in LinearUnit.Meteres

And then convert it to other LinearUnit. It solved my problem.

Thank you so much!

0 Kudos