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

learn more… | top users | synonyms (1)

5
votes
1answer
2k views

Exporting map to jpg (multiple times with python)?

I set symbology and exported each raster in my mxd (one by one) to jpg file. My script is ok and it works (it is shown at the bottom). The question is: how can I customly set my legend? Now I have ...
3
votes
1answer
739 views

Issues with arcpy.sa.Reclassify

I have a raster file with classifcation codes, and want to reclassify valid codes to 1, and all others to 'NoData'. RMAP2 = arcpy.sa.RemapValue([[3.2, 1], [4.1, 1], ...
3
votes
1answer
612 views

How do I programmatically export a single Data Driven Page to JPEG?

I am trying to write a python script to export a individual pages to a jpeg. I am getting the error "PageLayoutObject: Error in SetDataDrivenPageID". Can anyone see where I am going wrong? import ...
4
votes
2answers
966 views

Programmatical Setting of 'Store Relative Pathways' for multiple MXDs ArcGIS 10.1

I am looking to move large number of mxds to a different location on the same drive. Many mxds haven't got 'Store relative pathways' option checked therefore this operation will result in broken links ...
8
votes
2answers
1k views

How to keep spatial reference using arcpy.RasterToNumPyArray?

I am using ArcGIS 10.1, and want to create a new raster based on two preexisting rasters. The RasterToNumPyArray has a good example which I want to adapt. import arcpy import numpy myArray = ...
4
votes
1answer
1k views

Getting a constant background color for transparency

I am creating a series of tif files at 1:10k scale over a vast area (760 tiles) using arcpy.mapping.ExportToTIFF and then stitch them together to create a single ecw. The output looks ok but when I ...
1
vote
1answer
414 views

Does arcpy have an issue with directory names starting with a number?

I have a script to export DDP extents to tif and when I change arcpy.mapping.ExportToTIFF(mxd,"tests\BA\BA10k_" + str(ddp.pageRow.PageName) + ".tif",df,9306,9306*ar,1800,True) to ...
4
votes
2answers
373 views

How to pass an output stored in a single variable into another script using arcpy

I am running set of processes each with different outputs in a python script. Is there a way to set a variable as global so that just the output of that single step can be accessed from other scripts? ...
2
votes
1answer
737 views

Why is using two imbricate UpdateCursor not working?

I hope my question is not redundant. I wrote a script to Update a table using two imbricate cursors. The goal was: to read a records, update some of its values Make a selection based on this ...
3
votes
1answer
488 views

Pasing multivalue parameter using arcpy

I am trying to get my head around how multivalues derived from the arcpy command GetParameterAsText gets looped through a script. Could some please provide a sample script that does the follow basic ...
13
votes
2answers
331 views

File organization for sharing ArcGIS python code

What is the best organizational structure for sharing ArcGIS python code and geoprocessing tools? Or even, are sharing code and sharing tools separate questions? Esri has a Methods for distributing ...
4
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
455 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?
8
votes
1answer
4k views

Use python to add layers to TOC

I've been battling with adding layers to the TOC for some time now. I have managed to single layers added but need to loop through a folder and add all layers. Shapefiles I cannot get to add at all. ...
1
vote
1answer
167 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: ...
3
votes
1answer
85 views

What are arc's guarantees on data precision, XYTolerance (i) when displaying (ii) in arcpy?

Interesting behaviour: Two line segments in a dataset have almost, but not quite, identical endpoints. The difference between them is less than the XYTolerance for the data set. Reading the ...
2
votes
1answer
1k 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
638 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 ...
14
votes
3answers
7k 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
242 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
395 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
499 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
390 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
482 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
849 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
325 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
3k 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
7k 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
1k 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
2k 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
923 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 ...
7
votes
3answers
1k views

python script error- with GetParameterAsText

I have a seemingly simple code which iterates through a list of feature classes and calculates an ID field in the attribute table that is equal to the first 5 characters of feature class name. The ...
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 ...
5
votes
2answers
3k 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
4k 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
632 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
879 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
834 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 ...
9
votes
1answer
2k 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
401 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 ...
0
votes
1answer
229 views

Python adding grouplayer to muliple maps

I have the following code which is supposed to add a one group layer to each of the maps. In this case the group layer is always the same. Desired output: Map1 = 1 group layer added Map2 = 1 group ...
5
votes
3answers
4k 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
1k 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 ...