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

learn more… | top users | synonyms

6
votes
2answers
118 views
+50

Conflict between ArcPy and GDAL/OGR?

TL;DR I can't get an installation free version of GDAL/OGR to work from within ArcMap 10.0. I get an ImportError: DLL load failed on _mod = imp.load_module('_gdal', fp, pathname, description). ...
7
votes
3answers
856 views

How to determine on which side of a line a polygon feature falls?

I have parcel data intersecting line data. In the parcel data there are some parcels that don't intersect the line. How could I programmatically figure out if the non-intersecting parcel is on the ...
3
votes
1answer
145 views

draw lines with an angle inside a rectangle in python

I am trying to make a plugin for Qgis with python. I have the four corner coordinates for a rectangle. I want to give the user the inputs, line space and angle (0 -180 degrees). With these inputs, I ...
0
votes
0answers
13 views

PyQGIS: Editable Combobox for Value Map widget isses

I am having issues with an editable combo box in QGIS 2.4. The edit widget is set to Value Map with an uploaded CSV. However, if a new values (not included in the key value pair list) is added, the ...
1
vote
0answers
45 views

How do you modify selected geometry with a function in qgis python console?

My example use-case is that I want to redistribute vertices along lines as in Redistribute linestring vertices to specified distance and I've written some functions to do some of the work: import ...
0
votes
0answers
63 views

QGIS 2.4: plugin changes map tool canvas click behavior from 2.0

I had created a plugin for QGIS 2.0 to add new features more easily. It involves changing extents and updating snapping options along with triggering the default actionAddFeature(). However, I've ...
2
votes
2answers
372 views

upload table to ArcGIS Server

We are building a process which will allow users to submit a table of GPS data to update our central repository for all GPS data. Let's say that the target is simply a SQL data table. At first I ...
2
votes
1answer
28 views

How to do loops on raster cells with python console in QGIS?

I'm new here and beginner with python. I'm looking for a solution to my problem for some hours but now you are my last chance... I'm using the python (2.7.5) console in QGIS (2.4.0). Is there a ...
1
vote
1answer
227 views

ArcPy error: Add Feature Class to Terrain. [closed]

I'm writing a script to convert lidar data (in .las format) into a terrain without going through all the clicking and so I can send it out to neighboring states with similar programs (I'm using ArcGIS ...
0
votes
1answer
88 views

Using Union on multiple shapefiles to output single result

Using QGIS 2.2 and Python, I would like to use the Union algorithm on multiple shapefiles (contained in a folder TEST) which would then produce single shapefile containing all the data. Currently ...
1
vote
1answer
26 views

Import arcpy using PyScripter or IDLE gives No module named RuntimeError?

I'm trying to figure out this problem. Yesterday I installed PyScripter and since then, scripts doesn't work. When I run any script (in PyScripter or IDLE) which uses "import arcpy", I get this error ...
4
votes
2answers
69 views

ArcGIS Toolbox, parameters for python script not as positional arguments

I have an ArcGIS Toolbox with a bunch of parameters. A python script is used to perform some raster operations, based on this parameters. I am using Python argparse in the script to get the ...
1
vote
1answer
45 views

How to write output from subprocess to disk (using multiprocessing)

This code was developed from another question I posted about how to kill an arcpy tool if it takes longer than a specified time. See How to cancel tool execution in python. Using the multiprocssing ...
0
votes
1answer
11 views

ValueError using MapProxy decorate image middleware with WMS

I am successfully using Mapproxys decorate image middleware to apply a watermark to WMTS tiles. I am using the following code: def annotate_img(image, service, layers, environ, query_extent, **kw): ...
4
votes
1answer
90 views

How to cancel tool execution in python

I've written a python function that calls a tool (Import CAD to GDB) in a loop. When I run it I have seen that it hangs sometimes, and I have to force the script to quit. I am wondering if there is a ...
1
vote
1answer
431 views

Linux Client for OpenGTS server

I've installed an OpenGTS server and successfully linked it with the GPS2OpenGTS_Pro application for android. The buses I'm tracking offer 3G with a wireless AP, however whenever the bus stops, the ...
0
votes
1answer
53 views

What is the syntax for Python 2.7 to permanent display in percent in a field column?

