New answers tagged

1

You can either shift the line automatically or manually: You can use QGIS expressions with Geometry generator or Geometry by expression and the function translate( $geometry, dx, dy) to offset the line to it's correct position. You have to determine for one point the shift in x- and in y-direction and than set these values instead of dx and dy in the ...


0

Let's assume there is a point layer called 'random_points_test', see image below. Here a path using this order 4,8,1,9,2 for "id"-field will be created. Apply RMC over the layer > Filter... with "id" IN (4,8,1,9,2) (or "Select Features by Expression") Apply the "Point to Path" geoalgorithm using array_find(array(...


1

To connect points in the order of a an attribute value, you can use QGIS expressions with either Geometry generator or Geometry by Expression. Use an expression like the following one, where order is the name of the attribute field (your N values). See below if you first have to bring your N values in the correct order. make_line ( geometry ( ...


2

This may not be the best and smartest solution, but a working one. Let's assume there is a point layer 'points', see image below. Idea 1. Using the "Minimum bounding geometry" geoalgorithm. Proceed with Plugins > Python Console > Show Editor and paste the script below import processing # providing the point layer's name layer_name = "...


3

In the browser panel, browse to the Geopackage and expand it. Right click the layer you want to delete and select Delete layer.


2

Open Database -> DB Manager Then create a connection to your desired Geopackage file by right clicking on Geopackage -> New Connection Now you can see the layers. Right click the one you want to delete, and press delete.


3

You can also use the "Group Stats" Plugin. Install it and then choose Vector -> Group Stats. Choose your input file, drag "Count" into the Columns box, drag your categorical field into the Rows box and another field like "id" into the "Value" box. Then Press Calculate. You will get a table showing each unique value ...


3

If you symbolise a layer by your chosen attribute, and then right click the layer in the list of layers, you can select "Show Feature Count". This will then calculate and display a number next to each category, which indicates how many features are in that category.


0

The problem is solved. GEOSCoordSeq_getXY is in the GEOS library.Steps taken: Check with the Yast software manager which GEOS version is installed. This version should be 3.9. If another version than 3.9 is installed, replace it with 3.9.


0

My solution is: # -*- coding: utf-8 -*- from qgis.PyQt.QtCore import QCoreApplication from qgis.core import (QgsProcessing, QgsFeatureSink, QgsProject, QgsDatumTransform, QgsCoordinateTransformContext, QgsCoordinateTransform, ...


0

I was having the same problem saving LineString with merged line segments. A solution that worked was to set the snapping to only the active layer, then set the snapping type to both vertices and line segments. For some reason this worked. I'm not sure why.


2

The principal idea You can create lines with the following principle: I suppose that all the parallel lines are drawn in the same direction (top-down or down to top). Find the end-point of each line and connect it to the end-point of the following line. Take the middle of this line (centroid). This is the starting point of each middle line. Now simply ...


4

General advice: try via the QGIS GUI to achieve what you want then see how to implement it in PyQGIS. It's what I've done here. You do not need to use any code in particular, just using an expression for fill color style is enough. Without caring about using PyQGIS first, just try manually the following: On your layer you want to select, just set the fill ...


2

Densify by interval to create vertices every n meters Extract the vertices as points Voronoi polygons Polygons to line Explode lines to split each line into segments Extract the short segments


4

That cyan color is probably The Atlantic Ocean. Try the following way. It worked for me. test_data = 'testdata/airports.shp' canvas = QgsMapCanvas() vlayer = QgsVectorLayer(test_data, "test", "ogr") canvas.setCanvasColor(Qt.white) canvas.enableAntiAliasing(True) tms = 'type=xyz&url=https://tile.openstreetmap.org/{z}/{x}/{y}.png&...


2

You can set datum transformations using the project QgsCoordinateTransformContext accessible via QgsProject.instance().transformContext() For Proj 5, you get existing list from QgsProject.instance().transformContext().sourceDestinationDatumTransforms() For Proj 6+, you get existing list from QgsProject.instance().transformContext().coordinateOperations() ...


2

For windows 10, QGIS 3 you can find the settings in : "C:\Users\<YOUR_USER_NAME>\AppData\Roaming\QGIS\QGIS3\profiles\default\QGIS\QGIS3.ini" In case you are planning to clean install your windows and preserve your settings (including plugins), you need to back up this folder and replace it afterward: C:\Users\<YOUR_USER_NAME>\AppData\...


2

The error seems not to be related the Bertin 1953 projection. It seems it is caused by the first projection you defined earlier. Delete the first projection in the list (maybe the second also).


6

Use Reproject tool to conver the layers into a single CRS. Merge reprojected layers with the Merge tool. Export merged layers as a CSV-file.


4

You can change the 3rd number to a subscript. The ascii codes for sub-scripted numbers range from 8320 to 8329, so we can extract the 3rd number, add 8320 to it and transform this new value to a character. Create a grid, edit its properties, show the coordinates using a custom format. Click the epsilon button beside it. Enter the following function left(@...


1

To do Jenks breaks directly, import a suitable Python library. Here's an example of some overlapping normal distributions. from jenkspy import jenks_breaks import numpy as np import matplotlib.pyplot as plt a=np.random.randn(1000)+1 b=np.random.randn(1000)+5 c=np.random.randn(1000)+12 d = np.concatenate([a,b,c]) histdata = plt.hist(d,100) breaks = ...


2

I wrote a tutorial detailing an alternative to solve this problem but in spanish here https://acolita.com/etiquetado-inteligente-de-puntos-en-qgis-3/ I describe you the most important aspects You can achieve what you want by setting a filter on the labels. Open the layer properties dialog box or the Layers > Symbology panel. Set up a ruler-based ...


0

How about using a non-spatial table to store your Values and then in the form user "Value Relations" to create a link between your non-spatial table and your field. This way, your users can also edit the non-spatial table and add the missing value and it will appear in your drop-down table. If I am correct, you want to use it within the Input app. ...


5

Add the following lines: # table grid stroke table.setGridStrokeWidth(0.1) # 0.1 mm # content text content_text_format = QgsTextFormat() content_text_format.setSize(15) table.setContentTextFormat(content_text_format) # header text header_text_format = QgsTextFormat() header_text_format.setSize(20) table.setHeaderTextFormat(header_text_format) You also may ...


0

Delete the fixed value for burn-in and use a value from a field. Then you'll get different raster values for different polygons. Use ID or some other field that you have in your polygons, eg 1 for land, 2 for water, etc.


1

I had the same issue in Windows while using QGIS 3.16. So this is for anyone using Windows. Check this site on installing Python packages https://landscapearchaeology.org/2018/installing-python-packages-in-qgis-3-for-windows/ You might realize you are missing the following .dll files api-ms-win-crt-process-l1-1-0 api-ms-win-crt-conio-l1-1-0 Install them ...


1

You can bend the atlas function to make it change the style based on an attribute of your atlas layer. First create a theme for each of your styling option (the little eye in your layers panel). Name the different themes by really simple name. I suggest style1, style2, style3.. Then create a polygon layer for your atlas definition. You will have at least two ...


0

Try to add the netcdf as Mesh layer: Layer > Add Layer > Add Mesh Layer ... It should display the temporal component as well. You can manually override the project from Layer Properties.


2

You can modify the QGIS options settings as : Go to the QGIS menu Settings > options > Advanced tab Promise to be careful In the settings tree, go to core > NewsFeed > httpsfeedqgisorg > lastFetchTime Edit the value and set it at 0 Restart QGIS. PyQGIS Bonus from qgis.core import QgsSettings qgis_settings = QgsSettings() qgis_settings....


3

It might be a bug in that QGIS version. It works as expected in QGIS 3.10.14, 3.16.5, 3.18.1 (tested).


4

You can do this, but I would recommend keeping it simple. If you just want to see points on a map, where the coordinates are stored in Excel, you can use a "Virtual Layer" (Data Source Manager > Virtual Layer). Open your Spreadsheet in QGIS (just drag it in form Explorer) and add a virtual layer like select makepoint(x,y,25832) as geometry, x, y ...


2

You can use the plugin "Spreadsheet Layer": Below an example: A spreadsheet with coordinate. Don't forget to close the file now You can import your data. The plugin will create a additive file *.vrt Your points are now in QGIS. Now close QGIS Before reopen excel I add two new data. I close excel and reopen QGIS Tadaa! (ps. you can alsa add ...


0

I find a better model, which load the original layers in Qgis: The only limitation I have is that the layer names have to be exactly the same for each SQLite file used. I considered the questions answered. In the future, the development of an algorithm execute AND load SQL from a SQLite database could be relevant though.


1

I did not find any issue with your data. Unary union is working fine at my end from qgis.core import * from qgis.gui import * vl = iface.activeLayer() geoms = [f.geometry() for f in vl.getFeatures()] g = QgsGeometry.unaryUnion(geoms)


0

SOLVED: NextGIS seems to have been the conflicting software. About a year ago I tested NextGIS. The NextGIS installer version was 3.12. NextGIS was on both systems that could not run QGIS 3.16.5 and it was not on the machine that could. I ran the NextGIS uninstaller and it cleared up the problem on both of my systems that were unable to run QGIS 3.16. I ...


1

The only way I was able to get the repeatability I was looking for was to make a custom colormap. Created in a text editor: # QGIS colormap for HARs INTERPOLATION:DISCRETE -9999,0,0,0,0,None 5.0, 15, 5, 239, 255, a 4.0, 0, 107, 255, 255, b 3.0, 59, 161, 246, 255, c 2.0, 94, 208, 246, 255, d 1.0, 147, 244, 244, 255, e 0, 255, 255, 255, 255, f -1.0, 248, 186, ...


6

In theory, there is already a shortcut for running PyQGIS scripts from the Python Editor. It is Ctrl + Shift + E (for the Run Selected action, it is Ctrl + E). Unfortunately, in my OS (Ubuntu), the default shortcut does not work for whatever reason (although the Run Selected shortcut does work). Workaround As you have mentioned, Python Console actions are ...


0

If you have only one or two field you want to get I think the best way is to use field calculator to do it in one step. I use it mainly after i have done a processing on a "source" layer (spatial join or whatever), and I want to get the information back on my "source" layer (and discard the temporary data after). attributes(get_feature( '*...


0

Update: I found a way to avoid this issue. I'm using SAGA's tool "split lines with lines", this one does not cut lines that overlaps themselves.


2

Here is a PyQGIS solution: layer = iface.activeLayer() # choose the layer to edit fieldname = 'mycolumn' # name of the column to change i = 10001 # value to start counting at # no changes needed below # # start edit mode of the layer with edit(layer): # add the new field # layer.dataProvider().addAttributes([QgsField(fieldname, QVariant.String)]) ...


3

To extend @Eriks answer: just in case your ID's do not start with 1, you can use this expression: 'N' || to_string(10000 + array_find(array_agg($id),$id) + 1) It will always start at 10001, no matter what your actual ID values are.


3

With a virtual layer (official documentation), you can create a new layer then save the result as : SELECT lines.* FROM "Layer 1" lines, "Layer 2" structure, WHERE NOT( structure IN ('wall', 'corridor') AND ST_INTERSECTS(structure.geometry, lines.geometry) ) or in QGIS create a selection in Layer 2 with an expression like ...


3

'N1000'||to_string($id+1) should do what you are looking for. Since the ID starts out with 0, we need to add +1 in order to start with N10001.


1

Run OSGeo4W - this will open a terminal. Type qgis in that terminal end hit Enter. If you don't see 'qgis', try 'qgis-grass7' etc.


-1

This answer might be slightly off-topic, but your question keeps coming up whilst searching for the graphical modeller answers. If you are using the graphical modeller, you can use the parameter function to retrieve a string of any inputs. Unfortunately, you can not use the shorthand @parameter way of accessing data if you want a string. The below code takes ...


2

As Kadir Şahbaz commented, you are mixing QGIS 2 & 3 APIs. A couple of other things: -You don't need to actually open your layout, you just need a reference to the layout object. -If you want to export a png you should use exportToImage() not exportToPdf(). Try the example below which is working for me. project = QgsProject().instance() canvas = iface....


0

I have run the installers from kyngchaos for 3.16.5 which installs python3.9 and GDAL separately. I also deleted the profiles at ~/Library/Application Support/QGIS and deleted a slew of QGIS preference files at ~/Library/Preferences (e.g., org.qgis.qgis3.plist) Now the symptoms have changed: QGIS 3.16.5 crashes immediately on 2nd try, QGIS starts with ...


2

array_mean() is not yet available in the latest release, but I found a neat workaround with eval() and array_to_String() :) with_variable('nodes', nodes_to_points( $geometry), eval( array_to_string( array_foreach( generate_series(1, num_points(@nodes)), raster_value('Slope', 1, point_n(@nodes, @element))) , '+') )...


1

union_1 = processing.run("qgis:union", param_union) Should be union_1 = processing.run("qgis:union", param_union)['OUTPUT'] Or union1 is a dictionary, not a layer


1

You can simply use the function array_mean(array) (available since QGIS 3.18) - see the examples in the explanation on the right side of the expression string builder: array_mean(array(0,1,7,66.6,135.4)) → 42 array_mean(array(0,84,'a','b','c')) → 42


Top 50 recent answers are included