Tag Info

New answers tagged

1

I have changed the windows user account control setting to the lowest level and it solves the problem on my Win7 machine. Thanks for leading me in that direction @NeilBenny Unfortunately the same trick did not resolve the problem on my Win8 machine.


0

Do you need the memory layer at all? Have a look at the "directly from features" example in the PyQGIS cookbook to see how to create a persistent Shapefile from features, so that you avoid creating a memory layer.


1

Based on the answer by Adam Bioletti, further tests to the process described show that the only essential requirement is to start editing the memory layer before making any changes, such as creating attributes and features, and then commit the changes. This can be done before adding the layer to map registry. Here's an update of the Cookbook's code that ...


1

You can overwrite the close function of your UI as well, that the plugin is reloaded every time you close it. def closeEvent(self, event): qgis.utils.reloadPlugin('YourPluginName') This will reload the plugin completely and will empty all your boxes. In this way you don't have to care about clearing the boxes because the plugin will always load only ...


1

Both underdark♦'s and gcarrillo's replies provide valid answers. How exactly the issue should be handled however depends on the use case, and if necessary, options should be provided.


1

the Line, feature = layer.selectedFeatures() returns a list of QgsFeature. You will need to loop over it to process individual selections, like below. layer = qgis.utils.iface.activeLayer() for feature in layer.selectedFeatures(): mbuf = feature.geometry().buffer(50, 2) iterFeat = layer.getFeatures() for f in iterFeat: geom2 = ...


2

You are probably setting a connection between a SIGNAL (button clicked) and a SLOT (your method showTable) every time your plugin is open (run() method?) and you are not disconnecting such SIGNAL/SLOT when your plugin is closed. This leads to a new call to showTable() every time you open your plugin, because there's a new connection calling it. A couple of ...


1

In my opinion you should empty the combo box before populating it. The rationale behind that is that the layer might have changed so it's not a good idea to set a flag and ignore everything that might happen afterwards.


0

I think the repository you are looking for is https://github.com/olivierdalang/CadInput. Plugins-Manage and install plugins and you can give the repository there in order to install and use this plugin.


1

The Measure area tool does not create a layer which can be input for Processing. You need to create a new polygon layer, for example a Memory layer, see http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/vector.html#memory-provider and Using in-memory vector layer with QGIS processing / SEXTANTE


1

You only need to run pyrcc4 -o resources_rc.py resources.qrc The .ui file is loaded dynamically in the recent versions of the default plugin code. For example, if the plugin is called test, the corresponding GUI loading code in test_dialog.py is FORM_CLASS, _ = uic.loadUiType(os.path.join( os.path.dirname(__file__), 'test_dialog_base.ui')) All ...


0

I think that this is most a python related question rather than a GIS question. You can try with the "Try and except" in python sort of: try: layer with possible problem except: print this layer doesn't work. Anyways I think is better to ask or search this in the python related StackExchange.


1

What about the Oslandia Versioning Plugin for QGIS? http://www.oslandia.com/qgis-versioning-plugin-en.html Contrary to the promises on the website, I can't find it in the QGIS Plugin Repository.


2

You would just need to make sure your layer has a name you can distinguish from others. Instead of layer = self.iface.activeLayer(), do: layer=None for lyr in QgsMapLayerRegistry.instance().mapLayers().values(): if lyr.name() == "YOUR_LAYER_NAME": layer = lyr break If you don't trust the layer name (after all, it can be changed by the ...


1

As indicated in my answer to How to compute parameters for QGIS Affine transformation?, you can do it after you recognize the different parameters of the matrix. Parameters are: a: Scale X e: Scale Y d: Rotation X b: Rotation Y c: Translation X f: Translation Y So, you should be able to move your layer by setting c and f parameters with your x and y ...


2

You are calling the wrong class. What you need to call is mapCanvas, and not canvas. Change your code to this: allLayers = iface.mapCanvas().layers() for i in allLayers: print i.name() This will print all of your current layers' names. Also note that you need to indent the print line. I assume in your post this was just a copy/paste problem, but if ...


1

1) Click in Vector --> Geometry Tools --> Extract nodes 2) In the new window a)check "Add result to canvas" b)Browse your locate and save with a name 3) Whait a moment, in the layer Right click and choose "Save as" 4) In "Format" choose the "Comma Separated Values (.csv)" 5) And open the .csv file in to Excel and you have all ...


