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

learn more… | top users | synonyms (1)

3
votes
3answers
1k views

Copy dbf data into a shapefile in Arcpy

Basically it's to perform a one-to-many join in a python script, from a dbf to a shapefile. I saw (Greg Krakow's method) using QGIS, but I can't use it (I'm working on it, but QGIS is not yet ...
18
votes
1answer
1k views

ArcGIS 10.1 Python AddIn Using Multiprocessing crashes ArcMap?

I would like to run a multiprocessing task from a python add-in tool. My issue is that the process keeps failing. Basically crashes ArcMap. Here is my basic code: def function(startOID, endOID, ...
3
votes
1answer
397 views

How to convert a string from GetParameterAsText to uppercase?

This is my first question here and I'm sure it's ridiculously simple. But I have Googled and no luck. I am trying to make a tool in ArcToolbox using a Python script so users can input a street and ...
29
votes
3answers
1k views

How to Share Open Source Python Code for ArcGIS?

My company just purchased ArcGIS software. I'll be writing scripts for ArcGIS in Python. Is there a community or open source project where this code can be shared?
1
vote
1answer
146 views

Reading environment variables in arcpy

I have a script that tries to read from the arc environment using import arcpy tolerance = arcpy.env.XYTolerance as recommended here: ...
2
votes
1answer
998 views

ArcPy: Using lblclass expression to change font style and color

I´m trying to label features of a dataset using ArcPy and the lblclass function. While commands like "VBNewline" and "Round" work pretty well, I´m not able to change colors or font style. An ...
8
votes
1answer
1k views

concurrent use of in_memory workspace in arcpy

i am using a python script that's eliminating small polygons from a feature class. this script creates temporary feature classes with fixed (hardcoded) names in the "in_memory" workspace. example: ...
5
votes
1answer
2k views

How do I correctly use 'MultiValue' in Python script parameters?

My script works fine with a single feature class selected for clip_fc = arcpy.GetParameter(0) . However when I set clip_fc to MultiValue in the script properties and then select several feature ...
2
votes
4answers
442 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 ...
12
votes
3answers
5k views

What is the proper syntax and usage for ArcGIS “in_memory” workspace?

I am unclear how best to use the in_memory workspace in ArcGIS. The best resource I have found on the subject is from ESRI on Using in-memory workspace. Unfortunately, the help section is not very ...
9
votes
2answers
228 views

How to count zero values in a table in rows and write it to new field?

This is a very simple task to do but I can't understand the right syntax. I have a shapefile whose attributes are similar to the following: FID Shape FIELD1 FIELD2 FIELD3 ... 0 Polygon 0 1 ...
2
votes
1answer
331 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 ...
3
votes
1answer
414 views

How to rotate labels using ArcPy?

I'm writing Python code for ArcGIS using the arcpy library and now I'm experiencing a little problem with labels. In fact I'm not able to rotate them in layout via arcpy (I should rotate all labels of ...
2
votes
1answer
344 views

Converting a Map to graphics and annotations

i want to export a map for later editing before print, so i thought about converting all the annotations and and graphics and save them in the .mxd map. when i export graphics after exporting labels ...
1
vote
1answer
425 views

Converting arcpy based python script to OGR for semi-automated Metadata creation

I have created a script to automatically generate base ANZLIC standard metadata using arcpy based coding. Can anyone help me convert it to OGR/GDAL python? This is so that it can be run in QGIS and ...
0
votes
1answer
2k views

arcpy.RegionGroup fails with error 999999. Workspace or data source is read only

outRegionGrp = RegionGroup(inRaster,"EIGHT", "WITHIN", "ADD_LINK", valToIgnore) arcgisscripting.ExecuteError: ERROR 999999: Error executing function. Workspace or data source is read only. The table ...
4
votes
1answer
737 views

Why can't I multiply two string fields in the Field Calculator by converting them to int() and float()

I'm using ArcGIS 10 and new at python scripting. I have a string field that I need to calculate by multiplying two other string fields. I can do it in python using two arbitrary values... CINPT1 = ...
5
votes
1answer
289 views

What is the most efficient way to get a list of featureclasses from a large ArcSDE database?

I have a SDE DB which consists of 40 feature datasets and around 300 featureclasses. I need to get the full list of all featureclasses whose name does not contain "ARCHIVE". It takes several minutes ...
4
votes
1answer
2k views

How to detect duplicate attribute values in a table using ArcPy

In ArcMap, the right-click Summarize option very quickly creates a frequency listing of the chosen field: Note that the count field shows the count of duplicate values. How can I access this ...
1
vote
3answers
5k views

Python Script for Select by Attributes taking user input

I am trying to write a python script and create a script tool in ArcGIS that will let a user choose the value or values that will be used to extract a shapefile. These selected value(s) will then need ...
4
votes
2answers
923 views

Arcpy remove invalid character

I've built a model that takes the name of the Excel worksheet containing xy data, and uses that name as the name of the output shapefile. ( Worksheet "massachusetts_sightings" in an xlsx becomes ...
1
vote
2answers
1k views

How to Set up Data Driven Pages using arcpy?

I've read a lot about the topic data driven pages. I'm writing a python script for ArcGIS and I've defined my stripmap using the arcpy.StripMapIndexFeatures_cartography command and now I have to set ...
19
votes
1answer
1k views

How to Split a Concave Polygon Into Convex Polygons in Arcpy?

I'm looking for a tool or algorithm to detect concave polygons and split them into convex polygons. Like explained in the picture, the blue polygon is split into A and B polygons I'm using Arcpy ...
1
vote
2answers
790 views

pour point user click input over map for watershed delineation

I have a drainage density map and i want to interactively retrieve watershed by clicking a point on map. Once I zoomed to an area of interest and click the highest accumulation point of my choice then ...
3
votes
2answers
2k views

Getting values from attribute table and inserting another table

I have line feature class of a river network and “FromTo” table. Lines are dissolved so they are not segmented from junctions. I need to write a Python script in ArcGIS to do following: Begin from ...
4
votes
2answers
2k views

arcpy overwrite files in a geodatabase file

I'm writing a python script, I've got an mxd and its workspace is a geodatabase file with all the files I need into. The problem I'm encountering in testing and writing code is that, despite of the ...
2
votes
1answer
3k views

How to calculate polyline azimuth or polyline direction?

I am looking for a Python code block to calculate azimuth per each polyline feature. So far I have been able to use the following Python code to calculate bearing: 180 + math.atan2(( ...
1
vote
1answer
511 views

Why does arcpy append from file geodatabase to SDE fail?

I'm trying to append a feature class from a file geodatabase to an Arcsde featureclass using this line of code: arcpy.Append_management("parcel_copy", sde_path+"parcel" ,"NO_TEST") This line works ...
5
votes
2answers
712 views

arcpy - how to check if a domain contains a particular coded value?

How can I check if a domain contains a particular coded value? How to check if domain already exists? shows how to verify whether a domain exists in a geodatabase. However, I can't see how to check ...
6
votes
1answer
651 views

Why are results from Python tool not in Results window?

I am relatively new to ArcPy 10. and I want to return the list of feature class from a dataset. I can see them through the message, but cannot see them from the result window. Actually there are only ...
4
votes
2answers
1k views

How to programmatically work with featureclasses from multiple geodatabases?

I have produced a Python script which creates multiple buffers of specific (listed) featureclasses within a geodatabase. This is achieved by running each feature through a for loop. I would like to ...
8
votes
1answer
1k views

Creating table containing all filenames (and possibly metadata) in File Geodatabase?

I need to create a metadata-table for all files in a File Geodatabase or Spatial Database. It would be awesome if it were possible to automatically be updated with new filenames, and possibly even ...
6
votes
1answer
324 views

Why does tool take longer to run when in Python script?

I have written a python script that does some euclidean allocation. For that I use arcpy.gp.EucAllocation_sa() method. Now, my python script takes 30-40% extra time than spatial analyst euclidean ...
5
votes
3answers
3k views

How to create lines from points pair coordinates with arcpy?

I've got some points pair coordinates (start and end points) which I have to transform into lines. Until now, I used an append of both the coordinates in a pippo.Point(), a pippo.CalculateGeometry() ...
3
votes
1answer
981 views

How can I use a variable to specify which field to update with arcpy.UpdateCursor?

I am writing a script that cycles through several different point shapefiles, finds how many lie within a given area and the writes the outcome to a table in an Access database. I've used an search ...
45
votes
10answers
3k views

Alternatives to using Arcpy

I seem to use ESRI's Arcpy site package for virtually all of my python geoprocessing. To ESRI's credit, these are an incredible suite of tools that can help accomplish a great deal. However, I would ...
1
vote
2answers
83 views

Automating attribute completion of new polygons

Good Afternoon I am currently outlining property boundaries and then copying and pasting in the necessary attributes on a daily basis. I would like to speed up this process and remove the chance of ...
2
votes
0answers
1k views

Why am I getting an ERROR 000728: Field *fieldname* does not exist within table even though field exists?

I do some script for a shapefile's table. And this script works for 2 fields and do not for other ones, because of: ERROR 000728: Field FID_158_01 does not exist within table But this field is ...
4
votes
2answers
966 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 ...
1
vote
0answers
310 views

ArcGIS/arcpy: Geometry object comparison methods not working. Do they take z values into account?

I have an arcpy script that makes calculations based on an input PolygonZ feature class. What I need to do in several places in the script is test whether a point falls within a polygon in 2D. In ...
2
votes
1answer
615 views

How to add new data frame(s) to map using ArcPy?

I want to add a 2nd data frame to an existing "*.mxd" file. Right now, i see option to add layers and edit properties of "CURRENT" data frame but could not figure out how to add a new one and export ...
16
votes
4answers
1k views

How are people using Python data structures and classes in ArcPy?

This question may expose my ignorance on programming but I'm curious about how people are using different python data structures within ArcPy. This page lists the data structures in Python. I ...
3
votes
1answer
856 views

How to pan to a specific feature using arcpy?

I am attempting to use python and arcpy to automate the creation of some standardized maps I need to export for feature classes from various projects. I have a set of points and I need to export a ...
2
votes
2answers
3k 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 ...
5
votes
2answers
3k views

How to clip/export multiple selected vector layers in a map to extent of another raster/vector layer in ArcGIS?

Is there a way to clip/export selected vector layers (more than one) in a map to the extent of another raster/vector layer at a time?? in Arcgis or any other software. I am using Arcgis10. I am ...
2
votes
2answers
1k views

How to clip multiple raster datasets with county polygons?

The example below shows three raster (i.e. in black) and a single county polygon feature class. How can I clip/extract by mask the rasters by their corresponding county polygons (i.e. Edwards, Clark, ...
0
votes
1answer
979 views

Why do i get an input error no module named arcpy when i try and import it into pythonwin?

Here is the error i get when i use the import arcpy command in pythonwin: Traceback (most recent call last): File "", line 1, in ImportError: No module named arcpy Can any one tell me how to fix ...
4
votes
2answers
465 views

focal statistics with variable radius

is there an easy way to do focal statistics on a raster, with a variable radius for the neighbourhood to be searched? As in: that search radius would be stored in another raster? i tried something ...
5
votes
2answers
207 views

Using newly created features in the next part of a python script

Good Afternoon I am trying to write a python script which buffers a large number of features from a geodatabase (but not all) and then dissolves the newly created buffer shapefiles together. ...
0
votes
0answers
158 views

How to iterate throught fields names in a table and change row values?

I got table like that one (Example). I need to change 0 to 1 and -1 to 0 in each field except first and second. The problem is that every time i have different number of fields and field name is ...