Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Hot answers tagged

8

By default the auto commit interval is set to 1000. You can change the interval using the following: arcpy.env.autoCommit = 5000


4

When querying the table of a versioned (or archive-enabled) feature class directly using SQL, your results would not be expected to reflect the current state of the feature class. You should use the versioned view instead. The table could contain records that have been deleted, or records that have been changed, or may be missing records that have been ...


3

I would solve the problem with NetworkX. It’s an Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks. It supports import and export of shapefile format. Install NetworkX in your ArcGIS Python environment: pip install networkx The following code should give you one possibility to solve your ...


2

Use arcpy.Clip_management() to clip a raster, not arcpy.Clip_analysis() which is for clipping a vector feature class. See: Clip (vector) documentation and: Clip (raster) documentation


2

Create a set and populate it with values using a cursor. If you find a value that's already in the set update your table. ids = set () with arcpy.da.UpdateCursor(layer.name, "ID") as outs: for idVal, in outs: if idVal in ids: row = ("",) outs.updateRow (row) continue ids.add (idVal)


2

There is a lot going on here, i hope this answer gives you a start 1. Your function doesn't return anything! Let's take out some unnecessary stuff, change it to return a list of paths for each mxd file (we'll save arcpy stuff for later). def ListMXDSources(path,extension): MapList = [] list_dir = os.listdir(path) for paths, dirctory, files in ...


2

Try This: import arcpy from arcpy import env mxd = arcpy.mapping.MapDocument("CURRENT") layers = arcpy.mapping.ListLayers(mxd) for layer in layers: lyr = layer desc = arcpy.Describe(layer) path1 = str(desc.path) + r"\outstat.dbf" env.workspace = desc.path arcpy.Statistics_analysis(lyr, path1, [["ID","COUNT"]], "ID")


2

It's probably because you're just appending "_l" to the feature class path , rather than inserting it. And when the feature class is a shapefile, you end up with "filepath.shp" + "_l" which == "filepath.shp_l" Try: import os.path import arcpy for fc in arcpy.ListFeatureClasses(): name, ext = os.path.splitext(fc) outfc = name + "_l" + ext arcpy....


2

You could use Result.GetMessage/GetMessages, instead of arcpy.GetMessage/GetMessages For example: import arcpy def log(result): # Last message print(result.getMessage(result.messageCount-1)) # Or all messages... # print(result.getMessages()) log(arcpy.SomeTool_toolbox(some_input)) log(arcpy.AnotherTool_toolbox(some_input))...


1

In your code error that you presented in the comment this is the line causing problems. fieldList = arcpy.ListFields(fc, field_type="integer") I think integer needs a capital I. But you don't use fieldList later. So you could either remove this line and just use fieldObs = arcpy.ListFields (fc) But the problem here is that you are getting fields that ...


1

I found that it worked much better to use the ExtractByMask option instead of the arcpy.Clip_management process. The corrected code is as follows: import arcpy from arcpy import env #Must use the arcpy.sa for this option# from arcpy.sa import * env.workspace = "C:\\workspace" env.overwriteOutput = True points = "PrecipKansas2014" #Check out extensions: ...


1

I guess you didn't install networkx in the ArcGIS Python environment you are currently using in ArcGIS. To be sure, that you choose the right enviromnent you should change the working Directory to the Scripts Folder of the right Python environment, before installing networkx via pip install networkx command. E.g.: ArcGIS Pro: cd C:\Program Files\ArcGIS\Pro\...


1

In addition to using the versioned view, consideration should be made for the length of the table name. In this case, I've discovered that if adding "_EVW" to the end of the table name exceeds 30 characters, an error will be thrown. I got around this with the following: test_tuple = ("path\to\connection", "OWNER.table_name") own, name = test_tuple[-1].split(...


Only top voted, non community-wiki answers of a minimum length are eligible