Python bindings for QGIS.

learn more… | top users | synonyms (1)

3
votes
1answer
72 views

Error writing memory layer to shapefile in QGIS

I have created a memory polygon layer in my QGIS plugin. Then I added a buffer based on a point. I can see the ploygon memory layer in the map canvas and I can save it to a shapefile from the main ...
2
votes
2answers
121 views

IdentifyFeature() use via PyQGIS?

Intent is to have two variables (QgsVectorLayer and feature.id() within said layer) as input for the Identify feature map tool in Qgis (2.6). Wondering if a feature can be selected programmatically ...
1
vote
3answers
126 views

How to efficiently access the features returned by QgsSpatialIndex?

The PyQGIS Cookbook explains how to set up the spatial index but it only explains half of its usage: create spatial index — the following code creates an empty index index = QgsSpatialIndex() ...
1
vote
1answer
99 views

How to add fields to shapefile from standalone script?

When I run the following script via OSGEO4W64 Shell, I receive the following error when trying to run the qgis:fieldcalculator algorithm: 'NoneType' object has no attribute 'mapCanvas' I read ...
6
votes
1answer
214 views

How to get the file name of current style using PyQGIS?

I get the name of the current style file using layer.styleURI(). Then, I change the style file using layer.loadNamedStyle(different_filename). However, when I call layer.styleURI() again, it ...
2
votes
1answer
64 views

getting a plugin path using Python in QGIS

How to get a plugin path using Python? I tried QgsApplication.pluginPath() I got u'/Applications/QGIS.app/Contents/MacOS/../PlugIns/qgis' But I actually store the plugin in ...
0
votes
0answers
26 views

How can I include a color legend for my marker colors when i used a QgsCategorizedSymbolRendererV2?

I have this function that sets the marker color to a different RGB value depending on the attribute price level. I would like to also add a color legend showing the marker color with the level of the ...
2
votes
1answer
408 views

Problem with import qgis.core when writing a stand-alone PyQGIS script

I am trying to write a stand alone python script in windows 7 that uses qgis.core and various other qgis libraries. I have found an old question on this subject here: How to write standalone Python ...
0
votes
0answers
24 views

NameError: global name 'QgsDataSourceURI' is not defined

Following on from my previous question I cannot seem to get my function to run using script runner in QGIS. However, if i type then out in the Python Console then they work and load the layer in ...
6
votes
2answers
316 views

Cannot run standalone QGIS script

I've been trying, along with this post, to run a script in OSGeo4w Shell, outside of QGIS. But I get the following error: ImportError: No module named qgis.core I have also read the following ...
1
vote
0answers
28 views

Searching a table within PostGIS using PyQGIS script

Morning all, I am looking for some guidance in trying to set up a script that will search a PostGIS database using a wildcard and then open a certain file directory that will be in one of the fields. ...
2
votes
0answers
63 views

Via PyQgis how to refresh a modified CSV layer without having to reopen the file? [duplicate]

UPDATED: With an CSV layer Qgis workspace [loaded as a delimited text layer], an external algorithm is ran; outputting (writing) new values to certain rows in the layers source CSV file. The writing ...
1
vote
1answer
88 views

Writing a shapefile using OGR, from Shapely Geometry - No feature added Error

I am trying to write a shapefile from a Shapely geometry using PyQGIS in the QGIS 2.6.0 console. Lines of code before the OGR method to write shapefile: extnt = poly.extent() # gives a QtRectangle ...
1
vote
0answers
45 views

How to change values in a raster file at particular positions?

