POST
|
Traceback (most recent call last): File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript exec codeObject in __main__.__dict__ File "C:\Student\Script_fieldname.py", line 13, in <module> shift_features(in_features) File "C:\Student\Script_fieldname.py", line 9, in shift_features cursor.updateRow([[row[0][0] + (row[1] or 0), row[0][1] + (row[2] or 0)]]) TypeError: sequence size must match size of the row >>> I'm working on a project that, in the past, I ran a move calculation [SHAPE].Move([fieldname],0) in arc3.3. I work in ArcGIS 10, but use the oldie for a couple of tasks. We have upgraded and now don't have the use of arc3.3 anymore. I need to find a (modern) way to shift polygon features way out of their original spatial placement and then back again. Arcpy Café "shifting features" coding looked promising, but way out of my wheelhouse. So I am here begging for help. I did some Python tutorials, but am just not getting it. Wendy
... View more
04-14-2015
11:25 AM
|
0
|
0
|
621
|
POST
|
Sorry, I am just not getting it. I have two fields. One is called x_shift and one is called y_shift. Both float fields. Each currently have a value of 200. I keep getting an error. import arcpy
in_features = r"C:/Temp/CP_C06.shp"
def shift_features (in_features):
with arcpy.da.UpdateCursor(in_features, ['SHAPE@XY','x_shift','y_shift']) as cursor:
for row in cursor:
cursor.updateRow([[row[0][0] + (row[1] or 0), row[0][1] + (row[2] or 0)]])
return
shift_features(in_features)
... View more
04-14-2015
10:53 AM
|
0
|
8
|
621
|
POST
|
Hi Darren. What if I want to pull the x-shift value and y-shift value from a field in my shapefile instead of putting a value into the code sequence?
... View more
04-14-2015
08:41 AM
|
0
|
10
|
850
|
POST
|
That totally did the trick. Thanks for helping the newbie.
... View more
01-15-2015
03:15 PM
|
0
|
0
|
850
|
POST
|
Using PythonWin gives me the following error. NameError: name 'shift_features' is not defined. Below is the code that I used. import arcpy in_features = r"C:/Temp/CP_C06.shp" x_shift = 100 y_shift = 100 shift_features(in_features, x-shift, y_shift) def shift_features (in_features, x_shift=None, y_shift=None): with arcpy.da.UpdateCursor(in_features, ['SHAPE@XY']) as cursor: for row in cursor: cursor.updateRow([[row[0][0] + (x_shift or 0), row[0][1] + (y_shift or 0)]]) return
... View more
01-15-2015
03:03 PM
|
0
|
16
|
850
|
POST
|
I am totally new to script writing and am trying to get the Shifting Features code to work from ArcPy Café. I can't see what I am doing wrong.
... View more
01-15-2015
09:05 AM
|
0
|
18
|
4792
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|