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

learn more… | top users | synonyms

2
votes
1answer
151 views

Standalone script looping incorrectly?

Following on from my previous question, I would like the script to do the following (includes illustration): Search for the first shapefile (Paris (O).shp) in Country_France > Original files and ...
2
votes
1answer
72 views

PyQGIS: subtracting two values and append ID to list

I would like to subtract two values retrieved from qgs feature iterator objects and append the value of the feature id to a list depending on a condition. I have two layers: roadsLayer pathsLayer ...
2
votes
1answer
93 views

QGIS Python - raster as point layer, coordinates issues

I would like to create point layer for storing values retrieved from a raster file. My idea was to iterate through all raster cells. If cell value is different than NULL, I wish to create a new point ...
2
votes
1answer
119 views

Python GDAL: ogr.open or driver.open?

I’ve been using GDAL with python to manipulate shapefiles. When opening a source file I first set the driver to “ESRI Shapefile” before calling the driver’s "Open" method with the required shapefile. ...
2
votes
2answers
149 views

What is the “best” way to automate the GIS slope and aspect algorithm?

I am currently obtaining slope and aspect of roofs using ArcGIS as follows: Mosaic several Lidar .asc files to new raster Extract by mask using Mastermap building outlines to get hold of just the ...
2
votes
2answers
112 views

Is it possible to sort the features by an attribute programmatically?

I have written a PyQGIS script that loops through an attribute table and finds duplicated values in a target attribute field. My technique requires that the attribute table is first sorted by the ...
2
votes
1answer
62 views

How to find the distance of a point from the begning of a StringLine with shapely?

I have a route (represented by StringLine) and a location (Point) and I need to find the progress of the location in the route. The progress is the distance in meters from the begning of the route. ...
2
votes
1answer
106 views

QGIS Modeler flexibility and errors?

I'm trying to build a simple multi-step selection (by attribute) with the QGIS Modeler. I created a simple sample layer to avoid data-driven errors. Now I want to query the layer and select features ...
2
votes
1answer
67 views

Odd behavior in a QGIS plugin: my function is triggered twice

I have a plugin with a function (triggered by a button) that selects a specific layer by name, then shows its attribute table. When I close the plugin and open it again, the attribute table pops up ...
2
votes
1answer
165 views

Why processing.runalg(“gdalogr:rasterize”…) is not creating out files when running in the QGIS 2.6.0 console?

I want to use the QGIS python scripting functions to turn to rasterize a point vector using many different dimensions. Right now my code looks like this: import processing RasterPixelSize = ...
2
votes
2answers
108 views

How to get cell value along Flow Direction

I have: a flow direction raster where I took off (assigned NoData value) the cells that overlayed the river network (from flow accumulation). a perfectly overlapping raster where I asigned a ...
2
votes
1answer
114 views

Issues with PyQGIS while running a QgsZonalStatistics script

I have experienced a very bizarre issue with my PyQgis code. I simply want to load a raster and a vector layer to do zonal statistics, the first part works perfectly but for the zonal statistic I have ...
2
votes
1answer
88 views

Error with Python Script using Shapely

My professor gave us a basic Python script that demonstrated how Shapely works with a shapefile, however it's not working for me. Here is the code: from shapely.geometry import mapping, shape from ...
2
votes
1answer
84 views

Getting values from Qt widgets and using them for a buffer

I am writing a simple plugin that finds buffer. My gui has 2 combo box and 1 Line edit. The first combo box will have a drop down of values from column 'States' and 2nd combo will have a drop down of ...
2
votes
1answer
203 views

How to move layers in the QGIS Table of Contents via PyQGIS?

I have loaded two layers in canvas and would like to move the layers using the following code in TOC, but it is not moving the layers to the position based on the index given. from PyQt4.QtCore ...
2
votes
1answer
158 views

How to apply a filter to multiple vector layers in QGIS?

I am trying to apply an attribute filter to multiple layers in QGIS at once. The filter is to be applied to .osm data brought in through PostGIS to QGIS. I have tried selecting multiple layers -> ...
2
votes
1answer
298 views

