Tag Info

Hot answers tagged

4

You can't get this information as the Python script will block until the tool has finished running.


4

I am not sure if the following will not do the same thing as dissolve, but if I'm correct, it should not. You can use a SearchCursor() to loop through the polygons, get each polygon's geometry, add these as parts on a new polygon geometry object, and use an InsertCursor() to insert this new record. sc = arcpy.SearchCursor("c:/temp/fishnet2.shp") ic = ...


3

Environments aren't propagated from process to process, so changing extent in one won't affect the other at all.


2

No it is not possible to add "Folder Connections" using Arcpy. Folder Connections are stored in the ArcCatalog.gx file, which is typically located at c:\Users\*username*\AppData\Roaming\ESRI\*Desktopverion*\ArcCatalog\ArcCatalog.gx This is a binary file, so forget about editing it. The only thing you could possibly do is to create the Folder ...


2

Well I figured it out. I ran a repair geometry on the input polygon feature class. Problem solved. I should have tried that first!


2

Situations requiring edit sessions: Feature classes participating in a topology Feature classes participating in a geometric network Versioned datasets in ArcSDE geodatabases Some object and feature classes with class extensions I'd say you need to start an edit session, and save the edits before you do the append. The Editor class allows use of ...


2

It looks like you need to set a temporary alias on your toolbox (or a permanent one via its Properties) as described in the Help for ImportToolbox (arcpy): If the toolbox does not have an alias, the module_name is required. When a tool is accessed through the ArcPy site package, the toolbox alias where the tool is contained is a required suffix ...


2

I went with simply installing the manager pip-Win. It will install pip and virtualenv for you. Then it can identify your python installations (or you can browse to a specific python.exe to add more) and take care of all of your pip execution and package maintenance. https://sites.google.com/site/pydatalog/python/pip-for-windows Very important warning: ...


2

You might notice that when you manually change between Data View and Layout view, the scale changes. I would suggest changing to Layout view before you set the scale i.e. something like: mxd.activeView='PAGE_LAYOUT' df.zoomToSelectedFeatures(); df.scale = 2400.0


2

ListRasters will list the rasters in your workspace. ListLayers will list the rasters in a map document. rasters = arcpy.mapping.ListLayers(MXD, "", DF) for raster in rasters: #do work Use the wildcard argument to limit your results.


2

EDIT : I assume that you have a correct list of rasters, you can check this using print(raster) you need to save your raster at each iteration in order to persist it. Note that it is not necessary to use the mxd. outMeasurement = "PERCENT_RISE" zFactor = 1 arcpy.env.workspace = in_workspace #note that it is recommended to avoid spaces in your ...


2

Based on your variable, you just need to make sure variables and strings are not confused field_1="!field_name1!" field_2="!field_name2!" arcpy.CalculateField_management("Layer", field_0, field_1 + " / " + field_2, "PYTHON_9.3") note that if you have the strings as variables without the "!", it is nicer to use format() field_1="field_name1" ...


1

You are missing the wrapping exclamation marks, try this: arcpy.CalculateField_management("Layer", field_0, '!' + field_1 + '!/!' + field_2 + '!', "PYTHON_9.3")


1

You have embedded the string variable within a string so python sees it as a string. I would suggest you make you code something like: field_0="field_name0" calcString = "!field_name1! / !field_name2!" arcpy.CalculateField_management("Layer", field_0, calcString', "PYTHON_9.3")


1

Have a search in help for the subject "Performance tips for joining data" it offers advice on improving join performance. Your code does not indicate you have added an attribute index which can often improve performance.


1

there is a flipline tool, though it doesn't seem to allow queries on a feature. it may be that you can provide the tool with a feature layer based on the selected attributes. EDIT: As @JasonT mentioned, the flip tool should honor selections, so perhaps use make feature layer with a SQL clause on the features that should be flipped and pass that layer to ...


1

Got it figured out! Thanks to @Aaron's comments I was able to find a conversion: dMeanRatio2 = numpy.asscalar(dMeanRatio)


1

I'm not sure why, it must be some memory issue, but you need to use the full file path to the feature class you are creating the feature layer on. So for fcStops, put the full file path, not just the layer name from ArcMap. I tested it on my machine, and it failed with the same error when I used the layer in the TOC, but worked fine when I used the full ...


1

There is no guarantee that a model exported to Python will run without debugging and, depending on your model's complexity, that debugging effort could be considerable. I would wrap your model into a very short Python script that consists of little more than arcpy.ImportToolbox(). For example, if you have a TestModel (without an alias) in ...


1

As stated in the comments, the Con tool uses the '&' operator, not 'and'. Edit: to clarify, 'and' also worked up until ArcGIS 9.3 (map algebra operators).


1

The only types of layers you can add to an mxd with arcpy.mapping are map layers (layers in an mxd), and layer files (.lyr). A feature layer (in-memory layer) you create using the Make Feature Layer tool is not valid. In addition, Make Feature Layer doesn't accept topologies as input (a topology is a dataset, not a feature class). You can export a ...


1

An else on a for loop doesn't work like that. for row in theseRows: # do interesting work else: print "No rows found" will always print "No rows found" as long as no break was encountered in the for loop. A For on an empty list is still a non-breaking For. Something like this would work: flag = False for row in theseRows: flag = True # ...



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