What is the syntax to build to calculate field, for example, Acres to Percent? 841173.00 to 82 % What I want the field column in Percent to be display numbers with percent with the alignment to ...
1
vote
2answers
73 views

How to merge dbf files(zonal statistics as a table) in GIS environment.?

I am not very savvy at using Python. Actually I have around 1000 output files from using the tool zonal statistics as table in ArcGIS. The names of the files are jan_60, feb_60......dec_13. These all ...
0
votes
2answers
33 views

Error while importing CSV File using PyQGIS

Currently I am trying to import a CSV file using the python extension in QGIS and I have run into a problem that I can not seem to solve. I am trying to do a basic import of a CSV file from a python ...
0
votes
1answer
45 views

Python library or algorithm to generate arc geometry from three coordinate pairs?

I'm trying to write code to generate fixtures for a django/geodjango project. I need to generate geometry for arcs (line string) given three lat/long pairs; start of arc, end of arc and centre of arc. ...
0
votes
0answers
11 views

How to get sql error from postgis when a plugin fail to load vector layer?

I am writing a plugin for qgis that load a sql layer from postgis database. I am disappointed that when the layer fails to load i can't find a way to get the sql error message from database server. ...
0
votes
1answer
405 views

ArcPy SelectLayerByAttribute Error and how to control GP output layer name

I have a rather long script that first references an SDE feature class (non-versioned) to perform an attribute selection based on a SQL selection. I've been unable to figure out why the script will ...
0
votes
0answers
17 views

40k+ points from Shapefile, clustering them and populating on Google Maps/Webapp

