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

learn more… | top users | synonyms

8
votes
0answers
170 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 ...
6
votes
0answers
340 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
99 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: https://www.dropbox.com/s/fmomfpro3j6dmz8/...
5
votes
0answers
111 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
43 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 ...
5
votes
0answers
178 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
706 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
100 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
107 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 "PostgreSQL\...
5
votes
0answers
521 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 = "slope5....
4
votes
0answers
53 views

Cannot Open VRT of Sentinel2 image created by AutoCreateWarpedVRT

I am trying to create a warped VirtualRaster of a Sentinel2 image. Here the Python code I tried: from osgeo import gdal, osr srs = osr.SpatialReference() srs.SetFromUserInput('EPSG:32632') gdal....
4
votes
0answers
30 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
54 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
52 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
61 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
61 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
80 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
73 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
28 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
701 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
502 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
32 views

How to access qgis module from my virtualenv

I am running an Ubuntu 14.4 and I have installed a python virtual environment. Then I pip installed several python libraries (gdal, lxml, psycopg2 etc.) Also in my system I have the module for qgis. ...
3
votes
0answers
45 views

Python QGIS crashes within categorized renderer setup

I'm hassling around with QGIS renderer definitions in python with QGIS 2.8 at debian wheezy. At least I want simply build step by step a categorized renderer to fill a polygon. The script crashes, ...
3
votes
0answers
53 views

How to handle large tables in QGIS using python?

I'm currently writing a plugin that calculates values based on a QgsVectorLayer's attributes. To display and print the values I'm using a QgsComposerTextTableV2. I have several problems with my ...
3
votes
0answers
75 views

Using ogr2ogr in python?

I found this helpful post that got me started using ogr2ogr in python: Using ogr2ogr to convert GML to shapefile in Python? as well as this one: How to convert ArcGIS Server JSON to GeoJSON? I am ...
3
votes
0answers
36 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 "/usr/...
3
votes
0answers
98 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
65 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
72 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
33 views

Export multiple Layer Definition Files (qlr)

I have a postgresql database with approximately 400 tables. I need to generate Layer definition files (qlr) in QGIS for each individual table. Making this manually would take huge amount of time, so I ...
3
votes
0answers
63 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
43 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
176 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
84 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
142 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
67 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
69 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, Point(markers....
3
votes
0answers
90 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
101 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
128 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
47 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
361 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 https://www....
3
votes
0answers
101 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 accomplish ...
3
votes
0answers
206 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
90 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
155 views

How to create line segments between pairs of pixels in a raster?

I want to draw several lines between pixels (please see the image below) according to some criteria : First Criterion: The distance between 2 pixels is less than 2000m and greater than 500m ...
3
votes
0answers
167 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
122 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
38 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 point-...
3
votes
0answers
135 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 ...