New answers tagged

0

Following code has an example of parameters dictionary and, I modified some little thing in your code because you are tagged this question with qgis-3 and 'runandload' doesn't exist as processing method in pyqgis3. I also modified 'layer_name' for working with my own layers. import qgis.core import processing def __init__(self, iface): self.iface = ...


1

Step 1 Check the calculated path instead of the final image This is a combination of the two examples you posted. What exactly is the output you get? import QtQuick 2.0 Rectangle { width: 100 height: 100 color: "steelblue" Text{ text: "expression.evaluate("concat(@project_folder, '/Photos/', ...


0

I think you have done the script properly. That means, there are inputs and there is also an output (that's why you can chain your script in the modeler). I guess you are only missing one detail. In the last algorithm (Basic statistics for fields), you need to give the output a name when configuring it in the modeler. Once you do so, you'll see a green ...


1

Getlegendgraphic was ignoring the BBOX-parameter for layers inherited from QGIS2. I probably need to add them all over again


1

Found a workaround: I installed QGIS 3.4 LTR and pyinstaller in a miniconda environment on Windows 10. (Add conda-forge channel to install QGIS) I had to add the platforms/ directory in the data section of pyinstaller .spec file (qt platform directory found in the conda environment Library/ folder) for Qt to work.


0

I had the same issue. As you said in the your comment putting the path inside the pyrcc5.bat file between quotes solved it. The reason for that is the main folder of QGIS 3.xx has a space inside its name by default (in my case it was this: C:\Program Files\QGIS 3.8\apps\Python37), thats why the .bat gets stuck at C:\PROGRA~1\QGIS. Hope this helps anyone ...


2

By creating a new field "Fromto" (or any name) in your route table and in your resulting layer. This new field will contain both 'From' and 'To' (example: From: "Paris", to:"Moscow" --> Fromto: 'ParisMoscow'). You will then be able to add a Vector Join in your resulting layer and connect it to route table on their attributes "Fromto". the resulting layer ...


1

Suppose that I want to divide line layer of following image in 5 equal segments. In attributes table, it was calculated with geometry options of field calculator, total line length and each equal segment length (5 in total). Afterward, I opened v.split tool and filled following options: After click in Run, I got Split by length layer where it can be ...


1

You can use v.clean tool under GRASS from Processing toolbox, search for v.clean in the toolbox and you will find it. Use the pipeline network as an input file and under the tools select Snap option with a threshold value that you need to specify based on the distance of the disconnected vertices. You need to experiment by yourself to select the proper value....


1

Try deleting the .git folder. I recently got the same error because of a .idea folder which I think was a leftover from some python ide I used at some point. You probably don't need the .git folder for distribution.


1

According to this site, the value of -3.40282e38 is 0xff7fffee, which is a 'quiet' NaN ("Not a number") value according to this page . NaN is a sensible way to represent NODATA. Certain ranges of binary values for floats are used to represent NaN, infinity, minus infinity and so on. This nodata value suggests the original is single precision floating ...


0

It might be something with your python installation, since you are getting this message: GDAL command output: /bin/sh: gdal_merge.py: command not found Which means that one python utility from GDAL is not working properly. So you should check which OS you have and try to search with that error in mind. Perhaps try to install QGIS with OSGeo4W: https://...


2

That is the correct and expected behaviour, if you select several layers at the same time and add them to QGIS it will make one request for all of the selected layers and add them as a single QGIS layer. If you need to have the ability to turn individual layers on and off in QGIS then you must add the layers one at a time, this will make QGIS make several ...


0

Not really an answer but that's what I will do to diagnose such an error : Verify the geometry and repair any error you find. (See this for zoom related disappearing polygon) Made sure it's not a display issue (transparent symbol or no symbology) (Like @Steve said in his answer) Check that there are no provider feature filter set (but if there are some you ...


4

When creating line objects the Advanced Digitizing window shows you distance (d), angle (a), x coordinate and y coordinate. To use it, switch on both the Advanced Digitizing panel and toolbar and click the icon for 'Enable advanced digitizing tools' when you are editing


1

In the line of the @BERA comment, this solves the problem in QGIS 3.8: The points must be created with 'QgsPointXY' (instead of 'QgsPoint'). The polygon must be created with 'fromPolygonXY' (instead of fromPolygon'). p1 = QgsPointXY(546016, 4760165) p2 = QgsPointXY(535433, 4749582) p3 = QgsPointXY(535833, 4749982) layer = QgsVectorLayer('Polygon', '...


1

The underlying issue is that you're passing a list of list-of-strings as your layers parameter, not a list-of-strings. I.e. instead of 'LAYERS': [['C:/Shapes/File1.shp'],['C:/Shapes/File2.shp']], You should be passing 'LAYERS': ['C:/Shapes/File1.shp','C:/Shapes/File2.shp'],


1

I found it! It´s need to define the files and call them by their names, not by their path. def processAlgorithm(self, parameters, context, model_feedback): File1 = 'C:/Shapes/File1.shp' File2 = 'C:/Shapes/File2.shp' # Merge Layers alg_params = { 'CRS': None, 'LAYERS': [File1,File2], ...


1

Don't think it likes how you defined your input layers. You should consider using the new format for writing scripts as it gets rid off a lot of waffle. For example, the following script let's you select multiple shapefiles (either loaded in QGIS or external) and runs the merge tool. As it is a native tool, it would output the name of the tool used (at least ...


1

There is no direct way to calculate the minimum and maximum from the Raster Calculator in QGIS. The only workaround is to extract the minimum and maximum of the raster layer using Raster layer statistics tool from Processing Toolbox, and save it into a text editor: Then use the above minimum and maximum values in the raster calculator from Processing ...


1

The "error" was that the min max value was just "estimate" and not actual, and as the max value of original raster was just above 0.1 (0.010298) the setting of symbology of the layer (it was estimated) was defined in way that it was not showing the last cathegory (the 4th one) thats why I was missing all the time the last cathegory.


2

EPSG : 3857 is a projected CRS with meters as unit so the coordinate (-11315, 6710551) are right for London area. On the other hand your CSV seem to use degree as unit so it's not in 3857, you could try to use WGS84 (EPSG : 4326) if you dont know witch CRS it use


0

A simple workaround is to stop map rendering (little checkbox bottom right under the map) before saving your changes. But it is not satisfactory and should be natively implemented in QGIS.


5

To visualize them as curved lines, change the Symbol layer type to Arrow, then select Curved arrows option. Head length/thickness should be zero as you would not need arrow-heads.


3

You can achieve this by joining the shapefile with the CSV file based on the common fields between them (KEY field and KEY_ID). To do this, add both shapefile and CSV files as layers to the table of Contents using Add vector files, then right-click the shapefile -> Properties -> Join -> Add join (green plus at bottom left) -> Select the CSV ...


1

Good day, I’m moving from theory to practice, the initial data is a layer (table) with the name adm_polygons, run the script: WITH ta AS ( WITH at AS (SELECT id, (ST_ExteriorRing(((ST_Dump(geom)).geom))) as geom FROM adm_polygons), intervals as (SELECT generate_series (0, 8) as steps) SELECT steps AS stp, ST_LineInterpolatePoint(geom, steps/(...


0

typo : The orientation belongs directly to QgsLayoutItemPage from qgis.core import * manager = QgsProject.instance().layoutManager() layout = QgsPrintLayout(QgsProject.instance()) layout.setName("TEST") layout.initializeDefaults() pc = layout.pageCollection() pc.pages()[0].setPageSize('A0', QgsLayoutItemPage.Landscape) manager.addLayout(layout) This ...


1

I think the labeling tool bar has not gone anywhere in 3.8 (unless you told it to). To re-add it to the display, right click on an empty part of the grey toolbar background and click the box next to label toolbar.


0

Try the SuperLabeling plugin: Add your label by mouse click only. Some other similar plugins already exist, which create a memory layer or other layer making somehow difficult to integrate data. This plugin creates label data in the existed files in a minimum manner. You don't even need to type any thing, just mouse clicking can make be helpful to ...


2

Other than with expressions, you can use the line-width-assistant - it's probably easier because you don't need expressions (but you can, if you want, see below). Select the assistent, select the source ( field that contains the values/width-information in your attribute table), than update values (that automatically selects min./max. values - otherwise ...


3

That's quite easy: use pixel, points or mm as units for the width of the line (road, river) - thus a unit that refers to your rendered image/screen and not to the real world. Like this, you have the "Google-maps-effect" you refer to: your line is rendered always in the same width on your screen, whatever scale you zoom to. However, if you want to have "real-...


1

You have an Esri grid (also known as an Arc/INFO binary grid) format raster. The Esri grid (and other ancient Arc/INFO formats such as the coverage vector format) is a directory of related files stored in a parent directory (workspace) with an INFO database directory. Qgis can read ESRI grids, just unzip and add the aspect/hdr.adf file. Note: It looks ...


1

I noticed later that, even being only one feature, there were tiny islands around the boundary, and maybe the issue was in those. But i wasn't able to delete all of them, because i was in a hurry. So, to solve my issue, i used Simplify, with "Distance (Douglas-Peucker)" method, using a 1km tolerance. Any type of polygon based directly on the original (...


1

If you need change the name of output, you can do it with this: alg_params = { 'INPUT': parameters['shapeinput'], 'TARGET_CRS': QgsCoordinateReferenceSystem('EPSG:4326'), 'OUTPUT': 'memory:Name_layer' } or if you want to save, only do this: path = '/home/shade/Desktop/name_layer.shp' #or something like that alg_params = { ...


-1

In the transparency layer properties tab there is a option to set in a no data value for each color value of a pixel. Fill in 0,0,0 for R,G,B and then transparency 100, this only turns the black pixels transparent.


2

For any kind of analysis, make sure to reproject it which saves the spatial data in the new CRS. For vectors, you can use the Reproject layer tool; for rasters, you can use the Warp (reproject) tool. Both of these are available from the Processing Toolbox. – Joseph


1

Try using the following which uses the pageCollection() method to manage the page settings: layout = QgsPrintLayout(QgsProject.instance()) layout.setName("TEST") layout.initializeDefaults() pc = layout.pageCollection() pc.pages()[0].setPageSize('A0', QgsLayoutItemPage.Orientation.Landscape) manager.addLayout(layout)


0

Maybe it's now different with the new version (I use 3.6), but at first I also didn't get an output table. What helped: save file to... and then choose *dbf format, not shapefile


3

This is a known bug: https://github.com/qgis/QGIS/issues/29223. It's Mac-specific, and may be related to a similar issue with the Identify results window. It doesn't look like anyone is working on a fix at the moment. See the issue tracker page on github for more details and up-to-date information. github user emonshaugen suggested this workaround: ...


3

Open Layer properties - Attributes form - switch from Autogenerate to Drag and drop designer (worked for me).


3

Not sure if there is a simple way of doing this through the interface but we could accomplish this with a bit of Python. The code below stores the value and colour of the raster's symbology properties and rounds the value to 2 decimal places (you can change the value if you want) which it stores as the new label. Then it reapplies the updated properties So ...


5

I've found an answer! I need to use Numpy frombuffer and gdal_array.GDALTypeCodeToNumericTypeCode to make my for loop look like this: #Loading the bands into the matrix for b in range(band_count): block = input.dataProvider().block(b+1, input.extent(), cols, rows).data() data = np.frombuffer(block, dtype=gdal_array....


3

I use this code to ~randomly place a grid of sample plots for forest inventory: import numpy as np from itertools import product polylayer = iface.activeLayer() #Highlight polygon layer in layer tree npoints = 8 #Change pointlayer = QgsVectorLayer('Point?crs=epsg:3006', 'point' , 'memory') #Change epsg prov = pointlayer.dataProvider() for poly in ...


2

The final problem were different CRS. The points were in 4326 and my Project layer in 25832. I changed everything to the same CRS and it worked. Thanks for the help.


1

Not at the moment but a feature request has been sent about creating a "Favourites" section where users could manually add their frequently-used tools: https://github.com/qgis/QGIS/issues/29220


1

You can get the project title with title = QgsProject.instance().title() See the documentation


3

I implemented Cyril's comment. This is the input test polygon: Polygon to Lines Split lines by maximum length using $length / 7 in the expression builder. (8 vertices) Extract specific vertices (0 stands for start point) Voronoi Polygons with 100% buffer to make sure that parts of the polygon do not lie outside the generated Voronoi (in theory they may ...


0

If you have generated contours from a point based file using the Contour plugin, you may want to try using the Processing Toolbox, QGIS Vector Geometry "Smooth" routine. Set your tolerances to what you can live with, and start with 5 iterations. The routine will create a temporary layer which can be made permanent. I do this quite frequently with ...


0

With QGIS 3.4 and Windows 10 I have these deprecation warnings when running my standalone application : C:\Program Files\QGIS 3.4\apps\qgis-ltr\python\qgis\utils.py:685: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses mod = _builtin_import(name, globals, locals, fromlist, level) ...


0

I just found out apparently the flatpak version of QGIS does not allow for new Python modules to be installed at all. It seems circumventing the broken QGIS repository with flatpak was a dead end after all. On top of that, in case others are having the same broken dependencies issue with the ubuntugis repo (and in my case the ltr release repo) the nightly ...


Top 50 recent answers are included