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

learn more… | top users | synonyms

1
vote
2answers
3k views

How to terminate Python scripts in Processing framework properly?

I'm writing a Python script to use it in Processing framework. I need to cancel script execution if certain conditions are met (to save user's time). I tried to use sys.exit(arguments) command. The ...
4
votes
2answers
334 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 ...
2
votes
2answers
820 views

How to create equidistant points in QGIS along a polygon?

I am looking for a solution to distribute with a python script equidistant points in QGIS along a polygon. I tried to use the following code example: http://nathanw.net/2012/08/05/generating-chainage-...
1
vote
0answers
191 views

Create custom “Export To” context menu tool using selected feature in ArcCatalog

I'm trying to create a custom "Export To" script similar to the Right-Click Export Content menu item "To Geodatabase... (multiple)". I have a 3 feature classes in a file geodatabase. I selected two of ...
1
vote
2answers
151 views

How to transfer multi attributes in to features?

i have 2 feature classes, i want to transfer all attributes by one click to another attribute feature class, i have used Spatial Adjustment tools, but the challenge with me is to, how to transfer all ...
2
votes
1answer
1k views

How to make autoIncrement number start with (001…009, 011…099)?

i have a challenge with my time in my work, i have feature class called "Parcel" storing many data, i generated an autoIncrement number by using field calculator, in field "parcel code" Expression: ...
-1
votes
2answers
271 views

How to get layer extension info via Arcpy

I want to get file format of a layer with using Arcpy. I am writing a tool that needs to take raster or feature extension like SHP, TIFF etc. Which functions should i use ? Note: I use ArcGIS 10
1
vote
1answer
99 views

python scripts for accessing info from a postgresql database in case of a qgis application?

I am beginner and I need to know if I could access a postgresql database from python script made for a qgis application
0
votes
1answer
92 views

How to Add Field Between Two Existing Field in Shapefile

Can you please let me know if it is possible to add a new Field between two existing field using ArcPy? For Example if I have "Name", "Area", fiels already in my shapefile can I add a new field called ...
3
votes
1answer
340 views

How to apply a color gradient to a shapefile from QGIS console?

Anyone knows how to do a color gradient from the console to a shape file in Qgis (orin Python)? Like the image below.
3
votes
3answers
1k views

Formula for coordinates (lat, lon), azimuth and distance.

I would like to know how to find a set of coordinates on a small circle some distance from another point. For example, lets say A = (39.73, -104.98) #Denver B = (39.83, -106.06) #point ...
0
votes
1answer
371 views

Python: Using re and update cursor over three columns [closed]

I'm working on this code and got a little to excited...only to find out it wasn't perfect! I'm trying to eliminate the suffix (row1) of roadnames(row0) and parse just the roadname to a new field(row2)....
5
votes
2answers
657 views

Auto-updating symbology between *.mxds for same shapefile using arcgisscripting?

I have a variety of .mxds for any one project I'm working on, which are all different but all use the same set of base shapefiles for my project. I know I can save a .lyr version of my initial ...
4
votes
1answer
190 views

Are Date columns in feature classes stored as python datetime objects?

I have a Date column called readings_measurement_tstamp stored in my feature class. I would like to add a String column to this feature class and Field Calculate it to be be just the %H:%M:%S ...
0
votes
0answers
84 views

Loading QGIS and files from Python's use of os.system?

I am trying to open QGIS and load two files using the following code in Python: os.system('qgis D:\data\vector.shp D:\data\raster.tif') However it returns this error message: 'qgis' is not ...
0
votes
2answers
225 views

Adding Python Script to Custom Tool

I am probably making a simple mistake but can't seem to figure it out, only a beginner.The Select By Location Script is working and it exports to excel when it is run from Python GUI, it also works in ...
1
vote
1answer
217 views

Polygons not appearing when creating shapefile based on criteria using GDAL and Python (area calculated properly)

I am looping over the features of a shapefile containing multiple polygons. If certain criteria are met, I want to save the current feature in a new shapefile. I am doing this using GDAL 1.10.0 with ...
1
vote
1answer
358 views

Flow Direction Arrows in python

