|
POST
|
Like Dan said, you should use = instead of ==. import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name == "waste":
lyr.definitionQuery = "Code = 'IT1300021'"
arcpy.RefreshActiveView()
... View more
04-28-2017
10:45 AM
|
0
|
0
|
3595
|
|
POST
|
You could have a script write a comment to a text field that are duplicates, then append records that do not have a comment. import arcpy
shp1 = r'...path to shapefile1...'
shp2 = r'...path to shapefile2...'
shp1keys = []
#Field arguments is the common field between both datasets
with arcpy.da.SearchCursor(shp1, ['field_with_dups']) as cursor:
for row in cursor:
shp1keys.append(row[0])
del cursor
#Field arguments with common field plus 'Comment' field to write duplicates
with arcpy.da.UpdateCursor(shp2, ['field_with_dups', 'Comment']) as cursor:
for row in cursor:
if row[0] in shp1keys:
row[1] = 'DUPLICATE'
cursor.updateRow(row)
del cursor
... View more
03-27-2017
07:44 AM
|
0
|
7
|
2919
|
|
POST
|
Can you please post your Python code in the code syntax highlighter.
... View more
03-23-2017
12:19 PM
|
0
|
0
|
1866
|
|
POST
|
Arcpy has a cool function that does this called replaceDataSource. Check here: Layer—Help | ArcGIS for Desktop
... View more
03-07-2017
10:05 AM
|
2
|
0
|
4988
|
|
POST
|
All, I was wondering if anyone had any useful GitHub repositories pertaining to Python for ArcGIS. Are there any ones you use a lot? What are some of your favorites? I have attached a link to my repository. mitchh300 / Repositories · GitHub Thanks!
... View more
03-03-2017
08:14 AM
|
1
|
4
|
2086
|
|
POST
|
This could be done in Python. Try running this before you run the merge. import arcpy
import os
SHPfolder = r'...path to folder where .shps are kept...'
for x in os.listdir(SHPfolder):
with arcpy.da.UpdateCursor(SHPfolder + '/' + x, ['shpName']) as cursor: #Change field name if necessary
for row in cursor:
row[0] = str(x)
cursor.updateRow(row)
del cursor
... View more
03-01-2017
08:16 AM
|
1
|
0
|
10043
|
|
POST
|
Can you duplicate that selection in the Python GUI in that MXD without error?
... View more
02-27-2017
02:18 PM
|
0
|
0
|
2362
|
|
POST
|
Is there a reason you're using "SUBSET_SELECTION" selection method on that table? Does the user select records prior to running this tool? Also, I would make that layer a single variable in the tool. Right now the variable 'lyr' is assigned to an arcpy function of ListTableViews.
... View more
02-27-2017
01:56 PM
|
0
|
2
|
2362
|
|
POST
|
Is the "ArcGIDSDE.SDE.Detention_Basic_Inspection" a single layer in the MXD?
... View more
02-27-2017
01:13 PM
|
0
|
4
|
2362
|
|
POST
|
I would create an X and Y field in the featureclass. Then calculate geometry for those fields. From there, you can get an address.
... View more
02-23-2017
12:34 PM
|
0
|
0
|
4014
|
|
POST
|
Then what is your goal? It seems like Map3 is what you're looking for.
... View more
02-21-2017
09:30 PM
|
0
|
0
|
1341
|
|
POST
|
Sounds like you want to build an Add-In. What is a Python add-in?—Help | ArcGIS Desktop You can import a Python script and control functions based on user mouse clicks or keyboard commands.
... View more
02-21-2017
07:20 AM
|
0
|
0
|
1579
|
| 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
|