|
POST
|
This line should only return the first layer in your dataframe. lyr = arcpy.mapping.ListLayers(mxd, "", df)[0] If you want to test if "Fields" has any features selected you can do this. df = arcpy.mapping.ListDataFrames(mxd)[0] lyr = arcpy.mapping.ListLayers(mxd, "Fields", df)[0] desc = arcpy.Describe("Fields") if desc.FIDSet: df.extent = lyr.getSelectedExtent() else: arcpy.AddMessage("Fields polygon not selected")
... View more
10-16-2013
06:17 AM
|
0
|
0
|
2604
|
|
POST
|
Unless you have multiple "Fields" layers you don't need to loop through anything. df = arcpy.mapping.ListDataFrames(mxd)[0]
lyr = arcpy.mapping.ListLayers(mxd, "Fields", df)[0]
df.extent = lyr.getSelectedExtent()
... View more
10-16-2013
04:59 AM
|
0
|
0
|
2604
|
|
POST
|
You are probably getting your specific issue from limiting your fds variable to "Fields" only. However, you have a few other issues as well. Primarily, these lines are very confusing. fds = arcpy.mapping.ListLayers(mxd, "Fields", df)[0]
for fds in arcpy.mapping.ListLayers(fds): In the first line you assign your "Fields" layer to the fds variable. Then in the second line you create a new fds variable listing the layers in your fds variable. Try writing it a little cleaner using unique variable names.
... View more
10-15-2013
05:58 AM
|
0
|
0
|
2604
|
|
POST
|
You don't actually have to update each vertex according to the Café Python page.. http://arcpy.wordpress.com/page/2/ just update the SHAPE@XY token instead, then the whole feature moves. like :
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)]])
Cheers, Neil That makes it much easier, good find.
... View more
10-10-2013
07:22 AM
|
0
|
0
|
3828
|
|
POST
|
You are using updateRow incorrectly. That takes a row object, not the row values. Also, if you are updating a line feature you need to change each vertex value, which means will will need to access the geometry object and step through each one, modify it, add it to an array, then pass it back to a polyline object to be updated in the geometry object. Here's an example. import arcpy
rai = arcpy.mapping.ListLayers(mxd, "Railroads", df)[0]
EWmove = float(arcpy.GetParameter(0))
NSmove = float(arcpy.GetParameter(1))
update_cursor = arcpy.da.UpdateCursor(rai, 'SHAPE@')
for row in update_cursor:
array = arcpy.Array()
for part in row[0]:
for point in part:
point.X += EWmove
point.Y += NSmove
array.add(point)
new_line = arcpy.Polyline(array)
row[0] = new_line
update_cursor.updateRow(row)
del update_cursor
... View more
10-10-2013
06:35 AM
|
0
|
0
|
3828
|
|
POST
|
See reading and writing geometries using cursors. http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001v000000
... View more
10-09-2013
09:47 AM
|
0
|
0
|
3828
|
|
POST
|
& is used in VB usually, in python is has a different function that you are probably not interested in. Try this instead. def getclass(Value):
if Value >= 0 and Value <= 10:
return 1
elif Value >= 11 and Value <=20:
return 2
elif Value >= 21 and Value <= 40:
return 3
elif Value >= 41 and Value <=60:
return 4
elif Value >= 61 and Value <=100:
return 5
else:
return 6
You could also shorten it using this format. def getclass(Value):
if 0 <= Value <= 10:
return 1
elif 10 < Value <= 20:
return 2
elif 20 < Value <= 30:
return 3
elif 30 < Value <= 60:
return 4
elif 60 < Value <= 100:
return 5
else:
return 6
... View more
10-08-2013
12:06 PM
|
0
|
0
|
683
|
|
POST
|
extent is not a property of a layer object. Read through the doc here to find what you are looking for. http://resources.arcgis.com/en/help/main/10.1/index.html#/Layer/00s300000008000000/ Also, you cannot modify the extent of a layer in that manner, you will need to modify the geometry. Finally, how you are calling a layer object is actually returning the list of layers. You will need to reference an index in the same manner you do with the dataframe object to reference an individual layer object.
... View more
10-08-2013
11:58 AM
|
0
|
0
|
3828
|
|
POST
|
After you get your data from your source, I think the easiest next step would be to use an insert cursor. Either directly into your SDE feature class or into a temp in memory feature class to then upload to SDE. See the last example in this help page for inserting geometry. It is a little easier than depicted since you are only inserting point geometry. http://resources.arcgis.com/en/help/main/10.1/index.html#//018w0000000t000000
... View more
10-08-2013
06:24 AM
|
0
|
0
|
1661
|
|
POST
|
First of all, tooldataWorkspace is not a thing. Second, you need quotes around paths. Third, your path is mangled, there should be no colons after the drive letter. I assume you are looking for something like this. arcpy.env.workspace = ("C:/Temp/cab_homework_3_solution/Tooldata")
... View more
10-07-2013
12:23 PM
|
0
|
0
|
477
|
|
POST
|
This table "in_memory\table_sel" you create will persist until you close the instance it was created in.
... View more
09-25-2013
10:24 AM
|
0
|
0
|
1457
|
|
POST
|
I would find it more likely your log file is the issue. Try disabling logging and running it a few times to see if you get the same slow downs. Also, are you closing the instance of python this script is running in between executions? The in_memory workspace won't clear properly until you terminate the instance it was executed in or you clear it explicitly.
... View more
09-25-2013
09:58 AM
|
0
|
0
|
1457
|
|
POST
|
What version of ArcGIS are you using? Can you post the code you are running? Search Cursors are quite light and shouldn't be creating any additional files. Are you sure it isn't some other part of your code that is causing the issue?
... View more
09-25-2013
09:40 AM
|
0
|
0
|
1457
|
|
POST
|
just to be clear, my code was built with Service Pack 2 for ArcMap 10.1, so make sure you have installed Service Pack 2. Service pack 2? Did I miss a memo?
... View more
09-24-2013
07:04 AM
|
0
|
0
|
1357
|
|
POST
|
Are you getting this issue with just SDE or with a regular FGDB as well? Are you sure the SDE FC is editable?
... View more
09-18-2013
07:47 AM
|
0
|
0
|
1413
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-17-2011 10:36 AM | |
| 1 | 08-16-2012 10:48 AM | |
| 1 | 10-31-2012 08:39 AM | |
| 1 | 07-16-2012 01:52 PM | |
| 1 | 03-15-2012 10:57 AM |
| Online Status |
Offline
|
| Date Last Visited |
08-22-2024
11:12 PM
|