A site-package created by Esri to expose ArcObjects to Python.

learn more… | top users | synonyms (1)

2
votes
1answer
689 views

ArcGIS ArcPy: Iterate over shapefiles and report field “Desc” Length

I've just started learning to script using python, i.e. no programming experience. I need to iterate over a folder that contains multiple shapefiles that all start with nlc... I need to iterate over ...
2
votes
2answers
690 views

rename feature layer fields

Guys and gals could you please provide me with a sample code as to how to rename a field name in a Feature Layer or Table. I've been trying to use the FieldInfo object to do so over the last couple ...
2
votes
1answer
192 views

Convert a List to a file list to use in an arcpy tool

I just can't figure out how to feed a list of files into an arcpy tool... I have List_tif.append(os.getcwd()+"\\Stage1\\"+name+"\\GeoTif\\"+name+"_"+str(ddp.pageRow.PageName) + ".tif;") That ...
2
votes
4answers
330 views

What is causing syntax error in arcpy NetCDF Raster script

I'm trying to save the raster layer in the stand-alone python GUI but I keep getting a syntax error. I'm using the code from Save To Layer File (Data Management). And the error that shows up is: the ...
2
votes
2answers
663 views

Delete all fields from feature class with arcpy

I want to delete all of the fields from a feature class in a simple tricky way, I don't want to loop over the fields because this method is very slow in arcpy. I'm using a polygon feature class, I ...
2
votes
1answer
147 views

Import 3D Analyst Functions With ArcPy

This really seems like I should be able to do this, but I am running into some problems. I want to import 3D Analyst with python, in the same way I import Spatial Analyst, but it returns an error. ...
2
votes
1answer
125 views

Importing arcpy on application launch to speed up subsequent arcpy methods

Is there a way of importing arcpy during the launch of my custom built application so that any usage of arcpy methods after the fact won't require the 3-4 seconds that it takes to import the arcpy ...
2
votes
2answers
2k views

How to reference a specific layer in a dataframe with Arcpy

I am trying to reference a Layer named "Tim" in the dataframe "Layers" in my .mxd. It is not working. I have looked at the ArcGIS online help and all else in this forum. Can't get rid of this Runtime ...
2
votes
1answer
1k views

Unable to change data source path for group layer file

I am having some difficulty changing the data source for a group layer. Below is the code that I am using. It processes a LYR file successfully that has a single data source but if LYR file has more ...
2
votes
2answers
513 views

Zoom to Selected feature, without using 'current' in python

I am wondering if it is possible to build a zoom to geoprocessing service without using 'current' for the mxd variable in pyhton. Using 'current' my tool works in arcmap, but not in my gp service. ...
2
votes
1answer
105 views

How to write infinity to a feature class in arcpy?

Is it possible to write infinities to fields in arc feature classes, and if so, how? Currently I get an exception thrown when I try.
2
votes
2answers
398 views

Tables in ArcMap 10.0 - are they layers or tableviews

Is a table in ArcMap a layer or a tableview. I want to be able to feed a table into an UpdateCursor via a toolbox script. If my table has a definition query on it how do I check for that with ...
2
votes
1answer
521 views

ArcPy - Dataframe rotation - Getting a polyline length wise in the dataframe in layout view in ArcMap

EDITED: I'd like to rotate my dataframe until a polyline fits dataframe-width wise in the layout view of a .mxd. If the lines runs north/south I would like the dataframe rotated until the line is ...
2
votes
1answer
167 views

Using ArcPy to fetch Information from a .GDB

I am new to GIS and I would appreciate if you could guide me a little. I have a .gdb folder with data and I need to process that data to find educational institutions which are within say X Km of the ...
2
votes
1answer
325 views

stratigraphic ranking with field calculator?

I would like to populate a feature class float attribute with a numerical ranking of a text attribute of a geologic map. I have a field named [sheet_unit] with strings such as "H10, Q" and "J10, Pl" ...
2
votes
1answer
42 views

Table analog of MakeQueryLayer

As of 10.1, arcpy provides the rather handy MakeQueryLayer function. This allows us to use arcpy to create query layers programmatically instead of having to go through MXDs (as was the case in 10.0). ...
2
votes
1answer
56 views

Using Arc 10.0 update cursor to replace <Null> value

