Python is an open source interpreted programming language used in many GIS programs.

learn more… | top users | synonyms

1
vote
4answers
304 views

NameError: variable not defined even though set multiple times

This code original worked when run through the python command window in ArcCatalog. After I added the script to a toolbox I have had all sorts of troubles. The most frustrating error has been: ...
1
vote
2answers
405 views

How to create a series of points along multiple polylines at once in ArcMap 10

I have a series of polylines that represent linear vegetation (shelterbelts, etc). I need to convert these to a series of points equally spaced in order to add them to a different shapefile that ...
1
vote
4answers
170 views

Arcpy: what tools are most suited for this job?

I'll try to be as much detailed as possible but please let me know if anything is missing: I'm trying to get the number of lines in layerA that intersect with each line in LayerB and stores that ...
1
vote
1answer
56 views

Overwrite option on a standalone ZonalStatisticsAsTable using ArcPy

How can I code an "overwrite option" on a standalone ZonalStatisticsAsTable using ArcPy? I don't see any overwrite option from a Esri example. # Execute ZonalStatisticsAsTable outZSaT = ...
1
vote
1answer
475 views

How to Properly Loop Through a List With a Cursor?

My team is working on a python script that does various updating tasks to our streets file. A part we are getting stuck on is trying to update a field. Currently we have a field FEDROUTE that is ...
1
vote
2answers
108 views

Suggest an algorithm to measure how a node is connected to road network

I try to measure how well a node is connected to the rest of the network. If a city has a distant suburb connected with one sole road, it's connectedness is, say 1. If it's connected by 2 roads, it's ...
1
vote
2answers
614 views

How to add shapefile as layer to map using Python and ArcPy?