Any help would be appreciated. I am trying to write a python script to determine flow direction on a water pipe network. I have calculated the mid point of each section of pipe and created a point ...
6
votes
2answers
707 views

Getting the projection of a LAS file using liblas?

I am using the python api of liblas to read/write las files. I would like to get the spatial reference information of the las file using liblas, but have been unable to figure it out. Can anyone ...
1
vote
1answer
854 views

using GDAL/python to stack georeferenced images of different sizes

I am in the process of porting a code I wrote in IDL (interactive data language) to python but am running into a bit of a problem that I am hoping someone can help me with. The code goes like this: ...
6
votes
0answers
334 views

QGIS: How to reverse vertex ordering in polygons

I am working with an Oracle spatial connection in QGIS through which I am accessing and editing a vector layer. I find that when I edit a geometry, the vertex ordering is reversed (to clockwise in the ...
0
votes
0answers
71 views

Why legendLayerActions is not available in QgsLegendInterface

There's a reason why QgsLegendInterface (the python interface to QgsLegend) doesn't expose: QList< LegendLayerAction > QgsLegend::legendLayerActions( QgsMapLayer::LayerType type ) const method? ...
1
vote
1answer
631 views

Reading SBET file in python?

I have an SBET (Smoothed Best Estimate of Trajectory) file that I would like to read in python. I found these links that discuss options for reading/writing SBET files, but I was wondering if our ...
1
vote
1answer
281 views

Unsupported operand error writing to file (Python, arcgis)

In the code below, I get a "TypeError: unsupported operand type(s) for +: 'NoneType and 'str'" on the f.write line. If I don't concatenate, it runs fine, but all the layer names run together. I ...
1
vote
1answer
1k views

Insert Cursor fails to write results to table

Insert Cursor fails to write results to table. The Search Cursor is returning the results, but errors when trying to insert into field. # Insert Cursor for GDB table to GDB table # Import modules, ...
1
vote
1answer
558 views

Convert measurement geometry from ground reference frame to satellite reference frame

I need to convert solar_zenith_angle, solar_azimuth_angle, platform_zenith_angle, and platform_azimuth_angle from a reference frame at the WGS84 surface to a reference frame at the satellite observer, ...
6
votes
1answer
2k views

Why close a dataset in GDAL Python?

I see quite often in Python GDAL code that people close datasets at the end of their script. Why does it makes sense to close a dataset in Python GDAL? Are there any consequences if I don't do it? ...
1
vote
1answer
496 views

Map Layout Elements In New Layer Automated Using Python

I was wondering if there was a way to put a title and integer data from an attribute table in a new layer created in Python. I was able to create a new layer using copy features, zoom to the selected ...
2
votes
1answer
465 views

Clustering polygons by sum of values

I would like to group polygons that (1) are contiguous and (2) when the combined values of field X >= Y. Specifically I am grouping zipcodes that are connected. a group is when 1 or more zipcodes '...
0
votes
0answers
726 views

RasterXSize from gdal Nonetype error

I have this code to create a raster file in python: fileInf = QFileInfo(userIntervals) baseNam = fileInf.baseName() rlay = QgsRasterLayer(userIntervals, baseNam) gdalRast = gdal.Open(str(...
0
votes
2answers
404 views

GeoAlchemy pg_function.geojson cannot be decoded with json.loads

I asked this quesiton over on StackOverflow and thought it might make more sense to post it here given it's GIS nature. Given this function: features being a list of SQLAlchemy objects template ...
2
votes
1answer
543 views

How Can i create a Vector layer from selected features qgis

In my qgis plugin i select dynamically features from a Vector layer. and currently i create a new layer from selection on combining all feature into a new feature: theField = QgsField self.theString =...
2
votes
1answer
603 views

Automatic calculation in one attribute table based on values in another attribute table using python

I am trying to fill the fields of one gdb table based on some statistics over the attributes of another shape file. As it was not possible in ARCgis directly, I am trying to use python coe for this ...
6
votes
2answers
211 views

Distribute QGis plugin which depends on certain Python packages

I developed a plugin for Qgis which depends on some Python packages. On Linux and Mac, this is not really a problem because I can easily install them with the system pip command. Windows is another ...
0
votes
1answer
3k views

How to set PYTHONPATH in OS X to use PyQGIS?

I am trying to use PyQGIS in custom applications. I am on Mac OS X 10.9 with QGIS 2.0.1-Dufour. I know I have to set the the PYTHONPATH environment variable. This is the path to QGIS on OS X: /...
1
vote
1answer
886 views

Why does ListLayoutElements give IndexError: list index out of range?

When trying to create a legend on ArcMap use the following Python/ArcPy code I received an error message: import arcpy mxd = arcpy.mapping.MapDocument(r"E:\cities\MyProject.mxd") df = arcpy.mapping....
0
votes
0answers
90 views

Populate a new field with list of the top 5 values of all fields for that record

I have 15 fields. I would like to add a new field that is populated with the field name and value of the top 5 highest values of the 15 fields for each record in the table. The new field would be a ...
0
votes
0answers
246 views

Calculating distances between boundaries of polygons with Python

I have two sets of shape-files which have to be worked on within a Python Script. Those two Shape Files might differ from each other (same thematic content, but 2 different epochs). If there occurred ...
0
votes
1answer
1k views

Finding differences between two shapefiles in Python

I'm trying to find out whether there were any border changes between two yearly shapefiles. I've heard a lot of praise for Python's open source GIS tools like Shapely/Fiona, and thought I would try ...
0
votes
0answers
268 views

Change symbology of layer of unique symbol to unique with python

I have a problem concerning how can I change the symbology of a layer with unique symbole to unique values. I don't know how to update it. I used this code: import arcpy mxd = arcpy.mapping....
0
votes
1answer
146 views

How can i stop rendering Qgis

In my python plugin ,i select features from a vector layer dynamically using a loop and executing : VectorLayer.select(feature.id()) when i start the loop, the selection become very slow because ...
0
votes
0answers
52 views

How to get data from the selected features and embed to a particular featura class

I am trying to write a Python script for ArcMap 10.2. When the user selects some features I want certain data to go to a certain point file. For example, I have a polygon that contains parcel data. ...
0
votes
1answer
129 views

ArcToolbox model run but warning output in Python

I have created an ArcToolbox and a Model in the toolbox. It uses a lot of Spatial Analyst tools and deals with raster images. When I imported the toolbox in a Python script and ran the model from ...
1
vote
1answer
107 views

Trigger custom geoprocessing tool outside ModelBuilder?

I have created a model in a custom toolbox with ModelBuilder in ArcMap 10.1. Is it possible to trigger the model outside ModelBuilder and ArcMap? For example, use a Python script to trigger the ...
1
vote
2answers
136 views

Custom BatchProject Script

Here's my problem. My GPS collects data in WGS1984 and I have decided to start working in UTM instead of state plane. Needless to say, I would edit shapefiles, not paying attention to what ...
1
vote
0answers
78 views

Arcpy PageLayout.dll Errors in Python

import os import arcpy arcpy.env.overwriteOutput=True folderPath= raw_input ("Enter directory: ") filePath= raw_input ("Enter data repository: ") f = open((os.path.join (filePath,...
2
votes
2answers
231 views

How to create simple select script in ArcPy?

I am new to Python and want to create a script inside the ArcMap Python window. My current workspace is a series of rivers portrayed in the state of Ohio. I have a list of fish and the rivers (from my ...
0
votes
2answers
107 views

ArcPy symbolize layer if a value is correct

I want to symbolize a layer in an active session and add to display if some kind of value is right. I found a way to symbolize in an active session here So i tried to extend it, but unfortunately it ...
4
votes
2answers
393 views

Create network from shapefile without ArcGIS?

I want to perform shortest-path analysis on a network whose edges represent real-world roads and whose nodes are buildings or other locations. I have the shapefile for the area I'm interested in. ...
0
votes
1answer
783 views

How to extract list of layers in MXD using ArcGIS Desktop 9.3.1 and Python 2.5?

I have been trying to extract a list of all the layers in my mxd (Arc9.3.1), using Python 2.5. If I could have the source of the layers too that would be even better... But as long as I can get a list ...