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

learn more… | top users | synonyms (1)

3
votes
5answers
7k views

Renaming field using ArcPy?

What I need to do: rename a field name of a table/feature class copy all values to the new field So far I have done following code as @artwork21 suggests: import sys import traceback import arcpy ...
3
votes
4answers
201 views

Removing first and third zeros of a fieldname in label expression

The fieldname only has three characters. I dont want to display zeros in the first and third values. example below. 010 = 1 100 = 10 01Y = 1Y 10Y = 10Y I have figured out how to strip out zeros ...
3
votes
4answers
338 views

Having trouble with 'and' 'or' statements and negative numbers

I have set up a program that calculates the relationship between a point and the first point of a polyline. The aim of the program is to run this calculation and then copy the result to a certain ...
3
votes
3answers
277 views

Clipping faster (i.e. in bulk/batch) in ArcGIS for Desktop?

I have 100 different input vector layers and one clip feature vector layer. I have to clip them 100 times but its a large amount of work. Is there any Python script (ArcPy) in ArcGIS for Desktop ...
3
votes
4answers
1k views

ArcMap 10.0 Python script tool - Have the script tool dialog box stay open past successful completion of script

Is there a way to have the script dialog box have the radio button that says "Close this dialog when completed successfully" unchecked for any user who runs the script tool? Is there configuration ...
3
votes
3answers
193 views

Is there a better way to compare lists in arcpy?

I simply want to create a script which compares a list with the field names of a featureclass and if the fields do not exist in the featureclass add them. My code works, but is very inefficient. How ...
3
votes
4answers
512 views

How to get values of last row in table with ArcPy/SearchCursor?

I would like to base my query on the last row of a table? I know the basic syntax/functionality for my search cursor, how do I query only the last row; Below is an example of my search criteria, ...
3
votes
3answers
2k views

SearchCursor() fails to read feature class

First of all, I would like to apologize if this problem is trivial for you guys since I am very new to ArcPy and Python in general. I want write a script to read attribute table from a feature class ...
3
votes
4answers
505 views

Is there anything faster than cursor in ArcGIS Desktop to calculate records?

What is the most efficient (fastest) way to calculate records in a layer in ArcGIS? Is there anything faster than the Cursor in ArcGIS?
3
votes
5answers
3k views

Adding Raster Layer without lyr file using ArcPy?

i wonder how i can add a raster layer to a remote (not the current) mxd file with arcpy. I need to not use a lyr file for that. For vector Layer i have the following lines working fine : mxdPath = ...
3
votes
3answers
524 views

Sorting polygons by latitude?

We have a set of polygons which we would like to sort and number according to their latitude. This will make it easier for local authorities to relate to the numbers of the objects. I have looked ...
3
votes
4answers
2k views

Arcpy: Calculate new field from user input and existing data

Can't seem to figure out what is wrong with this create fields from a calculation. The code creates the new field in the shapefile as selected by the user but I keep getting a 9999 error on every ...
3
votes
2answers
442 views

How to use Vector Ruggedness Measure (VRM) tool from ArcScripts at latest version of ArcGIS for Desktop?

I need to use the Vector ruggedness measure (VRM) tool available from http://arcscripts.esri.com/details.asp?dbid=15423. However, I am using ArcGIS 10.2 for Desktop and these tools are made for 9.0, ...
3
votes
3answers
236 views

How to convert Midpoint of Polyline into Point Feature using ArcPy?

I am trying to write a python script to determine flow direction on a water pipe network. I've used this script to find the mid point along each polyline, now i need to convert this data into a point ...
3
votes
5answers
768 views

Can ArcPy's AsShape be used with GeoJSON FeatureCollection of Polygons with Labels?

The AsShape documentation provides examples that work very well. However, I have been given what I believe to be valid GeoJSON that is a FeatureCollection of two polygons each with a Label. It ...
3
votes
3answers
99 views

Using boolean parameters in Python Script Tool of ArcPy?

I'm using ArcGIS for Desktop 10.3.0.4322 I have a script tool which requires a parameter (folder path to a gdB, via GetParameterAsText) so that a later process can be saved there. The thing I want to ...
3
votes
1answer
536 views

How to change value of an individual pixel using arcpy?