I am working on an application and I am a beginner in Python :( I want to add a shapefile, the execution is successful and everything but no result appears on ArcMap, here is the code I use: import ...
1
vote
2answers
551 views

How to List Tables from current map document (mxd)?

We have many maps containing Feature Classes and Tables in a Personal Geodatabase that need their information updated. Is there a function to List Tables from the current map document like mxd = ...
1
vote
2answers
256 views

Extract a record by name in pyshp?

I would like to extract a named subset of the text records from a shapefile using Python/pyshp. Is there a clean/efficient way to do this? Ideally I'd like to use dictionary-like access such as: ...
1
vote
4answers
283 views

Python script to open many small images in QGIS

I have access to about 1000 satellite images that covers my country. Each of them is associated to a smaller image that is used for browsing the real deal. I would like to write a script that will ...
1
vote
2answers
295 views

How do I execute a script in the arcpy window?

I've been writing python in my text editor so I have a python script, script.py. I'm still developing it so don't want to put it in my toolbox yet, and at the moment this means copying and pasting it ...
1
vote
2answers
980 views

How to extract subdataset from HDF raster?

I am trying to extract a subdataset from HDF raster. Later on, I intend to make operations such as mosaicking and extracting raster averages from the extracted subdataset. The following code is ...
1
vote
2answers
717 views

Conditional Labeling based on attributes in ArcGIS 10

I am trying to label a street centerline layer with a condition based on street width. I am using the Python parser and I can't figure out this simple logic. Neither of these questions address how ...
1
vote
2answers
3k views

How to set workspace as Python script tool variable/parameter?

I'm pretty new to Python. I'm trying to write a script and as I want to automate it as much as possible, I'm wondering is it possible to set the workspace as a variable so that when it's run as a ...
1
vote
2answers
1k views

python - Calculate field with part of file name

So I previously successfully used the sample code here: Model Builder - How to calculate Field using part of filename # Import standard library modules import arcpy, os, sys from arcpy import env # ...
1
vote
2answers
863 views

Can you use arcpy.Copy_management() with in_memory tables?

I have a table in an ArcSDE GDB I'd like to step through using Python. For performance reasons I wanted to load it into memory like so: arcpy.Copy_management('C:/GDB.sde/MyTable', ...
1
vote
2answers
205 views

What is the best quick way to populate a field (in ArcGIS 10)? (for rare language/font e.g. Guzrati numerals)

I have polygons generated from shapefile (esri) format I have a tiff image of plot/parcel map(this tiff has plot id scribed in somewhat consecutive in manner) of that polygon feature. I would ...
1
vote
2answers
249 views

Python syntax error…cannot see the error!

I'm very new to python and have created a script for enabling a user to list file types in a workspace making use of the parameters function in ArcGIS so it's more user friendly. However I cannot get ...
1
vote
2answers
3k views

How can I save raster dataset using arcpy

I'm trying to save filled raster object to geo database by my specified filename. import arcpy from arcpy import env from arcpy.sa import * env.workspace = r"C:\GIS ...
1
vote
3answers
534 views

Replacing Variable in VB-Expression-File (.cal) of ArcGIS Desktop?

I'm trying to modify a VB-Expression saved in a cal-file by ArcGIS Desktop 9.3: dim out if [D19830701]=-9999 then out= [D19830501] else out= [D19830701] end if ...
1
vote
3answers
920 views

an arcgisscripting method for sanitizing a filename?

Is there an arcgisscripting method for sanitizing a filename to get rid of characters which Arcgis barfs on, the meek hyphen - for example?
1
vote
1answer
80 views

Python encoding error in ArcPy

I am writing a JSON file, as string input, using python, into a .json file in the file system. However I am getting the following error sometimes and I don't know why. Any ideas? ...
1
vote
2answers
213 views

Renaming filenames to a standard filename format using Python

I am working within an ESRI ArcGIS environment. I have a folder full of .xyz files that are named to a specific old file format such as 2014516_MS_005.xyz I want to be able to loop through the whole ...
1
vote
1answer
92 views

python expression convert field to string and format with leading zeroes

I would like to create an expression using the field calculator in ArcMap to be able to convert an Int field to a string and add leading zeroes. I am able to do it in a python window with an example ...
1
vote
1answer
146 views

Determinate Parcel Neighbors using PYTHON

As you can see in the First picture, I have parcel 220, and i want to determinate the position of each of his neighbor ! So the idea was to calculate the bearing between the centroinde of 220, and the ...
1
vote
2answers
107 views

Using Python For a Field Calc

In AcrMap 10.2 I'm trying to add a field and run this script in Field Calc: !shape.isMultipart! to see if I have any multipart lines. I keep getting geoprocessing failures. I am clicking the ...
1
vote
2answers
150 views

Field Calcuator to add percent using Python

What might I go wrong here is that I am trying to add percent. I use the Field Calcualtor and it keeps getting an error. I am opening the Table to add a field named Percent and then type this: ...
1
vote
1answer
225 views

Simple field calculator equation in ArcGIS 10.2.1 not working with python parser

I am trying to calculate a percentage in a field in a table. customers and total_customers are short integer fields. arcpy.AddField_management(tableSepSel2, "percent", "DOUBLE") ...
1
vote
1answer
447 views

Installing pandas with Esri's python?

Trying to get pandas to import, but I'm getting what looks like an error caused by a failed dependency of the version of my Esri-provided numpy's compile, based on this stackoverflow posting. Here's ...
1
vote
1answer
292 views

Secure credentials for scheduled python script targeting ArcSDE 10.1 on AWS

I have a python script that will be used as a scheduled task. Our dba team is wanting the credentials to be as secure as possible. I would say that using the os security system as far as locking ...
1
vote
2answers
695 views

Import CSV column into existing feature using arcpy

My goal is to take a CSV that contains 50 rows and one column and import the data into a feature class with over 3,000 rows using arcpy. I want to pick a random row from the CSV and then iterate ...
1
vote
2answers
340 views

Why my python script of r.watershed has no output?

I type those code in pyscripter, import os import sys #set up GRASS environment variables sys.path.append(os.path.join(os.environ['GISBASE'], 'etc', 'python')) import grass.script as g import ...
1
vote
2answers
1k views

Create an X,Y latitude and longitude grid from an raster

I have a satellite image (LandSat 5), I want create a raster with X,Y coordinates, this is possible in Model Builder of ArcGis 10.0? or other option. I know that the option $$YMAP ($$XMAP) not work ...
1
vote
2answers
909 views

How to plot geoJSON using Python?

I have huge geojson file that I am working on: [{ "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ ...
1
vote
3answers
711 views

Problem with python script to control GRASS GIS from outside - How to import grass.script under Win 8.1?

I am working with GRASS 6.4.3 and python 2.7.6 under WIN 8.1. I am a novice with computer science and coding, and I have seen many posts including those:Is it possible to use GRASS GIS in Python ...
1
vote
2answers
188 views

How to get an indication of how points are spatially distributed?

Let's say I have a set of points and I want to get an indication of their spatial distribution. That is, if all points are at one location a possible return value would be 0, whereas if all points are ...
1
vote
1answer
339 views

ArcGIS arcpy reprojecting raster issue

I have a raster which I want to reproject from GCS_WGS_1984 to GCS_NorthAmerican_1983. I am using the following code: try: spatial_ref = ...
1
vote
1answer
123 views

turn a Result object into a number

**import arcpy from arcpy import env from arcpy.sa import * import math # Check out any necessary licenses arcpy.CheckOutExtension("spatial") # OverwriteOutput arcpy.env.overwriteOutput = True ...
1
vote
1answer
154 views

Set Grass Region in Python grass.script

How can I set the Grass Region in Python without already having a map in the Mapset? Basically I am looking for the equivalent to this window Currently I am only able to extent an existing region, ...
1
vote
2answers
667 views

How to remove z & m coordinates from shapes with QGIS? (Or arcgis, grass, gdal, Python…)

I've recently received some parcel data in shapefile format that has z & m coordinates (all = 0.0). The WKT for a typical parcel looks like this: "MULTIPOLYGON (((2672464.560700002 ...
1
vote
2answers
869 views

Python - GDAL : Polygon to point shape file

I want to read all the points in a polygon shape-file and use their coordinates to make a new point shape file. then find the min and max of the X coordinates. So here is the code I wrote for the ...
1
vote
1answer
727 views

How to access row from dbf table?

I have got the following problem: I would like to access a row from a dbf table. I have tried to access it through SearchCursor, but I am not able to do it without knowing the field name. This is my ...
1
vote
2answers
1k views

Importing ArcPy taking many seconds and code is really slow for GeoProcessing Tools 64-bit (ArcGIS 10.1 SP1)

I've installed ArcGIS10.1 SP1 and whenever I import arcpy (on Pywin console or Eclipse PyDev) it takes aprox. 15-20seconds. Is this normal? I don't think so... I had Python 2.7.3 64-bit previously ...
1
vote
2answers
918 views

Python code does not work with RasterCalculator after exported from Model Builder

I have a model authored in Model Builder that uses "RasterCalculator" to process input raster datasets. arcpy.gp.RasterCalculator_sa("OutRas = Con(\"%STATIC_forestland%\" == 0, -255, ...
1
vote
1answer
598 views

Select By Atribute using python script on .Shp file getting error 000840 the value is not a raster layer

I have a script that calculating vertices angles on Polyline layer and the selecting features in that layer at a specified angle. at the end of the script i'm using select by attribute and getting ...
1
vote
3answers
443 views

Center of a bounding box

I have bounding box coordinates of my shapefile (fetched from layer.GetExtent() Python with GDAL/OGR): (-38.6102467739459, -38.017601026186576, 33.01563382506067, 33.624945228091406) So I assume ...
1
vote
2answers
799 views

Can anyone recommend an Arcpy GUI? [duplicate]

Can anyone recommend a GUI for arcpy? So if I want to run my script as an exe with some blank text boxes(or text boxes with default entries), radio buttons, check boxes etc.
1
vote
2answers
153 views

How to interact layers with a nested loop?

I've dealing with the code below with such a long time. I have to show in a raster image the result of calculating the cost of the electricity for a solar plant. The thing is that I have to interact a ...
1
vote
1answer
1k views

How to change vector attributes values?

I want to change vector attributes values. i could not get the command fet.setAttribute indeed, it is mentionned in http://hub.qgis.org/issues/7223 that: "The QgsFeature instance now must be ...
1
vote
2answers
1k views

Select Layer by Location - Arcpy - Why are my inputs being interpreted as invalid?

I am working on a tool in a python toolbox and am totally confused about what is going on and causing my select by location operation to fail (Error 000368). I am trying to select the features in one ...