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

learn more… | top users | synonyms

9
votes
0answers
912 views

Link QGIS to Anaconda Python Distribution: Spyder, iPython Notebook, pip, scikit-learn

I have Anaconda as my primary Python distro, and want to route Python related QGIS scripts through it. With Anaconda, I have Spyder, can easily install packages with pip, and can launch a iPython ...
8
votes
0answers
139 views

How to access a deleted features attributes (before committing)

I have a signal setup for a feature deletion event on a layer: self.layer.featureDeleted.connect(self.feature_deleted) When I try and grab an attribute from the deleted feature on the slot, a ...
7
votes
0answers
237 views

Automating creation of ServiceDefinition from Python script tool of ArcPy without broken project data source?

Summary: I can create a ServiceDefinition through ArcCatalog or ArcMap, but when I try to generate the ServiceDefinition through python, it does not copy the /data folder with it, thus the script ...
7
votes
0answers
337 views

Performing buffering and intersection with script in PyQGIS

I wrote a script that performs the intersection of two layers: The first Layer -> layer1, represents the rivers The second Layer -> layer2, represents a set of circular dots distributed in a ...
7
votes
0answers
687 views

How to get rpy2 for QGIS on OSX?

I am a new QGIS user, have installed QGIS on a Mac running Snow Leopard OSX 10.6.8 following all the instructions. QGIS seems to work well for everything other than when I boot up I get the message ...
6
votes
0answers
98 views

Can a memory layer be used as an input and/or output with runalg?

