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

learn more… | top users | synonyms (1)

2
votes
2answers
61 views

Need to understand desc.workspaceType to use in conditionals

I need to differentiate between two possible types of workspaces for an arcpy script. So I check the workspaceType: rootWorkspace = raw_input('Geodatabase workspace to analyze: ') desc = ...
2
votes
3answers
255 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, ... ...
2
votes
1answer
660 views

How to write point geometries with arcpy instead of gp syntax?

Can someone help me fix some code that simply writes points into a featureclass? It used to work in the older gp. syntax, but I'm having difficulties rewriting it in arcpy for ArcGIS 10.0. In this ...
2
votes
3answers
1k views

How to use ArcGIS 10.1 to make Python scripts for ArcGIS 9.3?

Recently I have been making scripts to run geoprocessing tools for a client who is running ArcGIS 9.3. However I only have access to ArcGIS 10.1. As a result I cannot use model builder in 10.1, and ...
2
votes
3answers
112 views

Loop with arcpy.ListFiles

I'm super new on here and have also not much experience with Python but I really like to learn to work with this language. I'm tying to write a script for this: I think I need a for loop instead ...
2
votes
3answers
105 views

Iterating using search cursor and layer selection performance?

I'm trying to use the results of a search cursor to iteratively make selections on a feature class and then create new feature classes (so you get a new feature class or shp for each unique value in a ...
2
votes
1answer
142 views

ESRI File Geodatabase with a field calculator with an incrementing number

I've got a python script that runs on the Field Calculator of a ESRI File Database. Right now it runs correctly in that it will increment the last three digits of the value. But this is a script ...
2
votes
1answer
146 views

How to check if a shapefile is empty with arcpy

I have a bunch of shapefiles in a folder. But some of them are empty, i.e. there are no rows within the shapefile. Is there a simply to find those empty shapefile out?
2
votes
2answers
565 views

arcpy.da.updatecursor to delete duplicate rows where values switch columns

I'm trying to dissolve polygons using polygon neighbors in arcgis 10.1, but don't want to use duplicate rows. However, the field values will switch when they're duplicated. If I run this: ...
2
votes
2answers
690 views

How do I construct a file path within Python for a Feature Class within a 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 ...
2
votes
2answers
297 views

The name contains invalid characters

I'm having a problem with the following script. When listing parameters that are optional I've used the "" before, so I can't figure out why this isn't working. import arcpy import os ...
2
votes
3answers
430 views

Is there a way in arcpy to convert map units from feet to decimal degrees?

This is my problem: I have an arcpy script that finds the XMax, XMin, YMax, and YMin of a polygon. It shows the results in feet, but I want them to be in decimal degrees. In ArcMap I can change the ...
2
votes
3answers
1k views

Arcpy Max Value per Group in One Field

I have a point shapefile that have two attributes that I want to extract from them. These two fields are "Group" and "Distance" I want to grab the maximum "distance" from each unique number in the ...
2
votes
2answers
575 views

How do you use folders as input/output parameters

What I want to do is to go into a folder, find a layer file, pull it into an MXD, then export a jpeg in an output folder. Everything is great except I don't know how to set the input/output folders. ...
2
votes
2answers
57 views

Using multiple wildcard parameters with arcpy.ListFeatureClasses

I know there has to be a way to do this but I'm having trouble figuring out how to do so. I would like to create a list of feature classes to perform operations on however, I want to have the list ...
2
votes
2answers
114 views

ListFeature classes in SDE

I have this code: def backSDE(ActiveSDE): arcpy.env.overwriteOutput = True arcpy.env.workspace = ActiveSDE fcs = arcpy.ListFeatureClasses() print fcs #Databases ActiveSDE = ...
2
votes
4answers
55 views

How to Add (+) up integers in a field and print a total count in pyhton 2.7

I'm a complete beginner to python. I have what I hope to be a simple question. I want to run a bit of script in IDLE so that it adds up all figures in a table under attribute name "Tot_Aff". When I ...
2
votes
1answer
204 views