3

Extracting coordinates of start/end vertices (not all line vertices) from lines is a nice use case for new functionality in QGIS v.2.8, namely, the function editor. This is the workflow: Load your line layer to QGIS and activate it. Open the field calculator and go to tab Function Editor. Click on New file, write vertices as the new file name, and click ...


2

Click on Vector -> Geometry Tools -> Extract Nodes A window will appears, choose a file to save and mark the option "Add result to canvas". Right click in the new layer created and click on "save as". Choose a name to your file and open it with a text editor to check the result.


1

You need to use a try/except block: def writeToFile(self, lsOfCities, filePath): try: fileCSV = open(filePath, "w") for i in lsOfCities: fileCSV.write(i) fileCSV.write(",") fileCSV.write("\n") QMessageBox.information(self.dlg, "Number of Cities Near", str(len(lsOfCities)) + " cities are ...


2

For exporting the coordinates too, I assume you will have to add new columns for x and y coordinates and calculate these using the fieldcalculator with the appropriate operators.


2

Export table to excel: Right click layer in table of contents select Save As Under Format drop down select Comma Separated Value (CSV) option Open excel and browse for saved .csv to open


1

You can do this easily. First, store the city names in a 'list' and then use a 'set' to remove the duplicates. def findTheCityNames(self): cities = [] layers = self.iface.mapCanvas().layers() for layer in layers: if layer.type() == QgsMapLayer.VectorLayer: layers = self.iface.activeLayer() if layer > 0: ...


0

Seems like your feature request does not return any matching features. That's why the resulting iterator is empty. For numerical value input use a spinbox instead of a text field.


4

You can apply the following code to define fromUtf8 which was taken from the QGIS Workshop describing how to use PyQT for QGIS: _fromUtf8 = QtCore.QString.fromUtf8


2

You don't really seem to have read at least one of the resources I collected for you in Layer Properties Field Tab in my plugin. If you open, for example this one, you'll see the answer to your question: button.clicked.connect(self.onClicked) In your case it would be something like (you might need to edit it to match your plugin structure): ...


1

This should work: iface.actionSelectFreehand().trigger()


1

No, you can not because the GDAL Excel driver is read-only: http://www.gdal.org/drv_xls.html The XYtools plugin allows to import point coordinates together with attributes, and export the attribute table only (if it works), but no real-time syncing. You can save to CSV, and import that back into Excel manually. But this is not the kind of ODBC-like ...


1

Just a short addition to the answer of user BritishSteel: I doubt that a networkdrive would work as the http-protocol should be used. ( see the tooltip in this screenshot:) But you can setup a webserver like apache,nginx,jetty or something like that (if not already exists) and make the xml-file available through the http-protocol(see screenshot.my local ...


3

It is possible, yes. I have not done it myself, but I have read about it in this book. (I hope this does not count as an ad; if someone thinks so, please edit the post and remove the link). You would first have to create an XML file that looks like the following: <?xml version="1.0"?> <plugins> <pyqgis_plugin name="SomeName" ...


1

You could also look at the Midvatten plugin (details in Midvatten Plugin for QGIS) The plugin is intended to be a toolset for using QGIS to manage data from hydrogeological investigations. A spatial-enabled SQLite database (i.e. spatialite) is used for storing data.


1

You could have a look at http://www.fossgis.de/konferenz/2013/programm/events/532.de.html (german) or the github repository of this project https://github.com/qgep/QGEP


5

Install the XY Tools plugin by Richard Duivenvoorde. Select a vector file from the ToC (that is, make it active). Go to Vector->XY tools->Save attribute table as Excel file. You would need the Python library xlw installed for doing so.


2

To get a csv file of the attribute table, rightclick on the layer in the legend, and change the file format from shapefile to CSV. You might need to change the separator from comma to semicolon in a text editor if Excel does not like the default separator.


2

A few things. First, .getFeatures() returns an iterator, and not the features themselves, so putting them in a dictionary is only good to consume memory. I re-did your work using a couple of layers I have for the Phoenix, AZ area and it worked well. See below. The original code also does NOT guarantee that the feature is contained, but rather that it ...


0

I contacted the plugin developer, and everything's much clearer now. I thought I would share what I learned, hoping it could be useful to someone else. Once you have generated a new layer in Plugins -> Easy Custom Labeling -> Generates a layer... (see @gcarillo 's answer), leader lines should appear automatically when you use the Move label button in the ...


2

Try with the text() function, as stated in the Qt docs. I would also parse it directly as a float, being a distance. distance = float( self.dlg.DistancelineEdit.text() ) Note: Actually, I had already told you so.


1

I think this can help you: # Get buffer distance and selected city dist = float( myLineEdit.text() ) city = myComboBo.currentText() # Get the feature corresponding to the selected city expr = QgsExpression('"Cities" = \'' + city + '\'' ) it = myLayer.getFeatures( QgsFeatureRequest( expr ) ) feature = it.next() # Perform a buffer on the feature geometry ...


5

The QGIS-plugin manager matches the version number of any locally installed QGIS plugin (this includes your development version) with the version number hosted on the QGIS plugin repo. As you can see in your screenshot your locally installed version has the version number 0.1, while the one on the repo has 1.1. Thus it correctly assumes that the one on the ...


1

I figured out the issue. The problem was I had sklearn in the same directory as my plugin files and not in the site-packages under my qgis installation. Not 100% sure that was the issue but once I deleted sklearn from the plugin directory and installed it in site-packages, the issue was resolved. No more errors!


2

I was just looking for the same answer myself and while my answer is not 'official', it's based on my interpretation of this Training Manual entry I found: http://docs.qgis.org/2.2/en/docs/training_manual/answers/answers.html#basic-distance-from-high-schools I think the above illustrates the buffer segments quite well. My answer is therefore... The ...


4

Since there is no custom QGIS GUI widget for that (at least I couldn't find it), you could try something like this: from PyQt4.QtGui import QComboBox lyr = iface.activeLayer() idx = lyr.dataProvider().fieldNameIndex( 'NAME_1' ) uv = lyr.dataProvider().uniqueValues( idx ) cb = QComboBox() cb.addItems( uv ) Note that we are obtaining unique values of the ...


0

As I explained in Snap points to line and calculate chainage using Open source GIS the QGIS LRS plugin accepts points not lying on the line to calibrate it, so it's not a problem that your points are not on the line. By the way, I assume you already loaded the txt file as a point layer (say gps_layer). As you may have already read, you first need to ...


1

The GDAL method (my preferred choice in this case): import gdal, gdalconst, numpy gdal.UseExceptions() def readfile(readfilename): filehandle = gdal.Open(readfilename) band1 = filehandle.GetRasterBand(1) # in your case you should add extra code here... geotransform = filehandle.GetGeoTransform() geoproj = filehandle.GetProjection() ...


1

As far as I know there is no PostGIS-Versioning plugin available at the moment. Perhaps you could have a look at the old Version in the still existing SVN to get an Idea of how to implement one of your own? https://www.kappasys.ch/svn/pgversion/branches/pgversion_branch/ If you use the plugin builder you can get an up to date "skeleton" for a new Plugin: ...


2

I suggest you to have a look at PyQt4 tutorials on Internet. They should help you understand how PyQt4 applications are structured, and should introduce you to the wide variety of widgets PyQt4 provides you with. Just to cite some, here is a list of resources you could read: Introduction to PyQt4 PyQt4 Tutorial GUI - PyQt4 Once you've done that, you ...


1

One more option using the Field Calculator, For age1, left("Age", length("Age") - strpos("Age" ,'/')) For age2, right("Age", length("Age") - strpos("Age" ,'/')-1)


2

Great answer by @Martin! Alternatively, you can also achieve this via the normal Field Calculator by using the following commands: When creating the column age 1: regexp_replace("Age" , '/[0-9]*', '') When creating the column age 2: regexp_replace("Age" , '[0-9]*/', '') Note: Make sure to place the forward slash / at the beginning if you want to ...


5

If you just want to split this string into two integers you can use the Python split function and convert the resulting two list entrys from type string to type integer. age = '14/2' ages = age.split("/") age 1 = int(ages[0]) age 2 = int(ages[1]) or as a function: def split_age(self, age): return(int(age.split("/")[0]), int(age.split("/")[1])) ...


1

According to this and to your previous question, you want to deactivate your tool by pressing the Escape key. However, as far as I know, one cannot deactivate a map tool. One should activate another map tool to deactivate (indirectly) the current one. That is, the map canvas MUST always have an active map tool. So, in order to deactivate your map tool you ...



Top 50 recent answers are included