Tag Info

Hot answers tagged

2

As asked by the OP, I put this in answer. The problem wasn't with the method used, as ogr.Geometry.Union() is the appropriate one but with the second polygon which was not closed. It can be done with : tri2.CloseRings() or by repeating the first point : tri2.AddPoint(1,1) If there is many features to dissolve (like the entire layer) it can be done with ...


2

You'll want to use a search cursor that iterates through your feature layer and reads values in the PageNumber field. Something like this: with arcpy.da.SearchCursor (IndexPoly, "PageNumber") as cursor: for pageNumber, in cursor: Expression = "PageNumber = {}".format (pageNumber) arcpy.SelectLayerByAttribute_management(IndexPoly, ...


2

The problem is that you were adding all fields as "TEXT". The first one should have been a date. Here is an example where you can map the field types with the headers: import arcpy import os import csv import time import locale from arcpy import env start_time = time.time() ##incsv = arcpy.GetParameterAsText(0) ##outfc = arcpy.GetParameterAsText(1) ...


2

Using QgsMessageLog you can do variable interpolation in strings using the usual python % operator: >>> QgsMessageLog.logMessage("hello") >>> x=99 >>> QgsMessageLog.logMessage("x is %s" % x) shows me "x is 99" in the message window.


2

From documentation: pushMessage(const QString &title, const QString &text, MessageLevel level=INFO, int duration=0) So, first and second agruments are strings. If you have some variables in your plugin, and you want to pass them into this function, you have to convert them to strings. For example we have a variable which contains coordinates and ...


1

While Joseph is correct about the syntax of the CASE statement, your Python issue stems from string quoting. You can use either ' or " to quote strings, and you don't have to escape the other character if used, but you do have to escape the same character. Or you can triple quote (ie ''') which will also allow multi line quotes. In other words: # this ...


1

I think list comprehension as well as applying sql statements to your search cursor will help you out. Here's a few tips: If you want all the unique values in a field (field ID, in this case). ##Find all unique values in a field #Return python set of unique values in field "ID" values = set([r[0] for r in arcpy.da.SearchCursor (table, "ID")]) Max value ...


1

in your plugin init() you can add a listener to iface.initializationCompleted signal http://qgis.org/api/classQgisInterface.html#a6f1cc8be7d4e0b4c76c2806b78b3d8b0 then do what you want regards


1

1) you don't need to export a shapefile. With the Python module GDAL (osgeo) you can read directly the layer from the GRASS folders hierarchy (look at GRASS 6 terminology) from osgeo import ogr # open the Grass layer shape1 ds = ogr.Open('/Users/grassdata/geol/MNT/vector/shape1/head') layer = ds.GetLayer(0) ... 2) If you want to read the shapefile, you ...


1

After having investigated the QGIS code, I'd decided that custom code needs to be created to store and load composer configurations. The QGIS desktop app does it all with custom classes and not the common library, so a standalone app written in python is going to have to do the same for the time being. relevant files: src/app/composer/qgscomposer.cpp ...


1

You will need to call the method QgsComposer.readXML(node) with the XML node representing the composer you want to load. The QGIS desktop app does it this way: create a slot method that takes a parameter loadComposers(doc) Search for doc.elementsByTagName("Composer") Iterate over all found xml_nodes and Create a new QgsComposer Call ...


1

This looks like a bug in the plugin. I would suggest to open an issue report. Please note that gis.se is not a bugtracker and it is unlikely that this post here will help to fix this issue. For further possibilities to proceed, please have a look at this answer.


1

You can do that from the QGIS Python console in this way: Copy the next function, taken (and slightly adapted) from the Processing framework source code, into the QGIS Python console: from processing.core.Processing import Processing from processing.gui.AlgorithmDialog import AlgorithmDialog def runAlgorithm(alg): """ Borrowed from CommanderWindow.py, ...


1

I've tried your code, but it not work. It can't find selected feature. So, I make an edit from your code. This is the edited code: def selectFeature(self, point, button): pntGeom = QgsGeometry.fromPoint(point) pntBuff = pntGeom.buffer((self.canvas.mapUnitsPerPixel() * 2), 0) rect = pntBuff.boundingBox() cLayer = ...


1

Hey moderator that deleted my last post on the same topic, please leave this one up. This is completely relevant because I don't believe the answers above still work and I'm not the only one that's struggling here. Either I'm crazy, or the two bits of code no longer work. I've copied these and tweaked them for my use and for the life of me I can't get a tif ...



Only top voted, non community-wiki answers of a minimum length are eligible