How can I iterate over several layers and run a process using PyQGIS?

I am trying to find road intersections within each of my memory Polyline layers (which are named road_layer_i for i in (0-99)) so this is what I tried: import processing self=qgis.utils layers = ...
2
votes
1answer
174 views

How to list items in a raster catalog?

I have a managed raster catalog in a file geodatabase that is comprised of 12 images. The screenshot shows the raster catalog footprint with the names of the tiff images that make up the raster ...
2
votes
1answer
134 views

Layer properties dialog in my QGIS plugin

I am developing a plugin which should display some information like geometry of the layer, feature count etc. Now those are currently displayed in QMessageBox.information. I want it to be displayed ...
2
votes
2answers
112 views

How to make a list of ESRI GRID rasters in Python

Tipically, ESRI GRIDS are not defined by a file extension like for the .tif files, but they are stored in a info folder plus an extra folder corresponding to the name of the raster. Arcpy allows to ...
2
votes
1answer
125 views

Edit attribute table for shapefiles in folders and subfolders with arcpy?

Continuously to Merge shapefiles in folders and subfolders with arcpy I try to edit attribute table for 20 shapefiles that spread in big a folder and are divided to a lot of sub folders. All ...
2
votes
1answer
221 views

Load the raster image which is in TIF format using QGIS API

I am quite new inthe field of GIS. I am interested in is to load the raster image which is in TIF format using QGIS API I have followed the steps given the in the follwing link to load shape file ...
2
votes
1answer
81 views

Python library for geometrical calculations using with GRASS GIS?

I have to do some geometrical calculations in 2D(point, lines, line segments and intersection points) in Python, and then use it in GRASS GIS. What is the best library to use for it? I'm trying with ...
2
votes
2answers
150 views

Select Layer By Attribute to be used in for loop

I'm trying to iterate through a feature class and select each feature one by one by using the OBJECTID field. When I use a single value, the SelectLayerByAttribute works, but how do I compare the ...
2
votes
1answer
78 views

QGIS Python SQLite using variable

I have been looking for answers and working on this for many hours. In the spatialite database table nodes, id is an integer. idValToNode = 854 sql = 'UPDATE nodes SET obsolete = 0 WHERE id ...
2
votes
2answers
86 views

List all feature layers

I will often create many temporary layer files with MakeFeatureLayer_management. I was wondering if there was a means to list the temporary layer files I've created. I've tried setting the workspace ...
2
votes
1answer
51 views

MakeFeatureLayer_management wrong output

I have a huge database with Sightings from whales and dolphins from 1995 till today. So I want to sort the database with python. Till now I can make FeatureLayers for each year for ...
2
votes
3answers
246 views

Executing Python code takes a lot of time (more than 2 hours)? (Arcgis10.1)

I am executing this Python code, in which I am trying to determinate the position of neighbor parcel (north, south, east, west). It works fine but it took 2 hours for just 50 parcels! I think that ...
2
votes
1answer
69 views

Qgis how to combine a geotif with a country border shape file?

I have 2 files. A geotif with different values and 1 shape file with country borders of this area. Can I generate with this 2 files an image with the country borders and the data from the geotif? ...
2
votes
1answer
68 views

Nested SearchCursor functionality

I am trying to ultimately compare the gate height to the corresponding fence height located nearby. So far I have come up with the following: gates = "gate_line" fence = "fence_line" ...
2
votes
1answer
159 views

How to format an excel table using python

I am trying to come up with a way to export an attribute table as a formatted excel table in ArcMap 10.2. I am aware that there is a "table to excel tool" in the conversion toolbox, but I am not sure ...
2
votes
1answer
190 views

How to geocode a single address in Python Script/ ModelBuilder?

How to geocode a single address (not table of addresses) in ModelBuilder and/or python Script? I want to enter the address and then geocode it. I am using arcgis 10.2.2
2
votes
1answer
134 views

How to create layer group in geoserver with gsconfig?

How can I create layer groups using python gsconfig ?
2
votes
3answers
123 views

