Emil Brundage
  • Member for 7 years, 5 months
  • Last seen this week
Combining ListDatasets and ListFields to return geodatabase contents to CSV--one script prints attributes and another returns feature class counts
Accepted answer
0 votes

In your first script fc is your feature class. After for fc in arcpy.ListFeatureClasses('*','',fds): add your ListFields script. import arcpy arcpy.env.workspace = "C:\Users\Redfish\Test.sde\Test....

View answer
Checking feature overlap using ArcPy cursors
Accepted answer
3 votes

One potential issue: Your two geometries must be in the same spatial reference, so check this. More importantly: You want to use geometry.overlaps instead of geometry.touches. list_tif = [] sr = ...

View answer
Variable Buffer on Street Centerline using ArcMap
1 votes

This is a process that is best done through automation, and an advanced license helps. The basic work flow: Divide your lines up for by their categories. For each category: Select lines within ...

View answer
Creating WHERE clause from list using ArcPy
Accepted answer
6 votes

You're using AND when you should be using OR. A value can't equal all the values in field_names. 5, as an example, can't equal 5 AND 7 AND 3 AND 23 AND... I like to make a string out of my list of ...

View answer
For loop with SearchCursor stops after first iteration
1 votes

It looks like you have arcpy.env.overwriteOutput set to True. With each iteration you are copying over whatever you have ExportBuffer set as. Currently you have a single feature class that's been ...

View answer
ArcPy Iterative Select by Location
1 votes

Make use of a spatial join instead of selecting each feature one at a time. This will give you a table with your main fields and your service fields based on the indicated spatial relationship. This ...

View answer
Update row based on order of parameter
1 votes

