Esri / ArcREST

python package for REST API (AGS, AGOL, webmap JSON, etc..)
Apache License 2.0
192 stars 155 forks source link

geometryservice intersect #234

Closed DShokes closed 8 years ago

DShokes commented 8 years ago

ArcRest or ArcRestHelper

ArcRest

Version or date of download

3.5.4

Bug or Enhancement

document examples for geometryservice functions

Repo Steps or Enhancement details

I have two features with the following geometries:

{u'y': 6520782.7078824835, u'x': -15918260.703705259, 'spatialReference': {u'wkid': 102100, u'latestWkid': 3857}},
{u'y': 6520782.7078824835, u'x': -15918260.70370526, 'spatialReference': {u'wkid': 102100, u'latestWkid': 3857}}

I'm trying to prove that they intersect given some amount of tolerance. I think intersect is the function I want to use, but I'm not certain. Perhaps I should be using generalize. I don't know the correct parameter syntax for this function either. Thanks,

DShokes commented 8 years ago

I found a semi-workaround using the arcpy geometries.

>>> feature1.geometry.distanceTo(feature2.geometry)
4.4777
>>> # Using a geometryservice object 
>>> geoservice.distance(sr=102100,geometry1=arcrest.geometry.Point(feature1.geometry,wkid=102100),arcrest.geometry.Point(feature2.geometry,wkid=102100))
{u'distance': 4.47213595499958}

I could say if the distance is below some number, that the points are the same. Unfortunately, this function doesn't seem to work when one feature has a wkid but the other feature has only wkt.

The distance function has parameter name "distanceUnit" which is supposed to take these Possible Values: meters | feet | kilometers | miles | nautical-miles | yards. When I try any of these, I get the same error.

>>> geoservice.distance(102100,arcrest.geometry.Point(feature1.geometry,102100),arcrest.geometry.Point(feature2.geometry,102100),distanceUnit='feet')
{u'error': {u'message': u'Unable to complete Distance operation.', u'code': 400, u'details': [u'The specified WKID (factory code) or WKT (definition string) is not a  linear or angular unit.']}}

I can't tell if the distanceUnit error is a REST or ArcREST issue.

achapkowski commented 8 years ago

@DShokes - is this an ArcGIS Online or ArcGIS Server geometry service?

achapkowski commented 8 years ago

The distance units must be these: http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnitType_Constants/000w00000042000000/

or

http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnitType_Constants/000w00000041000000/

achapkowski commented 8 years ago

Usage Example:

pt1 = arcrest.common.geometry.Point(coord=[4,4], wkid=4326)
pt2 = arcrest.common.geometry.Point(coord=[5,5], wkid=4326)
print (gs.distance(sr=4236, geometry1=pt1, geometry2=pt2, distanceUnit=9036, geodesic=True))
DShokes commented 8 years ago

Thanks @achapkowski , I didn't think to use an integer for distanceUnit or that the options were located in the ArcObjects documentation.