|
POST
|
Do a Select By Attributes on the table in ArcMap, then copy that SQL syntax to your Python code.
... View more
10-19-2016
07:02 AM
|
1
|
1
|
2336
|
|
POST
|
#Variables
feature = r'...path to feature...'
field = "field"
field_set = set()
count = 0
with arcpy.da.UpdateCursor(feature, ['ACCT','group_code']) as cursor:
for row in cursor:
if row[0] not in field_set:
if str(row[1]) != "01":
field_set.add(row[0])
else:
count+=1
cursor.deleteRow()
arcpy.AddMessage('\n'+str(count) + ' duplicates removed from the ' + str(field) + ' field.\n') This script will delete a duplicated record of the 'ACCT' field, ONLY WHERE 'group_code' does not equal "01". Is this what you're looking to do? Also, I'm not sure about the highest value thing... that's tricky.
... View more
10-14-2016
07:14 AM
|
0
|
1
|
1550
|
|
POST
|
findAndReplaceWorkspacePath() not findAndReplaceWorkspacePaths()... No 's' on Path
... View more
10-13-2016
01:05 PM
|
1
|
2
|
1592
|
|
POST
|
I built a similar tool that deletes duplicate geometries. It looks a little like this: #Variables
feature = r'...path to feature...'
field = "field"
field_set = set()
count = 0
with arcpy.da.UpdateCursor(feature, [field]) as cursor:
for row in cursor:
if row[0] not in field_set:
field_set.add(row[0])
else:
count+=1
cursor.deleteRow()
arcpy.AddMessage('\n'+str(count) + ' duplicates removed from the ' + str(field) + ' field.\n') I haven't tested it on a field duplicate, only the 'SHAPE@XY' token. But, I successfully got it to work with the geometries.
... View more
10-13-2016
12:06 PM
|
2
|
3
|
1550
|
|
POST
|
For 2, if by template you mean schema, there is a way to do this in a geodatabase. See here : Exporting a geodatabase schema to an XML workspace document—ArcGIS Help | ArcGIS for Desktop. Then, you can import the XML document to a database and load data into it.
... View more
10-13-2016
08:10 AM
|
1
|
1
|
902
|
|
POST
|
Did you try searching through the Geoprocessing > Result window?
... View more
10-10-2016
08:15 PM
|
0
|
1
|
1223
|
|
POST
|
I'd like to create a SQL query statement which can select by multiple items in a Python string. Can this be done? lyr = r''
my_list = ['12','13','14','15']
for i in my_list:
qry = "OBJECTID" + i
arcpy.SelectLayerByAttribute_management(lyr, qry) The problem I'm having is formatting the list properly so it won't trip up the SQL statement. Should I create a new list with the items separated by a "+" character?
... View more
10-10-2016
12:53 PM
|
0
|
3
|
14800
|
|
POST
|
So, the source feature and the target feature do not share any unique IDs? The only relationship that these have are spatial?
... View more
10-06-2016
08:00 AM
|
0
|
2
|
2353
|
|
POST
|
So, are you trying to read through the CSV and get the date from different fields? Can you show the fields?
... View more
10-04-2016
12:01 PM
|
1
|
1
|
4251
|
|
POST
|
Shouldn't this: cursor = arcpy.da.InsertCursor (fc...) Be this: cursor = arcpy.InsertCursor (fc...) Drop the 'da'? brittney.white.ucf
... View more
10-04-2016
10:30 AM
|
0
|
10
|
1920
|
|
POST
|
Jay, Don't forget the '@' in the SHAPE@XY. Please format it like this: ... (csv, ["SHAPE@XY", "Date", "Field_1", "Field_2"]) as cursor Each field is exasperated by quotations, not brackets. ArcPy reads the geometries stored in the feature without them being an actual attribute. Please read Brittany White's response above for a more in depth look into the InserCursor function and the SHAPE@XY token.
... View more
10-03-2016
12:04 PM
|
0
|
20
|
3089
|
|
POST
|
All, I finally got the script to successfully run thanks to all the kind people in this community. Below is the final code. Dan Patterson is there a way to mark several people's replies as the correct answer? This seems like it was a team effort since everyone contributed to the overall answer. import arcpy
#Get input from user
feederID = arcpy.GetParameterAsText(0)
ischecked = arcpy.GetParameterAsText(1)
#Variables
mxd = arcpy.mapping.MapDocument("CURRENT")
field = "FEEDERID"
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.isFeatureLayer:
fields = arcpy.Describe(lyr).fields
for f in fields:
if f.Name == field:
delim = arcpy.AddFieldDelimiters(lyr,field)
lyr.definitionQuery = delim + "='" + feederID + "'"
#Clear definition query
if ischecked == 'true':
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.isFeatureLayer:
lyr.definitionQuery = ""
arcpy.RefreshActiveView()
... View more
10-03-2016
09:41 AM
|
1
|
1
|
756
|
|
POST
|
I actually figured out the issue. I believe it was because I had layers in the MXD with broken data sources. Thank you!!
... View more
10-03-2016
09:38 AM
|
1
|
0
|
756
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-28-2024 11:43 AM | |
| 1 | 09-12-2025 07:32 AM | |
| 1 | 10-26-2018 06:50 AM | |
| 1 | 10-26-2018 08:43 AM | |
| 1 | 02-25-2016 07:50 PM |
| Online Status |
Offline
|
| Date Last Visited |
12-02-2025
01:10 PM
|