The field name ("AccountNo") needs to be in your cursor field inputs. Something like this: for fc in arcpy.ListFeatureClasses("Comps"): arcpy.AddField_management(fc, "Comp_Num", "TEXT", ...

View answer
UpdateCursor not deleting Null row
Accepted answer
2 votes

" " is a string with a single space. None indicates a null value. You have a couple options: if not row[3]: ##returns true if row[3] is "", None, 0, []... cursor.deleteRow() or: if row[3] =...

View answer
ApplySymbologyFromLayer on ArcGIS Pro not working?
Accepted answer
2 votes

After changing the layer symbology you need to save the project. aprx.save ()

View answer
ArcMap closing when running ArcPy script?
Accepted answer
3 votes

Update your environmental settings so that outputs aren't added to your map. arcpy.env.addOutputsToMap = False

View answer
Simple UpdateCursor onto new field
Accepted answer
1 votes

As mentioned in the comments make use of a data access cursor. Use the two status fields as your field input and perform an if logic check. with arcpy.da.UpdateCursor(FC, ["Status1", "Status2"]) as ...

View answer
Defining variable for output location based on feature class attribute?
1 votes

You can iterate through your muni feature class with the search cursor and select points by its geometry. The tricky part is creating the proper geodatabases and datasets. Check for gdb existence with ...

View answer
Selecting Deficient Water Mains
Accepted answer
2 votes

Given: We want the 3 inch pipe. Basic work flow: Dissolve tool by diameter to connect segments. Spatial join dissolved lines to themselves, one to many. Keep your diameter fields. Copy/Paste ...

View answer
Taking substring of one field and using value to field calculate or update cursor another in ArcPy?
Accepted answer
3 votes

Make use of regular expressions to find your number. .split () won't work for numbers like #1234567 because of the pound symbol. Also you only need to iterate your cursor once. import re import arcpy ...

View answer
Performing Point Distance analysis using Basic level license of ArcGIS Desktop?
1 votes

Using arcpy geometry objects is a good way to determine distances between features. Use data access cursors to access a feature's geometry and the method angleAndDistanceTo to determine distances. ...

View answer
Optimizing slow multi cursor approach?
Accepted answer
0 votes

You're making use of cursors within cursors, as well as appling sql queries to those cursor which can slow down the process exponentially. Your dissolve also appears to be unnecessary as it appears to ...

View answer
Deleting Picture Element using ArcPy in ArcGIS 10.3 Desktop?
Accepted answer
1 votes

It appears you cannot add or remove picture elements using ArcPy. If it's acceptable you can use a work around and set the element height to 0. pict = arcpy.mapping.ListLayoutElements(mxd, "...

View answer
Check in all tables in database if two fields are not null, with ArcPy?
1 votes

@BERA has a good answer but it can be made more efficient by skipping the creation of lists and by breaking the iteration of the cursor if a value is found. import arcpy arcpy.env.workspace = "C:/...

View answer
ArcPy UpdateCursor fails when adding a transform to SHAPE@XY due to type error
Accepted answer
3 votes

You have features in your feature class without geometry. "SHAPE@XY" returns (None, None) when a feature has no geometry. As @MarceloVilla suggested, you can print out the OBJECTID of the features ...

View answer
Using variable (input parameter) as out_name to create feature class?
2 votes

From the comments it's clear that the issue is bad characters in your output name. I recommend using ValidateTableName to ensure your inputs won't throw the exception. newFc = arcpy.ValidateTableName ...

View answer
ArcGIS geoprocessing DomainToTable_Management script crashing
Accepted answer
1 votes

I'd make use of Validate Table Name and GISPro's Alter Domain. You can alter your domain names using Validate Table Name to remove spaces. Untested since I don't have ArcGIS Pro: inGdb = r"Domained\...

View answer
Get list of editable fields while also adding 'SHAPE@' to the end
Accepted answer
5 votes

Here's an easy way: fields = arcpy.ListFields('//path/to/layer') flds = [f.name for f in fields if f.editable and f.type != "Geometry"] + ["SHAPE@"]

View answer
arcpy.SelectLayerByAttribute_management ExecuteError
Accepted answer
1 votes

In your code Polygon_Neighbors is a table. You'll need a table view to perform your selection. Polygon_Neighbors_tv = arcpy.MakeTableView_management (Polygon_Neighbors, "Polygon_Neighbors_tv") [0] # ...

View answer
Creating multi-attribute primary key in table in ArcGIS Desktop
4 votes

You can use your field calculator for this. Add a new text field to your table that will be your key field. Right-click on its field name in the attribute table and choose Field Calculator... Use [...

View answer
Delete layer created during Buffer_analysis
1 votes

Instead of name, go with the layer's catalogPath property. This will return the full path of the layer's feature class. If outPath is the full path of the buffer output: for layer in layerList: ...

View answer
Updating gdb with JSON?
Accepted answer
2 votes

You need to specify an output feature class. parcelsFC = os.path.join('temp.gdb',JsonDirectoryLocation) outFc = os.path.join ("temp.gdb", "JsonFeatures") arcpy.JSONToFeatures_conversion(parcelsFC, ...

View answer
Using SearchCursor and ArcPy to add message?
3 votes

sys.exit (1) ends the script. Get rid of this line. with arcpy.da.SearchCursor(MapUnitPolys, ['SHAPE@', 'MapUnit', 'OBJECTID']) as cursor: for row in cursor: #arcpy.AddMessage(str(row[1]))...

View answer
Deriving field parameter from table parameter in Python Toolbox?
Accepted answer
2 votes

My input field parameter needed to be type GPString instead of Field. lkLkTab = arcpy.Parameter ( displayName = "Leak Excel Worksheet Leak Field", name = "lkLkFld", datatype = ...

View answer
Performing a 'far analysis' using ArcGIS for Desktop?
0 votes

I've created a python toolbox which performs a far analysis as described above. Inputs: Input Feature Class - The input feature class Far Feature Class - The feature class with far feature ...

View answer
Selecting multiple attributes with variables using arcpy
3 votes

Your or is outside your string. expression = """ "LINE_NUM_1" = '""" + line_val1 + "' or "\"LINE_NUM_1\" = '" + line_val2 + "'" I like using IN and format, myself. """"LINE_NUM_1" IN ('{}', '{}')"""...

View answer
1
2
3 4 5
14