I just started a new Python/Django webapp job related to GIS (and i'm totally new to GIS). Here is my task and what i have found so far, and i am stuck as to finding out what's the best way or the ...
6
votes
3answers
4k views

Splitting lines automatically at specific distances using ArcGIS Desktop?

I have a set of polylines which I need to split at varying distances from their starting points. In general, I'm looking for a something similar to the SPLIT function within the editor tool. There ...
1
vote
0answers
18 views

Import QGIS Python modules in Python command line or standalone script

I am running a Windows 7 machine with Python version 2.7.8 (32 bit). I installed QGIS 2.4 (Chugiak) from OSGeo4W and simply want to be able to import the QGIS Python modules (e.g. qgis.core) into ...
1
vote
1answer
108 views

QGIS Python Labelling

i want to label a point layer with those values exceeding a set of variables attribute table as follows 'loc field'(text),'a'(float),'b'(float),'c'(float) variables as follows vara = 5, varb = 3, ...
4
votes
1answer
287 views

How to write scripts that can call on both Arcpy and PyQGIS?

I have spent quite a bit of time looking for a clear answer this topic and have still been unable to really accomplish my goal of accessing PyQGIS in a stand alone script. Parts of answers have been ...
2
votes
3answers
100 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 ...
1
vote
2answers
30 views

How to find the minimum pixel value within a region of interest?

I am working on a Python script for dark object subtraction, a radiometric correction method for remotely sensed data.To accomplish this, I need to find the minimum band pixel value of a waterbody ...
2
votes
1answer
31 views

Randomly choosing one from multiple fields in Field Calculator of ArcGIS for Desktop?

Using the Field Calculator in ArcGIS for Desktop, I want to randomly choose one field from a list of 10 fields (strings). The Excel equivalent, which is working, is: =INDEX(A2:J2;rnd()*10+1). How ...
5
votes
1answer
172 views

Calling external files in Python Geoprocessing Service

I have created a Python script which calls an R script and then reads the output back into Python. I can run this tool in ArcGIS Desktop (10.2.1) and it works fine. When I publish as a geoprocessing ...
6
votes
1answer
148 views

How to classify time periods in a new field, using Python?

I have a datetime field (Horario) in my feature class, showing only the time. Although the date doesn't appear, it seem to be stored automatically as 30 Dec 1899, I'm not sure why. I want to use ...
0
votes
2answers
30 views

Export Raster Data to TIFF, BMP, or PNG File Using Python

I am writing a Python script to export a Raster Dataset to a TIFF, BMP, or PNG file, as I would manually by right-clicking on the layer, choosing Data | Export Data, and then make my choices in the ...
4
votes
1answer
125 views

How can I modify layer order with the QGIS python API

Typically, after a new_layer = addRasterLayer(...) that inserts new_layer before the active layer, I'd like to move it to the top of the table of contents. How to do it? I use an existing QGIS ...
2
votes
3answers
71 views

How can I iterate Selection by Attributes?

I have a large data shapefile for the state of New York. Each shape has a code corresponding to each county, so I want to iterate "Selection by Attribute" for each code, create a layer from all the ...
1
vote
0answers
26 views

Link to pdf file through mouse clicking

I need help in identifying the feature attributes displaying a pdf file when click in that feature. I see many examples but I don't have success. I try this code: command = "firefox"; imagerelpath = ...
0
votes
0answers
27 views

QGIS Init script: How to get active layer and GID of edited object?

I would like to ask, how to get the GID (from Postgresql+Postgis) and active layer of edited object in QGIS Init script (Python)? Code Layer=qgis.utils.iface.activeLayer() works in QGIS console, but ...
2
votes
1answer
71 views

How would I group values in a field based on range of number using python, and then update the attribute table?

An example of what I'm trying to accomplish is described below, however they don't describe how to use the data update cursor to update the attribute column. data - Group values based on range of ...
0
votes
1answer
25 views

Python for loop doesn't work for Spatial ETL Tool

I've created a Spatial ETL tool from ArcGIS 10.1 and would like to run this tool to all 200 featureclasses in a geodatabase. Therefore, I've written a python script to do this automation. (btw, i'm ...
2
votes
2answers
123 views

Is there a function to select a region of a map for further processing with Python?

I would like to select a map's region in QGIS for further processing with python console. Ideally I would like to select the region with a mouse drag (like Gimp crop function) and then e.g. analyze ...
3
votes
1answer
911 views

insert cursor “Row contains a bad value”

I'm having a problem copying data from a shapefile to a feature class using an insert cursor. Here is the part that is causing trouble: newRows = arcpy.InsertCursor(Target) sourceRows = ...
0
votes
0answers
20 views

Using python libary simplejson and urllib in PostGIS

I installed PostGreSQL9.3 and want to create a Pl/Python function using simplejson library and urllib. First I use OSGeo4W Shell to test the similar python script, it works. Then in PostgreSQL, it ...
0
votes
1answer
60 views

Summing column values in table using arcgisscripting?

I need to create a python script that sums a column's values in a table. Thereafter, the script is supposed to get the percentage of each individual row in that column and populate this percentage ...
0
votes
0answers
27 views

How to select duplicate polygons? [duplicate]

Although it may seem this has been answered before, there doesn't seem to be a solution. I am trying to simply select duplicate polygons. I don't want to delete them or anything like that. I need ...
1
vote
0answers
27 views

Why does this python OGR code for creating a layer and then adding a field not work?

Spot the difference! So this works... fp = "C:\\LiDAR\\MyLayer.shp" layer = "MyLayer" driver = ogr.GetDriverByName("ESRI Shapefile") data_source = driver.CreateDataSource(fp) srs = ...
0
votes
1answer
26 views

List index out of range error

I've been writing a script that clips large datasets based on a selected feature. It works fine when I run it in a test workspace where only related layers are active and running. However, when I run ...
0
votes
0answers
15 views

Exporting ArcSDE feature class to shapefile using OGR?

I'd like to export data from ArcSDE for SQL Server to SHP. I've tried first to run this python script in QGIS: http://trac.osgeo.org/gdal/browser/trunk/autotest/ogr/ogr_sde.py But finally I've got ...
2
votes
0answers
33 views

How to check whether an optional FeatureSet parameter was set by the user in a geoprocessing script tool?

I have created a custom geoprocessing script tool which contains an optional FeatureSet parameter. When unpacking the parameters in the script, the FeatureSet is defined as a RecordSet object, even ...
10
votes
2answers
517 views

Is there a compelling case to learn/use Python Toolboxes (new at ArcGIS 10.1) over Python Script Tools?

I've written a few Python Toolboxes (which are new at ArcGIS 10.1), but am yet to decide whether/when I should write them rather than Python Script Tools in a standard toolbox. I thought the Online ...
1
vote
1answer
163 views

Select a single entry using SearchCursor and create variable

I am trying to select a single entry of a floating point entry in a dbf table that contains 9 entries (sampled from a raster image), some of which is NULL using SearchCursor. I want to select one of ...