I want to change the value of an individual pixel in a raster using arcpy. The code I wrote for changing the value is below, but it changes all of pixels in my raster. How can I set an individual ...
3
votes
1answer
2k views

How to turn off layers in ArcMap via arcpy?

I'm working on a script in ArcMap 10.1 that takes a screenshot and I need to know how to extinguish (turn off) a layer in my table of contents.
3
votes
2answers
203 views

Using PyQGIS, ArcPy, NumPy, SciPy Together in Windows Command Prompt

I ran across this slight issue when I was looking to access python installations from ArcGIS, QGIS, Anaconda (cited because SciPy & NumPy come with it), and version 2.7 vs 3. Sometimes, I find it ...
3
votes
2answers
96 views

Arcpy to get ArcGIS Application Data folder (My Toolboxes folder)

Is there a way (enviromental variable) in arcpy to get access to ArcGIS Desktop AppData Per User folder. For example I need to access this folder for arcgis 10.2: ...
3
votes
2answers
2k views

Python script to export .csv tables from GDB

I am very new to Python programming and have been tasked with writing a program to export a csv file from a file geodatabase feature class. The csv should contain only certain fields and the records ...
3
votes
2answers
530 views

ArcGIS Python - Convert feature class names to lower case

Can anybody anyone point me to directions on how to convert file geodatabase feature class names to lower case by using python? Thanks
3
votes
1answer
105 views

How to find number of fields in shapefile using Python?

I've been looking at the ArcGIS resources for python but I can't seem to figure this one out. I'm looking for a method to gain access to the number of fields that are within a shapefile / feature ...
3
votes
3answers
608 views

How does one replace characters in a layer name using Python (“_” with “ ”)? [closed]

I can rename layers easily enough, but I really need to replace any "_" with a " ". This code just renames layers, but I would like to do a find and replace on each layer name mxd = ...
3
votes
2answers
2k views

How to select specific filenames nested within several folders?

I have hundreds of shapefiles that are stored in separate folders, which are nested within several other folders. Among the shapefiles I only need the ones that are named 'POINT*.shp' How do I get ...
3
votes
3answers
871 views

Runtime error : ERROR 000358: Invalid expression using SelectLayerByAttribute in ArcPy?

I cannot for the life of me persuade SelectLayerByAttribute to work (I need to automate this for a complex script). Working in ArcMap's python console on already loaded shapefile, the format below: ...
3
votes
3answers
4k views

how to get ALL FIELD NAMES from table? (using arcpy.ListFields)

I have a table: , Script at ModelBuilder's "calculate values": Expression: a("%path%") Code BLOCK: def a(path): fields = arcpy.ListFields(path,"FID_*") for field in fields: return ...
3
votes
1answer
2k views

Writing Python script to give multiple buffers of different sizes in ArcGIS for Desktop?

I want to write a loop that will cause the output to be multiple buffer shapefiles. For example, I want a circle buffer of 50ft, 100ft, 150ft, etc. Can anyone help? I'm new to this and am trying ...
3
votes
3answers
110 views

Using Python to count records and show difference

I'm trying to find an example of a python script for ArcGIS 10.1 that will get count of a FC in my SDE and get count of a FC in an incoming FGDB update and then write the difference to a log file. We ...
3
votes
2answers
161 views

Calculate Field Syntax: If statement over many fields

Apologies if this has already being asked but I couldn't find a page pointing to this problem. I'm struggling with the python syntax in the Calculate Field so that, in the table above: if b, c, d, ...
3
votes
3answers
701 views

ArcPy nested loop problem

I have a question connected with ArcPy. I was trying to make a nested loop with 2 cursors - 1st with 2 elements and 2nd with 5 elements. The statement should return 10 connections, e.g. 1-1, 1-2, ... ...
3
votes
2answers
709 views

Using ArcScripts

I use ArcGIS 10 I want to use an arcscript to compute an index of ruggedness for each cell of my map. For this purpose, I found, Evan's TRI.aml script here: ...
3
votes
2answers
308 views

Process every 100 records in list

An arcpy merge process is failing due to the size of the datasets and I need to just merge every 100 tiles before it goes on to the next 100 tiles. I wrote the following snippet but it is just ...
3
votes
1answer
480 views

Converting string from GetParameterAsText to uppercase?