I have been combing the help associated with (None) values in arc, and have not been able to solve the following problem: I have a a field with mixed Null and integer values: 0 100 I would like ...
2
votes
2answers
51 views

python add fields that may have NULL values

I would like to use python to calculate a field (short integer) using other fields (short integer) present in the table. In some cases these fields may have NULL values for one or more of the fields. ...
2
votes
1answer
41 views

Arcpy Calculate Field Formatting Syntax

I am trying to field calculate a double field (PID) to a new string field (PIN). Using: qry = '"139-{}".format(!PID!)' arcpy.CalculateField_management(out, "PIN", qry, "PYTHON") Given a PID = ...
2
votes
1answer
97 views

How to do a separate Python installation with ArcGIS?

I see a lot of threads asking how you can have a separate Python installation (e.g. the Anaconda or Python XY distribution) and get it to work with arcpy, while not 'breaking' ArcGIS at the same time. ...
2
votes
1answer
63 views

SQL expression to python expression

I have a SQL expression that I use in Make Feature Layer in Model Builder ("HOSPITAL" = '% HOSPITALNAME%'). The expression makes a selection in a OD Cost Matrix that a patient is patient only at one ...
2
votes
1answer
134 views

How to get arcpy.AddMessage() to display a message from a script tool called from another script tool?

I am using a python script tool within an ArcToolbox in ArcGIS 10.2. The script calls another python script tool while running but does not display the messages from the called script when using ...
2
votes
1answer
62 views

*.lyr to *.style conversion in ArcGIS

Do you know how it's possible to convert a layer symbology or an *.Lyr file to an *.style file? Thanks, Jérôme
2
votes
2answers
83 views

Python Def Query Help for multiple layers

I have Three layers in a .mxd, all three layers have a common value I can use, but a different Label in each Layer. As an example, the Value I want to use is "100" In Layer A, the Value is in [Name] ...
2
votes
1answer
75 views

How to get Network Analyst data from script file back into Model Builder?

I am running a script which takes some input parameters and runs some Network Analyst processes. The script is imported into a toolbox and is setup in Model Builder with the necessary input and output ...
2
votes
1answer
79 views

Why does arcpy.ListFields list GUID field as SmallInteger?