How to convert arcpy.InsertCursor to arcpy.da.InsertCursor in Python code?

I have some working code using arcpy.InsertCursor which I want to convert to arcpy.da.InsertCursor. This I want to do primarily as ESRI claims that da methods are more optimized. The code I have is ...
2
votes
1answer
85 views

ArcPy: Drop fields from list of fields for arcpy.da.SearchCursor

I have a feature class with several fields in the attribute table, and I want to export a few but not all of those fields out to a tab delimited text file. The code below sort of works, half of the ...
2
votes
2answers
303 views

Measure area of a polygon in specific units using ArcPy

I am trying to find the area of a particular polygon (OriginalPolygon, below), and I can do that... But, I'd like it in acres regardless of the original units of the polygon.(Data is coming into this ...
2
votes
3answers
139 views

Software needed to recreate VBA forms using python for Arc 10.0

I'm new to programming and need to convert VBA scripted tools for the 10.1 upgrade. I need to recreate the forms and use Python scripting. How do I do this? I need the form to function in 10 ...
2
votes
2answers
223 views

Arcpy how to conduct addition in a script, function needed?

I'm trying to work on my first arcpy script and am running into some troubles. The objective is to create a new field, check several existing fields (Cnt1,2,3 and Pop1,2,3) for missing data (-99 ...
2
votes
3answers
1k views

How to measure minimum distance between objects in two layers using arcpy?

I am working on an alien species analysis looking at the spread of a species from the mainland to islands in an archipelago. I am doing the analysis using arcpy and I have succeeded in isolating risk ...
2
votes
2answers
1k views

Using newline/page break tag in ArcGIS Desktop Text_Element in arcpy.mapping? [duplicate]

I want to update a Text_Element with a newline or page break using ArcGIS Desktop 10.0. Does anyone know the tag or syntax?
2
votes
2answers
546 views

From a script tool using ArcPy, can I store a point object in a BLOB field and retrieve that point later?

I am trying to write an ArcPy script tool that will store a point object in a BLOB field that I have created. I don't know if that is even possible. If it is, how do I do it, and how can I then ...
2
votes
1answer
1k views

How to change the datasource with python?

How do I change the datasource of all layers in a map document using arcpy and python
2
votes
3answers
120 views

raster area calculation using python script

Hi I am a beginner to python programming in GIS and am trying to calculate the area of a raster. When I ran the program, I got error message below. I am also providing my code. Any help would be ...
2
votes
2answers
113 views

Convert a Toolbox (.TBX) to a Python script (.PY)?

I have a .tbx tool box, which runs a script that is incredibly slow. So what I want to do is to open the python script that is running below the .tbx and make some changes or perhaps write something ...
2
votes
3answers
173 views

SQL expression error for Select Layer By Attribute

arcpy.MakeFeatureLayer_management("N05-12_Station2_JGD.shp","station_12") year=2012 arcpy.SelectLayerByAttribute_management("station_12","#",'"closing">=%d AND "opening"<=%d' % year) ...
2
votes
3answers
158 views

How to extract data using arcpy.da.SearchCursor

I have a shapefile of point features showing fire locations in a given year. One of the fields is named "YYYYMMDD" and indicates the corresponding date that that fire happened. In Python, I am trying ...
2
votes
1answer
55 views

How to use the List field function for a toolbox script?

i´m trying to write a simple script for a toolbox, similar to the Addfield_datamanagement toolbox. The script adds a new field to a table of a feature class or a shapefile with attribute tables. So ...
2
votes
1answer
157 views

How to generate dynamic legend using ArcPy?

I used this example to produce printing service. As the result I get map with too many elements in the legend. Is it possible ti show classes that are visible in the current map extent using python ...
2
votes
3answers
96 views

Best way to find points outside state boundary that are supposed to be within specific State

I have a nationwide featureclass called bakeries. In the bakeries FC, there is a field called "State" and the field is populated with state abbreviations(AL,NJ,CT,etc). I have another feature class ...
2
votes
3answers
110 views