I have a collection of coordinates which comes from a QGSGeometry object. The shape is a polygon. example: qgsGeometry [[(75.2172,17.6566), (75.8499,17.9613), (75.5218,17.2113), (75.2172,17.4574), ...
0
votes
0answers
14 views

How to zoom to the features by selecting the feature with the key event

For zooming to the features first i am selecting the feature and then i am zooming but when i am selecting the feature keyevent stoped working. layer.select(feat.id()) ...
2
votes
0answers
65 views

How to customize the visibility of buttons in QGIS?

The built-in toolbar named "Composer" has an icon "Duplicate Composer". I wish to toggle the visibility of this button in the toolbar. How do I achieve this using pyqgis?
1
vote
2answers
119 views

Vector -> Geometry Tools -> Extract Nodes equivalent in PyQGIS API

My question is fairly straight-forward. Would anyone know the PyQGIS equivalent of the Extract Nodes tool in QGIS? I don't seem to find it in the API documentation. If you do, kindly share the ...
2
votes
2answers
189 views

How to use QGIS explode lines with Python

I want to access the explode lines function in Python outside of QGIS from a standalone script. What module do I have to load in order to use it? How can I access processing? from qgis.core import * ...
1
vote
0answers
24 views

How do I step into the C++ functions from an external Python app I'm debugging?

I just wanted to see how to step into the C++ class QgsVectorLayer()'s methods from the python call to QgsVectorLayer(self.uri.uri(),'foo','postgres'). I'm trying to debug and it trying to step into ...
2
votes
1answer
44 views

Does anyone have any tips on figuring out why a Vector Layer didn't load in Pyqgis?

This is a general question. I'm stepping through the pyqgis code and the layer isValid() is always False. I don't see any error messages showing any reason why it wouldn't load. Other similars have ...
3
votes
1answer
96 views

overlaying raster layer hides my vector layers in PyQGIS

I loaded vector layers and rendered them without a problem but when I tried to add a raster layer as well the map suddenly only shows the raster image and my vector layers are missing. Anything I can ...
1
vote
2answers
78 views

handling QgsVectorLayer (pyQGis begginer question)

I have a simple question. I am trying to start with pyQgis, but I have found it really hard to get a GOOD api Documentation, simple but yet useful. The one of you who did programming in the old ...
1
vote
1answer
69 views

Loading Vector Layer using python console in qgis

I am using qgis2.6 version and new to pyQGIS. I tried to load a vector file using python console in qgis. I don't know where I am wrong. The layer was not loaded and does not show any error too. Help ...
2
votes
1answer
63 views

Calling canvas.saveAsImage from script in QGis -Qstring problem

I want to create a processing script that saves the QGIS MapCanvas exactly as it is seen on the screen and then Zip up the tifw and a created PRJ. The existing QgsMapCanvas.saveAsImage()-method does ...
1
vote
1answer
63 views

Connecting vector label size with map-units?

I have a working application of labels to a point array - but the size of the text is not relative to the map scale. This decreases the readability of labels when panning and zooming. To resolve~ ...
3
votes
1answer
68 views

PyQGIS: Trying to export layer to shapefile

I´m using python in QGIS 2.2 and struggling with an error trying this: # create layer from text _vlayer = QgsVectorLayer(_ur1, "raw", "delimitedtext") works fine but: # export layer to shape ...
1
vote
0answers
36 views

Is there any alternative for reshapeGeometry in Qgis 2.4 version

I am splitting the polygon feature if it intersects with the line feature. I am using reshapeGeometry() but it is nt wrking in qgis2.4. Is there any alternative to use for this one.it is wrking ...
2
votes
2answers
132 views

QComboBox nested within a Qmenu?

Is it possible to nest a QComboBox inside of a Qmenu within QGIS? Below is my current code and an associated screenshot with the unexpected results. (orange = current incorrect placement, green = ...
1
vote
1answer
36 views

QGIS plugin select and edit features performance issues

I wrote a plugin for selecting and instant updating the value of the selected feature in the attribute table. I tested with a big shapefile and to select and edit 5 features takes ~5 seconds. Which ...
3
votes
2answers
119 views

Azimuthal orthographic projection QGIS2.6

I'm trying to create a globe view in QGIS2.6 with an Azimuthal Orthographic projection using NaturalEarth's 110m countries dataset. I'm following Hamish Campbell's blog post instructions that have ...
4
votes
1answer
97 views

Access ESRI .GDB in PyQGIS

I can access ESRI .GDB data using OSGeo's OGR. The following code gives feature class names embedded in .GDB... from osgeo import ogr driver = ogr.GetDriverByName("FileGDB") data = ...
1
vote
2answers
244 views

How to customize the QGIS default GUI using Python?

Is it possible to hide/remove/customize the default UI of QGIS from a Python plugin? I want to add my own menus and toolbars and remove some included by default in QGIS. If it's possible, which ...
0
votes
0answers
22 views

Make qgsmapcanvas.extent().size equal to qwidget.size()

I am using Qt and QGIS to write a touch device application. Right now, I have a QWidget which is the child of qgsmapcanvas, and both of them are full screen. However, the qwidget size is (1920,1080), ...
2
votes
0answers
23 views

How to show combine results or export them with PyQgis

I'm quite new in Pyqgis and i think Pyqgis could make my work easier. I first want to try with a simple code, here is what i want: merge some features and then export them in a shape files. For the ...
1
vote
1answer
111 views

How to draw perpendicular/Parallel line using pyQGIS?

While digitizing a line with multiple segment, how to create a particular segment parallel to (or) Perpendicular to another feature using pyQgis?
2
votes
2answers
229 views

QGIS install on Ubuntu 14.04 fails

Following the QGIS installation guide I have tried both UbuntuGIS and QGIS stable, but both fail with the error message: The following packages have unmet dependencies: python-qgis : Depends: ...
0
votes
1answer
68 views

QGIS plugin select and edit feature attribute [closed]

I'm looking for a QGIS plugin that can change attributes (attribute table) of features on a vector layer by selecting them with the mouse. I found this plugin "SelectTools": ...
4
votes
1answer
147 views

clip geometries in postgis table if they are inside a polygon

I have polygons defined in KML files just like this one, which I can easily parse. Example: <Polygon><outerBoundaryIs><LinearRing><coordinates> -91.463940,40.372660,0 ...
1
vote
1answer
45 views

Adding geometry to QgsVectorLayer with lon/lat coordinates

I'm creating a custom Qt app that uses pyqgis for showing data on maps. I have successfully created a map canvas that shows a world map from a WMS server. Now I'd like to overlay data on this map. ...
3
votes
1answer
76 views

Getting random values from geometryType() in a standalone PyQGIS script

I am asking this question based on the result I received from this earlier post. The following script only works if I set geometryType() == 3 as that is what is being printed out in the Python console ...
2
votes
0answers
43 views

Using pdb in QGIS console

I am unable to use pdb from qgis console. If I run a function that calls pdb.set_trace() I get the error Traceback (most recent call last): File "<input>", line 1, in <module> File ...
2
votes
1answer
113 views

ImportError: No module named processing

this question may have been discussed before but i was not able to find any answer. I am developing a stand alone python script that will invoke methods from processing module. I am seeing error ...
2
votes
0answers
44 views

PyQGIS: standard and advanced linear referencing possibilities

I'm aware of the existence of the following QGIS plugins: QChainage Event layer linear referencing LRS Although, all of these tools offer some linear referencing capabilities, I find that they ...
2
votes
1answer
43 views

align scale bar with PyQGIS

I am making several maps from a template with a PyQGIS script and I am having problems to align the scale bar on them. My code is: # create scale bar item = QgsComposerScaleBar(comp) ...
4
votes
2answers
328 views

How to identify polygon/point shapefiles in python?

I have a script which performs various functions on shapefiles, most of which are polygon-based. However, some shapefiles are point-based and I have to specify where these files are by editing the ...
2
votes
1answer
35 views

Is there a python version of qTuio? [closed]

Is there a python version of qTuio? qTuio is implemented in C++. However, I am currently trying to use pyqgis due to problems with C++ environment (I cannot even create a raster layer). Any help is ...
0
votes
0answers
45 views

Handling event in overlap widget scenario in Qt

Here is my problem: I am trying to develop a mobile application using Qt and QGIS in python. I am trying to mockup zoom action on qgsmapcanvas. Right now, I have a qgsmapcanvas and a qwidget. I ...
1
vote
0answers
23 views

Interpolation plugin from PyGIS? [duplicate]

How to run this plugin from PyQGIS?? http://docs.qgis.org/2.2/en/docs/user_manual/plugins/plugins_interpolation.html
2
votes
1answer
128 views

How to print 2 maps in the same PDF page using PyQGIS?

I am trying to generate a one-page PDF document containing the following items: 1) On the left half, a full state map (say, New York State). 2) On the top right quadrant, a map that zooms in to one ...
1
vote
1answer
71 views

PyQGIS export to JSON: writeAsVectorFormat and precision

In my QGIS plugin qgis2leaf I am exporting all layers as JSON into a JSON directory. Therefore I would like to enable the user to define the precision in the GUI. The normal "save as" dialogue in QGIS ...