I am trying to read input of lat and long to draw the shape based on condition.The input is standard array of lat and long with 15 decimal accuracy. I am realizing - I am loosing some decimal accuracy (the point was somewhat offsite and complex polygons were never drawn). The samples are here:
point: [[[-81.00392112682097,46.50255058560673]]]
the plotted point is: -81.003906 46.502686 and I am generating PDF maps at 1:3000 scale so it is a big deal.
polygon: [[[-79.37485174735863,43.6430783790403],[-79.37361793121188,43.64341222822559],[-79.37323169311376,43.64261253986735],[-79.374186559523,43.64234079868168],[-79.37412218650664,43.64220880966229],[-79.37454061111293,43.64210787668709],[-79.37471227248987,43.64248831547784],[-79.37463717063745,43.64251160757044],[-79.37481956085045,43.64285322389105],[-79.37470154365381,43.642884279823875],[-79.37485174735863,43.6430783790403]]]
I used eval to read input as list, but probably that was not a good idea. Not sure how and where should I cast the input as decimal?
OrderCoord = eval(arcpy.GetParameterAsText(0))
point = arcpy.Point()
array = arcpy.Array()
# A list that will hold each of the Polygon objects
featureList = []
for feature in OrderCoord:
# For each coordinate pair, set the x,y properties and add to the
# Array object.
#
for coordPair in feature:
point.X = coordPair[0]
point.Y = coordPair[1]
array.add(point)
if OrderType.lower()== 'point':
feaERIS = arcpy.Multipoint(array)
elif OrderType.lower() =='polyline':
feaERIS = arcpy.Polyline(array)
else :
feaERIS = arcpy.Polygon(array)
# Clear the array for future use
array.removeAll()
# Append to the list of Polygon objects
featureList.append(feaERIS)
I added the screenshot of these points at 2000 scales. We have a Flex application where customer can draw and order a geometry. All the data sits in ORACLE and I am working on a GP Tool to print final PDF.
Answer
Turns out its a known bug in ArcGIS (which is not a priority to be fixed sadly). We had the same issue ourselves when trying to input features using arcpy.AsShape
. From the ESRI tech support response we got it turns out that if you don't specify a spatial reference ArcGIS automatically truncates data to 3 decimal places. This remains the case even if you try and specify the tolerance using arcpy.env.XYTolerance
.
The only solution is to create the geometry object with a spatial reference. For example the arcpy.Polygon
object takes a Spatial Reference object as it's second argument.
Note that arcpy.Point
is used to construct geometries, but is not a point geometry itself. arcpy.Point
does store the full resolution of the point until it's used to create a geometry and doesn't take a spatial reference argument itself.
No comments:
Post a Comment