Create in memory polygon with RasterToPolygon

I need to create a number of polygons in a loop from a raster. Essentially, the loop will call a function a number of times which needs to convert it to a polygon: def myfunc(raster): #do some ...
2
votes
1answer
89 views

Create lines from points arcpy

I have a points shapefile, and a file that tells me which of the points have a line between them. I am using arcpy to create a new shapefile to hold the lines and then create the lines based on the ...
2
votes
1answer
295 views

Python getting area of multipart features with SearchCursor()

I am tasked with programatically getting the area of each individual part of a multi-part feature. I have a script already to read each individual part and print its XY coordinates and it works fine ...
2
votes
2answers
65 views

How do I skip rows with searchcursor based on an interger value

For example, if I have 100 records, and I want to sample 10% of the records. How do I tell the search cursor in arc10 to read the value of the 9th record, or every 10. I tried to do row[0 + count] and ...
2
votes
2answers
51 views

Is there a way to replace just a specific character in a variable? [closed]

Here is an example township = township[3].replace("0", "") My goal being that if 10.0 is the current value for township I want to remove the zero after the . but not the one after the 1 with the ...
2
votes
2answers
300 views

How to edit (particularly flip direction of) polyline obtained through UpdateCursor?

I want to flip the direction of a polyline feature obtained as a result of an Update query; e.g. lines= arcpy.UpdateCursor(myFeatureClass,myQuery) dsc= arcpy.Describe(myFeatureClass) try: for ln ...
2
votes
1answer
58 views

How to use arcpy.setValue for Title casing?

I am trying to figure out how to use fieldName.title() method while updating rows using updateCursor for multiple fields. I was trying to improve the code of this post to fit my purpose: ...
2
votes
2answers
999 views

Possible to add multiple fields in single arcpy statement?

I'm trying to add multiple fields to a table using arcpy and am wondering if it's possible to have multiple fields declared in the AddField management, and their values, separated by commas or ...
2
votes
1answer
230 views

Calculate field result is float with Arc tool, integer with arcpy script

I am trying to calculate a field for some points within a python script using arcpy functions. (This is calculating the percentage visibility from a cumulative viewshed, if that matters.) # Process: ...
2
votes
1answer
241 views

Saving rasters in a Python for loop fails only on last iteration

I'm a newcomer to Python scripting and I'm having what's seemingly a very simple problem but one that's stumped me enough to send me posting to these forums for the first time. I'm using a for loop ...
2
votes
1answer
64 views

create folder with random number for each session using arcpy

I am processing data and it is required to have same name of outputs [standard names] for different geographical regions. Therefore it is necessary to save outputs in different folders each time. Is ...
2
votes
1answer
284 views

How to programmatically determine whether a spatial reference factory code is valid?

I am using the following code segment to create a spatial reference. spatialReferance = arcpy.SpatialReference() spatialReferance.factoryCode = spatialReferanceFactoryCode ...
2
votes
1answer
746 views

Convert MapInfo - MapBasic Script into Python

I have a mapbasic script that divides an irregular polygon into smaller polygons of 1 hectare each. Would anyone help me to convert the following into an arcpy python script. ' This program ...
2
votes
1answer
512 views

Adding Layer in current session using ARCPY

I wanted to add a layer through the toolbox using arcpy. The below script works fine through the python console in ArcMap, but does not when executed through the toolbox. The layer flashes for a ...
2
votes
2answers
488 views

How to truncate file geodatabase tables with python?

Everything is in the title. I need to truncate file geodatabase tables (1 or all) with python. What is the code for that? Thank you in advance!
2
votes
1answer
37 views

Using get count with if statment

Pretty simple question though I am struggling with how to operationalize this, I want to rename a shapefile based on the number of features it contains. My initial thoughts are that I would need to ...
2
votes
2answers
55 views

Check if a single feature is completely within another (arcpy)

I have a feature class that contains one polygon feature, and I need to check if said feature lies completely within another polygon feature. Used selectLayerByLocation and then retrieved the count ...