Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
1answer
234 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
48 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
17 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
88 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
452 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
453 views

How can I access `processing` 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
61 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
60 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
185 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 ...
2
votes
2answers
185 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 ...
2
votes
1answer
150 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 ...
3
votes
1answer
103 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
141 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
164 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
50 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
316 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
59 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
207 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
138 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 = ...
3
votes
2answers
623 views

How to customize the QGIS 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
34 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
30 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
290 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
399 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
119 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
490 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
72 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
128 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
68 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
297 views

ImportError: No module named processing [duplicate]

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
57 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
64 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) ...
5
votes
2answers
441 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
39 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
75 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
26 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
159 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
160 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 ...
2
votes
1answer
50 views

How to switch rule-based styles in loop?

I'm a working on a QGIS script that could activate/deactivate rule-based styles of the vector layer in a loop (one active layer per iteration). On the every iteration this scenario should: Activate ...
2
votes
0answers
91 views

How to open a second window in QGIS plugin from a button inside the main window

If I already created a qgis plugin, and i need to create a button inside that plugin that opens a new window, how is that possible? Qt creator won't add a slot unless there are a header file. I looked ...
2
votes
0answers
104 views

How to load all items from a template with pyQGIS in QGIS 2.6 [closed]

Since QGIS 2.6, the LoadFromTemplate method seems not work any more (or works differently?) This is my code to add items in my composer from a template : self.composition = ...
1
vote
1answer
23 views

Read ellipsoid parameters

I would like to retrieve the semi-major axis of ellipsoid of a layer (any layer) using Python API. It seems that crs class can read only the ellipsoid acronym (?) Apparently, QgsDistanceArea class ...
2
votes
2answers
87 views

What are QGIS Arcpy Equivalent Functions for MakeFeatureLayer and SelectLayerByLocation?

I have a script that I had created using ModelBuilder, but our field personnel use QGIS 2.0. Below is a snippet of the code. I am wanting to know if there is an equivalent using pyqgis so that I can ...
2
votes
1answer
212 views

How to calculate the perimeter of the polygon using python programming

Is it possible to calculate the perimeter of each feature of the polygon? For calculating the area we are using: area=feature.geometry().area() is there any function to calculate the ...
2
votes
3answers
257 views

Saving a QGIS project using the API loses mapcanvas (and other) XML nodes

I'm using the following python script to open a QGIS project, modify some things, and save it under a different name: from PyQt4.QtCore import QFileInfo from qgis.core import * def main(): ...
2
votes
1answer
205 views

How to add vertex to an existing polyline programatically?

I have a Polyline and would like to add new vertex to before start point or end point or at any part of the polyline using python in qgis. How can i do that?
1
vote
1answer
92 views

With QGIS Plugins/PluginBuilder, how to prevent 2nd instance of Plugin from starting

I am using QGIS 2.6.0, with PluginBuilder 2.0.3 [checking the version, I just noticed that the 2.1.0 update is available] I am writing a plugin; it installs and runs. While running, I am able to ...
3
votes
1answer
124 views

Add button to custom standalone QGIS application

Im able to implement zoom in and zoom out functionality as described in the PyQGIS developer cookbook using a tool bar. I would like to have buttons that display above my map canvas layer and have the ...
3
votes
1answer
157 views

How to prevent users from removing QGIS layers?

I need to prevent users from removing layers. In my plugin code I use the following to achieve that: QgsMapLayerRegistry.instance().layersWillBeRemoved.connect(self.dontremovefunc) def ...
1
vote
2answers
95 views

Using QgsRasterCalculator

I'm trying to make a sum of n rasters and create a new one using QgsRasterClaculator, the problem is, every time the code reaches processCalculation, it makes QGis close and create a dump file. I ...