Can a memory layer be used as an input and/or output with runalg? With runandload I get this to work: processing.runandload("qgis:mergevectorlayers","memory:bufferOne", "memory:bufferTwo", ...
5
votes
0answers
86 views

Different results from GDAL raster attribute table command on mac and windows

I am trying to get the raster attribute table of the following file: Shift_cult_past_current_prediction_20160107_gr1DD.tif available here: ...
5
votes
0answers
89 views

How to fill composer map with canvas data and export composition as png using Python script in QGIS

I'd like to create a Python script in QGIS that will take some data (shp + tif, in my example), use tamplate Map Composer (from a file) and export created composition to a png image. With almost no ...
5
votes
0answers
139 views

Counting features into intersections of Shapely Polygons

I have a geopandas GeoDataFrame containing hundreds of shapely Polygon and MultiPolygon geometries. The polygons overlap in lots of places. I'd like to make a new geometry that contains a count of how ...
5
votes
0answers
625 views

RGB satellite image in Python with Basemap

Can anyone recommend a workflow or python library that will let me work with RGB images and BaseMap (or something equivalent - could be CartoPy). I have Landsat 8 images, and can load one in python ...
5
votes
0answers
92 views

Is it possible to add an ArcGIS attachment to a row in Oracle using oracle stored procedures?

So far I have been able to attach files to features within a featureclass using the python tools and ArcObjects. Within Oracle I have been able to add features with geometries using the ST_Geometry ...
5
votes
0answers
103 views

Diminishing performance of gdal_polygonize in a python subprocess for GRASS to PostgreSQL

I have written a python script to polygonize GRASS rasters into a PostgreSQL database using the gdal utility gdal_polygonize: sub.call('gdal_polygonize.py -8 gdb/quercus/{0}/cellhd/{1} -f ...
5
votes
0answers
324 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 ...
5
votes
0answers
506 views

How to convert a raster (array) to a NetworkX graph and do a * search?

I want to use a slope-raster for a a_star path analysis in NetworkX. I am using Python for this project. My test raster looks like this First I read in the raster with GDAL input_raster = ...
4
votes
0answers
27 views

Using QgsNewVectorLayerDialog

I am using QgsNewVectorLayerDialog for taking user input for creating a new shape file. When the user clicks OK i am reading the inputs selected by the user using the following code. dlg = ...
4
votes
0answers
53 views

Issues updating field values programmatically for particular field data type on 64bit Windows computer using QGIS 2.8.7

I have an issue with a plugin for QGIS 2.8 I'm developing when using it on a Windows 64bit machine (as opposed to 32bit). I am trying to update values in a particular field in my plugin, and the ...
4
votes
0answers
47 views

TypeError: QgsEncodingFileDialog

I am using the latest version of QGIS (Lyon) on MAC and have set the default Python version 2.7. Moreover, I have installed all the required python modules and GDAL. It was working before, but now, ...
4
votes
0answers
53 views

How do I implement PyQGIS multithreading to update a progress bar

I am developing a PyQGIS plugin using python. I facing a problem during the implementation of threading in my plugin. I have written a python script which contains a class wrapping all geo-processing ...
4
votes
0answers
48 views

How to unproject a UTM ESRI Shapefile over WGS84 extent boundaries

Background: I am working on a collaborative project in Python that uses GDAL/OGR to work with rasters and vectors. There is one function that attempts to project one ESRI Shapefile's coordinate ...
4
votes
0answers
60 views

Custom forms feature in QGIS: QMessageBox.warning closes QDialog as well

I am attempting to work with custom forms in QGIS. I have included a validate function in my code that will pop a QMessageBox() if the validation fails. My problem is that when I close the QMessageBox ...
4
votes
0answers
62 views

SQL SERVER 2012, Python subprocess, OGR

Need help with uploading shapefile with srid 102008 to SQL server 2012. I ran the ogr2ogr script in the ogr shell and it uploaded the shapefile within seconds but when I try using python subprocess to ...
4
votes
0answers
26 views

“Merging” 2 layers of LineString with splits at intersections

I would like to "merge" 2 networks of lines and these lines need to be split when they intersect. With pictures it should be clearer : What to do: if a black line intersects a red line, they ...
4
votes
0answers
38 views

What's the binary format of ENVI (Classic) ROIs?

I'm a (lonely) Pythonist in an office full of ENVI/IDL users. I've created some tools to help bridge the gap, but one big stumbling block is ENVI Classic .roi files, which my colleagues use a lot. I ...
4
votes
0answers
660 views

Connect to QGIS 2.6 Python Plugin function via button on custom feature form

I am trying to connect to a QGIS 2.6 Python plugin function via a custom feature form button. On my feature form, I'm attempting to do a few things : enable the updateButton only if the ...
4
votes
0answers
483 views

Extracting x,y,z values from a postgis linestring to python using ogr

I am trying to load a postgis linestring into python (using ST_DumpPoints) and extracting x,y,z coordinates, which is working but extremely slow..and if i mean slow, i really mean it (yes, it takes ...
3
votes
0answers
24 views

GDAL gdal_polygonize.py TypeError

I am using GDAL to convert a .tif to .shp file. gdal_polygonize.py input.tif -f “ESRI Shapefile” out.shp However this does not work and results in: Traceback (most recent call last): File ...
3
votes
0answers
47 views

GDAL RasterIO performance in C++ vs ReadAsArray in python/numpy

I'm currently writing optimisations for a raster viewer program which uses gdal as it's base. It's currently written purely in python, and has some major speed issues which cause problems when we are ...
3
votes
0answers
53 views

Render Vector & Save as Raster

I am working with ENC files from noaa, specifically S57 format or ".000" to be as specific as possible. I am trying to render a layer or even the entire thing in a window but have had no luck. ...
3
votes
0answers
53 views

How to generate static heat maps server side?

I've been searching a way to generate server side static maps using Python (or any other languages, doesn't matter) I can create the maps I want with Qgis (And they look really great) but I don't ...
3
votes
0answers
54 views

Approach to controlling which layers display in a QgsComposerLegend

I've tried 2 approaches to control what shows up in print legends. Neither of them work which is troubling because other than pruning the layerRootTree in advance of composer.addItem(legend), there ...
3
votes
0answers
39 views

Translating ArcGIS field calculator python expressions in to QGIS field calculator python expression?

I'm transitioning to QGIS from ArcGIS. I'm having trouble getting my python field calculator expressions to work in the QGIS advanced python field calculator. Here is a screenshot of the working ...
3
votes
0answers
139 views

QGIS 2.14 Processing plugin crashes - TypeError: must be string, not None

I've recently installed 2.14, and it worked fine for the first couple of days (Appart from Grass tools), including several program and computer reboots. Today I had this error show up Couldn't load ...
3
votes
0answers
74 views

ArcGis' python library (arcpy) are imported so long

python -c import time; t1 = time.clock(); import arcpy; print('{0} seconds'.format(time.clock() - t1)) 3.60283379862 seconds It takes this long each time i launch my script or test. Is there any ...
3
votes
0answers
73 views

Python script to automate saving satellite images for different combinations of lat longs

PS. : This is my first try at a GIS application. Please forgive if my question is pedantic. I would like to get a series of satellite images all at the same scale centered around different points on ...
3
votes
0answers
111 views

Can qgis_core work with external python distribution (such as Anaconda)

I've built a python application that has its own GUI. I am trying to use qgis.core/pyQgis as map display only. Specifically, i have anaconda 2.3 and its python distribution (2.7.11). After research on ...
3
votes
0answers
61 views

matplotlib show() suspends ArcGIS

I've written a python script to plot a cross-section from a DEM along a line. Everything works fine except when I Show the plot, ArcGIS hangs and I have to force it to close with Task Manager. I ...
3
votes
0answers
51 views

How to use pythons' GeoAlchemy2 to filter on dynamically generated Points?

I'm trying to do something like this SQL query in Geoalchemy2: SELECT district_polygons.district FROM markers, district_polygons WHERE ST_Contains(district_polygons.multi_poly, ...
3
votes
0answers
73 views

How to show only selected features from a a layer in the QgsComposerLegend?

I have developed a custom qgis plugin. I have a button to export the map canvas in the form of image along with the legend. I came up with the following code for the legend: legend = ...
3
votes
0answers
84 views

spatial index intersection with qgsrectangle only computes polygones

I have the problem, that i only get polygon features inside my defined rectangle. If i switch off my polygon layer(s) i get my lines. TOC: Line-Layer on, Polygon-Layer on: i only get Polygons which ...
3
votes
0answers
109 views

Dissolving polygons in a large dataset

I need to dissolve polygons by the ID attribute in a large dataset (+-1gb shapefile). I have been struggling to find an efficient method to do this. I have tried the following methods: Postgis ...
3
votes
0answers
45 views

Batch Georectifying Imagery

I have a large collection of drone images that aren't georeferenced. I'd like to georectify them by pulling projection and coordinate data from the GeoTiff files, but I'm having difficulty. My ...
3
votes
0answers
302 views

Folium heatmap not displaying

I have an output file data.json [{"5403": 2, "9734": 1, "2565": 5, "5087": 2, "9061": 1, "1761": 4, "4811": 7 "1111": 5, "3891": 3, "1962": 3}] and a shapefile converted to geojson ...
3
votes
0answers
97 views

Creating arc segment between two points with common field using Python?

I need to create Arc Segments between multiple points with like data using half the distance between the two like points as the radius of the arc segment. I would prefer to use python to ...
3
votes
0answers
187 views

QGIS 2.8 Python Plugin Unittest Segmentation Fault 11

UPDATE: This issue may be isolated to my MacBook. The seg fault did not occur in testing on Windows. I have put together a sample unit test for a QGIS python plugin. It is causing a Segmentation ...
3
votes
0answers
87 views

Publishing a geoprocessing service that imports modules besides arcpy?

I'm trying to publish a geoprocessing service (10.2.1) that will be used to generate a PDF from a webmap using an MXD layout as a template. The problem is that if I try to import any module besides ...
3
votes
0answers
162 views

How to change the group icon in legend via Python in QGIS 2.6?

How to change the group icon in legend via Python in QGIS 2.6? At version 1.x I did it this way: self.legendTree = self.iface.mainWindow().findChild(QDockWidget,"Legend").findChild(QTreeWidget) ...
3
votes
0answers
121 views

Lining attributes up with features when creating shapefile using PyShp?

I used the Python Module Pyshp to select particular census blocks from the Census's shapefiles and package these into a single shapefile. However when I add this data into ArcMap and right click to ...
3
votes
0answers
117 views

point feature to raster with count of unique points

I am using ArcGIS 10.1 with Python 2.7 I have a point layer with thousands of points that each hold an id value of its owner. One owner can have multiple points, meaning that points can have the same ...
3
votes
0answers
35 views

Action: Move pointfeature to other layer - Point becomes Multipoint

I'm trying to write an action that moves a pointfeature from one layer to another. It works fine until i try to save the layer with the new feature on. He says he can't save a MULTIPOINT to a ...
3
votes
0answers
133 views

arcpy.mapping.ExportToTIFF fails to render layer?

Has anyone else had this problem? I have an mxd file with two layers in it, one of which is fairly 'heavy' (i.e. takes a minute or so to draw). All layers are visible by default. I have the ...