Find coordinates of given raster value

I would like to get the coordinates of a raster cell with a given value. I suppose many cells can take the same value, in which case several coordinates should be returned. In my first problem I'm ...
2
votes
2answers
148 views

How can I select features based on another feature attributes?

Here is my case: I have a layer of features (buildings from a city) that is populated with polygons. This polygons have attributes : street name and postal code In the project I have another layer of ...
2
votes
1answer
86 views

QGIS select reversed geometries

I have a road network and a geometry for each road direction. One Geometry from A->B and another Geometry from B->A. This geometries are covering each other. Is there a tool available in QGIS to ...
2
votes
1answer
53 views

Arcpy PointGeometry does not carry forward the ID

I used this as starting point I have the following code: Test data data = numpy.array([(0, 51.1047664, -114.3722785, 1205, ...
2
votes
1answer
60 views

How to find length of a discontinued line feature

I wanted to find the length of features in a road layer. So I go through each feature in the layer and used, line = feature.geometry().asPolyline() to find the points which particular feature is ...
2
votes
4answers
282 views

Converting a large set of GRIB2 files to a spreadsheet format

I have a large set of .pgrbf.grb2 files downloaded from the Climate Prediction Center, and I need to run statistical analyses comparing them to data that was produced locally in .csv format. I'm not ...
2
votes
2answers
221 views

Store result from gdallocationinfo as variable in python?

I'm trying to find the cell value at various locations in a set of rasters so I can count the number of real values (aka not 'NoData') that occur at all the locations within each raster. The various ...
2
votes
1answer
183 views

Changes not persisting in ArcGIS server from ArcPy script

I have a ArcPy script (10.2) which connects to an ArcGIS server (10.0) versioned geodatabase, via an .sde connection file in the Database connections directory through direct connect on a Microsoft ...
2
votes
2answers
87 views

ArcGIS Field Calculator passes European-formatted floats as tuples

I have the problem that the ArcGIS Field Calculator doesn't read a float number when it is included in Python by referring to the field that contains it, in this way: def giveResult(floatValue): if ...
2
votes
1answer
233 views

select random rows with python in arcgis

I am new to using Python in ArcGIS, and I wonder: how do I select random lines (or every two lines) of an attribute table? I must select these lines and calculate them, so they are different from ...
2
votes
1answer
203 views

arcpy with multiprocessing throws “UnpickleableError: Cannot pickle <type 'geoprocessing Layer object'> objects”

I'm attempting to speed up a process which is currently running synchronously, by using the python multiprocessing module. I'm having trouble sending a feature layer to a function which is called by ...
2
votes
1answer
418 views

How to properly import QImage from PyQt4.QtGui?

I am starting with QGIS python console. Naturally, I came across the PyQGIS Developer Cookbook. While trying to cut my way through it, I encountered a lot of problems with "undefined attributes and ...
2
votes
1answer
266 views

Python loop with address locator

I was given a list of addresses without any zip codes, and I'm trying to write a python snippet that will loop through a set of possible zip codes and make a set of geocoded shapefiles that I will ...
2
votes
1answer
234 views

Cannot load postgis layer from sql string in pyqgis

I'm trying to load a layer using the following code in qgis python console: sql = "(select the_geom, ID from mytable)" uri = QgsDataSourceURI() ...
2
votes
2answers
492 views

How we can get output for os.system() in python?

I wrote the following command in Geoserver rest-api using curl: cmd=curl -v -u admin:geoserver -XGET -H "Accept: text/xml" ...
2
votes
1answer
81 views

How do I rename rasters in an mxd by using my csv?

I have the following data in a csv: RasterName First name Raster 1 Aaron Raster 1 Paul Raster 2 Bryan Raster 3 Cranston Raster 3 Vince I have added these ...
2
votes
1answer
486 views

UnicodeDecodeError: While installing gdal in a new Python Virtual Environment

I was trying to create a Python Virtual Environment for some initial GIS development. I installed pip and virtualenv and then tried the following commands from the Linux-Terminal to accomplish the ...