I want to get a list of all GUID fields in a feature class, but it seems that arcpy.ListFields is listing my GUID field as a SmallInteger. What am I doing wrong? global_id_fieldnames = [f.name for f ...
2
votes
2answers
89 views

How to define workspace as input for GP tool in order to select from list CAD layers as the second input?

How to define workspace (folder) as input for gp tool in order to select CAD layers as the second input that will be obtained from the first input?
2
votes
1answer
288 views

ArcPy findAndReplaceWorkspacePath not working with Raster Datasets

Situation: I am working on creating a Python script that will replace workspace paths for every layer in a map document in order to fix broken layers after a data migration. The script works except ...
2
votes
1answer
98 views

ArcGIS 10.2 Copy Rows error

I'm very confused by this one. I have run a polygon neighbors analysis in ArcGIS 10.2 and appended some data from another table to help me whittle down the neighbors list before my next action. So I ...
2
votes
2answers
167 views

How to add values in X column to dictionary or list using ArcPy?

My apologies if this question has been asked before. I've spent some time searching for a similar question with no results. Is it possible to add each value under X column to a list using ArcPy? I ...
2
votes
3answers
218 views

How to release locks to temp files after ArcPy script crashes in ArcMap?

Sometimes when I'm testing an ArcPy script and it ends with exception, ArcMap is still holding locks to some temp files (I run my scripts through ArcMap). I cannot run the script any more, because it ...
2
votes
1answer
63 views

Is it possible to display two categorical symbolizes for two different attributes in one layer alongside each other in ArcMAP 10.1?

I have a road layer that I would like to display attribute_1 = "speed" on top of the line segment and attribute_2 = "traffic_volume" below the line segment. For each attribute I would like to setup ...
2
votes
1answer
57 views

How to reference path to file that is in edit session from Python AddIn?

I am creating a Python addin button and I would like to reference the path to the layer that is currently in an edit session to the code in the addin button. This way users will be able to use the ...
2
votes
1answer
237 views

How do I get the coordinates of my data frame always in long/lat?

I want to determine the coordinates of my current data frame. To do so I wrote this script: def DataFrame (): mxd = arcpy.mapping.MapDocument("CURRENT") df = ...
2
votes
1answer
202 views

Trouble formatting SQL expression for where clause in “Search layer by attribute” arcpy function

I am trying to pass a variable into a where clause in the "Search Layer by Attribute" arcpy function. I cannot seem to figure out the correct format for the SQL expression so that the function reads ...
2
votes
2answers
96 views

Determine ArcCatalog's currrently selected folder using Python

Is there a way to get the current directory opened in ArcCatalog 10.0 using Python? Something like os.getcwd() but instead gives the selected folder on the catalog tree. Cheers
2
votes
2answers
240 views

How can I perform an inside clip on a raster file based on another raster file?

I have a raster file that I would like to use to perform an inside clip on another raster file. I have tried using the extract by rectangle tool, but it gives me values ranging from 3.40282e+038 to ...
2
votes
1answer
264 views

How to replicate an unversioned SDE geodatabase to a file geodatabase?

I need to implement a process for creating a file geodatabase copy (a read-only snapshot, essentially) of a production SDE geodatabase without using versioning, adding global ID columns, etc. I cannot ...
2
votes
2answers
177 views

Create line from two points, two different feature class

I'm attempting to automate this in ModelBuilder in ArcMap. I have one feature class with one point (Start) and one feature class with multiple points (Destinations). I want to iterate through the ...
2
votes
1answer
637 views

How to save currently opened mxd and changes using ArcPy and Python?

Here is what I have so far... import arcpy import arcpy.mapping as map mxd = map.MapDocument() mxd.save() And yes I know that map.MapDocument requires an argument, but I want it to automatically ...
2
votes
1answer
248 views

Arcpy: Troubleshooting parameter error for Export Report

I'm running into what I believe is a parameter error in writing an arcpy exporttoreport script. I've written several successful scripts of this same type, but the difference is that this one has a ...
2
votes
1answer
181 views

Why do no Labels appear on .pdf output from ArcPy when turned on in Layout?

Do labels needed to be coded into an arcpy script in order to be visible on an arcpy .pdf output? In ArcGIS the labels are visible for various features, but when I use the arcpy script (either in IDLE ...
2
votes
1answer
314 views

Error 999998 in Arcpy 10.1

I found an RuntimeError: ERROR 999998: Unexpected Error when lunching Arcpy in my ArcGis 10.1 such as this: Runtime error Traceback (most recent call last): File "", line 50, in File ...
2
votes
1answer
626 views

Python - read shapefile .dbf for encoding

I've written a python script that formats a .shp such that its fields structure matches my office's database view in order to ingest the data of said shapefile. This original shapefile was encoded ...
2
votes
1answer
175 views

Difficulty converting standalone script to ArcGIS tool

As my title says, I am currently trying to make my (working) standalone script into an ArcGIS tool so I'm not the only person in my office that can use it. It essentially selects all the data within ...
2
votes
1answer
124 views

Import only necessary arcpy modules?

I'm working on a standalone script where I need to import arcpy. This usually takes close to 10 seconds, which is a little more than ideal. I'm only using a few Data Management tools and some base ...
2
votes
1answer
306 views

How to use ArcPy cursor to define each feature sequentially as current selection of layer?

I want to implement a script that runs through each feature of a feature class, zooms to the extent of the feature, sets the scale to 1:5.000 and adjacent takes a picture of the scene. The steps are ...
2
votes
1answer
393 views

How to use arcpy.mapping to batch export layer to KML?

I am trying to export map layers from an MXD to KML using arcpy with the following code: import arcpy, os, sys, traceback arcpy.env.overwriteOutput = True mxd = ...
2
votes
3answers
462 views

arcpy: get list of adjacent lines per line

I am working with polylines with hundreds of thousands of features, and would like to write a script that returns the OIDs of all lines adjacent (intersecting with) each line. I have been ...
2
votes
1answer
300 views

arcpy.AddMessage and codepage problems

Some times in my tools I need to output Cyrillic text via arcpy.AddMessage function. Previously in 10.0 it was very easy. I had .py file of the tool saved in UTF8 codepage. This code wrote messages ...