I am trying to make a tool in ArcToolbox using a Python script so users can input a street and lot number and it will zoom to the correct location/s in the cadastre. It's working but I have to type ...
3
votes
2answers
638 views

How to select polygon features that have their centers outside of another polygon feature class

Since I only have Incorporated area feature class, how can I select census blocks that are in unincorporated area? Or not within any incorporated areas? Thank you. John
3
votes
1answer
2k views

Use ArcPy to rename MXD layers

I have a MXD with some layers that have parentheses in them. I'd like to rename them via script. Is this a valid approach? import re map = arcpy.mapping.MapDocument("CURRENT") layers = ...
3
votes
3answers
2k views

How to create a copy of a feature class that is vertically and horizontally offset by a given distance?

I want to duplicate a polygon feature class and offset all of the polygons by about 10 feet in both the x and y directions. Is this possible to do using arcpy, or are there any geoprocessing tools ...
3
votes
2answers
4k views

Assertion Error when attempting arcpy.mapping.AddLayer

Whenever I attempt to use AddLayer it gives me: Runtime error <type 'exceptions.AssertionError'> This is what I've been using: arcpy.mapping.AddLayer(MainDF, ...
3
votes
2answers
86 views

Shapefile Naming conventions in ArcPy?

I have shapefile named `band-tailed_pigeon.shp which is fine and no problem on displaying or geoprocessing on Desktop but in ArcPy when I try to merge some layes to it I am getting this error I ...
3
votes
3answers
74 views

How do I compare two features to test if they are identical?

What is the most efficient method for determining if two features (points, lines, or polygons) are geometrically identical? I'm not concerned about a square figure that contains eight vertices (four ...
3
votes
2answers
228 views

How do I count occurrences of unique field values?

I have a feature class with a field which contains values 1, 2 and 3. I need to write code that reports the total count for each value: 1: 29 features 2: 52 features 3: 57 features ...
3
votes
3answers
279 views

Calculate field using variables as fields

When I calculate a field like this: field_0="field_name0" arcpy.CalculateField_management("Layer", field_0, '!field_name1! / !field_name2!', "PYTHON_9.3") It works! The field "field_name0" in the ...
3
votes
2answers
112 views

ArcPy Append Ignores Domains

I've been working with the append tool inside arcpy and discovered that, even though I have domains constraining the values of some of my columns, I never receive an error when the domains are ...
3
votes
1answer
751 views

Arcpy Update Cursor (arcpy.da.UpdateCursor()) not saving changes to 'SHAPE@LENGTH'

Looked around and found other Cursor questions, but nothing dealing with updating 'SHAPE@LENGTH'. I am running ArcGIS 10.2.1 and have a multipoint shapefile that I am grouping into polygons based on a ...
3
votes
1answer
445 views

How to check if shapefile is empty using ArcPy?

I have a number of shapefiles in a folder but some of them are empty i.e. there are no rows within the shapefile. Is there a simple way to find those empty shapefiles using ArcPy?
3
votes
2answers
2k views

Constructing file path within Python for Feature Class within Feature Dataset?

Based on my understanding of the ArcGIS path structure, a feature class inside a feature dataset inside a geodatabase can be accessed by the following: C:\Menu\Lunch.gdb\Sandwich\Cheese Where ...
3
votes
2answers
101 views

Looping field name change

I need to alter all of the field names through multiple feature classes. I have a pretty good idea of which tools to use but I'm not sure how to loop them through each feature class and each field. ...
3
votes
1answer
195 views

Arcpy.da.UpdateCursor, Error - Sequence size must match size of row

I am trying to use an UpdateCursor fill in a field but I keep getting an error, can anyone tell me what I am doing wrong? My code is below: import arcpy fc= "C:\Users\Keri\Desktop\GEP_690\Project ...
3
votes
2answers
2k views

Running Python script in Task Scheduler— Script will not run

I have a script which I wish to run on a regular monthly basis without me needing to open and run the it. I have referred to every web page I can find on Windows Task Scheduler and followed their ...
3
votes
3answers
209 views

Creating polygon from 2 txt files (Parent ID + Coordinates)

Here is what I am trying to do: I want to create polygons based on two separate text files: the first one (as parents) lists the Polygon ID (ID_el) and three to four Points ID (IDpt1, IDpt2, IDpt3..) ...