POST
|
Hi Xander, I run the python file from a .bat file, the content in the .bat file is "C:\Python26\Arcgis10.0\python.exe C:\testing\donut.py" since I need add to the batch file in a scheduled job. It seems it is not the correct way? Now I am using da cursor (ArcGIS 10.1) with the code shared by you, it works properly. Thank you.
... View more
09-05-2016
12:40 AM
|
0
|
0
|
511
|
POST
|
Thanks so much for your help Dan and Xander, I use the 2nd script (yes this is the right way) but I get runtime error when process the multiple parts polygon: oid 0 - part 0 - pnt 48408.0001220703 42942.8201293945 NaN NaN 48408 42942.82 NaN NaN - pnt 48391.9600830078 42944.5001220703 NaN NaN 48391.96 42944.5 NaN NaN - pnt 48391.4301147461 42957.2000732422 NaN NaN 48391.43 42957.2 NaN NaN - pnt 48416.9801025391 42950.9700927734 NaN NaN 48416.98 42950.97 NaN NaN - pnt 48408.0001220703 42942.8201293945 NaN NaN 48408 42942.82 NaN NaN oid 1 Traceback (most recent call last): File "C:\Script\dobut.py", line 38, in <module> main() File "C:\Script\dobut.py", line 26, in main polygon2 = arcpy.Polygon(arcpy.Array(lst_pol), sr) File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\mixins. py", line 196, in dunu *gp_fixargs(args, True)) File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_bas e.py", line 474, in <lambda> return lambda *args: val(*gp_fixargs(args)) RuntimeError: Object: CreateObject cannot create geometry from inputs I run the python file through batch file.
... View more
09-01-2016
09:04 PM
|
0
|
3
|
511
|
POST
|
Hi Dan, The script from stand alone, it means I run the script without open arcmap. After running the script I manually check the vertex xy value in editing session. I will test on a shapefile as you suggested, and update the result. Thank you
... View more
09-01-2016
12:30 AM
|
0
|
6
|
511
|
POST
|
Hi Dan, thanks for the advice. You are right that I should round the xy value. The most important thing is I cannot change the vertex xy value for multiple parts polygon at all, don't know whether there is a way to change the vertex value for multiple parts polygon. Thanks again.
... View more
08-31-2016
11:48 PM
|
0
|
8
|
858
|
POST
|
Hi Dan, the purpose is to modify the xy value of the vertex. For example, one vertex coordinate is (123.456, 213.672), I want to change it to (123.45, 213.67).
... View more
08-31-2016
07:57 PM
|
0
|
11
|
859
|
POST
|
Hi Dan, Yes the points printing out in line 33 line 52, if you indent it one more level the print out result is the same The shapefile is attached for reference. Thank you so much....
... View more
08-31-2016
03:21 AM
|
0
|
13
|
859
|
POST
|
Thank you Dan, already format the code. I didn't add it in new data frame or refresh the view. The script works for single part polygon.
... View more
08-30-2016
08:56 PM
|
0
|
15
|
859
|
POST
|
Dear all, I am using python2.6 (together with arcgis 10.0) and try to modify the vertice xy values for multiple parts polygon using the following scripts, no error thrown but the vertice xy value not changed. Please help to advice what is wrong in my script: def modify(f, n):
s = '%.12f' % f
i, p, d = s.partition('.')
return '.'.join([i, (d+'0'*n)[:n]])
import arcpy
import logging
from arcpy import env
env.workspace = r"C:\modifyTest"
infc = "testing.mdb/donutTesting1"
desc = arcpy.Describe(infc)
shapefieldname = desc.ShapeFieldName
my_field = "SHAPE"
rows = arcpy.UpdateCursor(infc)
for row in rows:
feat = row.getValue(shapefieldname)
arr_pol = arcpy.Array()
partnum = 0
if feat.isMultipart == True:
for part in feat:
parts = []
arr_parts = arcpy.Array()
while partnum < feat.partCount:
part = feat.getPart(partnum)
pnt = part.next()
while pnt:
X_value = modify( pnt.X , 2)
Y_value = modify( pnt.Y , 2)
pnt.X= X_value
pnt.Y= Y_value
#print pnt.X, pnt.Y
parts.append([X_value, Y_value])
XYPoint = arcpy.Point(X_value, Y_value)
arr_parts.add(XYPoint)
arr_pol.add(arr_parts)
pnt = part.next()
if pnt is None:
pnt = part.next()
if pnt:
X_value = modify( pnt.X , 2)
Y_value = modify( pnt.Y , 2)
pnt.X= X_value
pnt.Y= Y_value
parts.append([X_value, Y_value])
XYPoint = arcpy.Point(X_value, Y_value)
arr_parts.add(XYPoint)
arr_pol.add(arr_parts)
partnum += 1
print parts
polygon = arcpy.Polygon(arr_pol)
row.setValue(my_field,polygon)
rows.updateRow(row)
... View more
08-30-2016
02:14 AM
|
0
|
17
|
2230
|
POST
|
Dear all, I would like to check with you, in Polygon feature class, how to set the XY values precision only two decimal places without rounding up. I have tried to set XYResolution to 0.01 to store only two decimal digits. But the value is rounded up and changed the position. Is there any setting to create a polygon feature class by truncating two decimal places of original XY values? Eg, X= 0.389 , Y= 2.467 to X = 0.38 , Y = 2.46 Thanks.
... View more
12-30-2015
01:47 AM
|
0
|
3
|
6138
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|