New answers tagged

1 vote
Accepted

Editing a QGIS script to use field values as input parameters rather than introducing a constant value

Based on your comments you can use this modified script: from qgis.core import QgsProcessing, QgsProcessingAlgorithm, QgsProcessingMultiStepFeedback, QgsProcessingParameterFeatureSource, ...
user avatar
  • 24.7k
2 votes

Creating nested hex grids in QGIS

Whilst Taras has provided a great answer, I wanted to share another solution I came across - the Shape Tools plugin by C. Hamilton. Not only could I edit the shape of my hexes, but I could also rotate ...
user avatar
6 votes

Creating nested hex grids in QGIS

Create an hexagonal grid then add some centroid fill using hexagonal symbol. you may control the colour of each symbol by using data override on each symbol. Edit : If you don't have hexagon symbol ...
user avatar
  • 11.8k
7 votes
Accepted

Creating nested hex grids in QGIS

Step 1. Create a grid with the "Create grid" geoalgorithm Step 2. Use the "Geometry by expression" from the Processing Toolbox (Ctrl+Alt+T). With the following expression: ...
user avatar
  • 22.9k
1 vote

PyQGIS: moving legend with changed reference point

From your screenshot, it is clear that your legend is being added to your layout, "except for being in the wrong place". You haven't shown or explained how you calculated the layout point ...
user avatar
  • 13.5k
1 vote
Accepted

When moving layer labels the labels connect

You need to choose a unique key. The window for this pops up the first time you move a label: You cannot use an expression here. So in case you do not have one, you need to add it to the layer first. ...
user avatar
  • 24.7k
1 vote

"sqlite3.OperationalError: database is locked" error when generating MBTiles in QGIS

This error happens when one tries to override already existing .mbtiles file. A working solution is either (1) delete the existing output and write a new file or (2) write the output to a new file ...
user avatar
  • 22.9k
0 votes

Write layer style .qml as predefined within a gpkg using R

Thanks to @Spacedman I manage to do so by : -in Qgis(3.2) save your style in database (Geopackage) and export as .gpkg in R : #I save my style layer as an object mystyle <- sf::st_read("...
user avatar
3 votes

Making automatic updated date and time field in QGIS

Create a new date or datetime field. Go to the layer properties › Attributes Form. Select your field. Activate the checkbox Apply default value on update and set the Default value to $now.
user avatar
  • 151
0 votes

Naming the output layer created by a QGIS 'Feature filter'

While the prefix is always added by default, you can just edit the resulting green output node and remove it there.
user avatar
  • 8,082
1 vote

geopandas error "OSError: could not find or load spatialindex_c-64.dll" in PyCharm using OSGeo4W paths

To get geopandas working in a OSGeo Pycharm environment you need to import qgis processing using... from qgis import processing then... import geopandas will bring in the geopandas package EDIT ...
user avatar
  • 1,159
0 votes

Adding new vertex using QGIS Vertex editor

Caution. In some versions of QGIS it only works if you have the pixel option enabled instead of map units.
user avatar
2 votes

QgsVectorLayer no attribute setLayerName QGIS 3

Its .setName(). Use it like this: layer = iface.activeLayer() layer.setName('my new layername')
user avatar
  • 24.7k
0 votes

Creating Minimum Convex polygon around points in QGIS

I had the same problem - check that your file has a projection set. A work around I used is to convert the points to lines, convert the lines to a polygon (may need to fix the geometries at these ...
user avatar
1 vote

Using PyQGIS to buffer the width different than the height of a rectangle

Here a PyQGIS solution for 1 feature : from functools import lru_cache @lru_cache(maxsize=6) def orientation_choices(num_coords: int, axis: str = "x") -> list: if axis == "x&...
user avatar
  • 11.7k
6 votes

How to remove rectangle around label

These rectangle are probably "candidate position" (ie. emplacement the labelling engine consider while placing label, the placement engine choose the best candidate relative to your setting ...
user avatar
  • 11.8k
0 votes

Orienting line labels to graticules in QGIS

!! This only works if the point layer is in a unprojected CRS, because only then will QGIS reproject the created straight line on-the-fly into the curve on the map that follows the graticules of the ...
user avatar
0 votes

Handling too many geopackages in QGIS

Your screenshot just show that you have a lot of gpkg. As I understand, you have only one layer per gpkg. As a start point, I suggest you to have one gpkg with multiple layers!
user avatar
  • 600
2 votes

"Has no attribute geometry" error when creating polygon with Shapely

I have seen your previous question, where I would like to extend @KadirŞahbaz's answer: from shapely.geometry import Polygon ... for steps in range(numVertices): pt = geom.vertexAt(steps) ...
user avatar
  • 22.9k
1 vote

Filter layers with expression using the layers panel or SQL

Define a custom variable containing the expression you want to use for filtering layers. Then for each layer, use this variable as condition if the layer should be visible or not. When you change the ...
user avatar
  • 40k
5 votes

QgsPoint invalid argumets in PyQGIS 3

vertexAt method returns QgsPoint. So, you don't need to construct new one. You get the error since QgsPoint class doesn't have any constructor method which takes a QgsPoint argument in QGIS 3 unlike ...
user avatar
1 vote
Accepted

pyqgis 3 zoom to selected polygon without zooming in so far

I created a quick script with the setCenter method from the QgsMapCanvas class. It allows you to change the extent of the canvas without changing zoom level. It works with Polygons, Lines and Points. ...
user avatar
  • 1,375
2 votes
Accepted

Get M-value from shapefile by mouse click on canvas

There are two main issues with your code. First one is that QgsMapToolIdentify.identify() will return a list of identified features. So you will need index your result variable before accessing any ...
user avatar
  • 1,434
0 votes

Winkel II fails while reprojecting on the fly in QGIS 3.12

According to https://github.com/qgis/QGIS/issues/35512 this will work without issues in any modern QGIS that uses PROJ >= 7.1.
user avatar
  • 8,082
1 vote

Debugging Error: Algorithm gdal:dissolve not found in PyQGIS

To check whether PyQGIS has a certain algorithm one can use the following code: from qgis import processing for alg in QgsApplication.processingRegistry().algorithms(): if 'dissolve' in alg.id(): ...
user avatar
  • 22.9k
0 votes
Accepted

Land cover shapefile to raster

You can just use the tool in Rater -> Conversion -> Rasterize (Vector to raster). You can find documentation here.
user avatar
  • 2,967
0 votes

Is there a fix for "sqlite3_exe(COMMIT) failed: database is locked" QGIS 3.6 Python 3.7

Turn off labeling, then save your changes.
user avatar
  • 1
0 votes
Accepted

OGR error "is not a directory" when moving to Windows from UNIX

Explanations ERROR 1: D:/extract_TSX/SHP/input.shp is not a directory. A very common interpretation of this error through a lot of forum is the following : You have chosen a file, where a folder is ...
user avatar
  • 115
1 vote
Accepted

triggering add feature action in polygon layer using pyqgis in my plugin, the polygons will not show up, although they are there

I was able to solve this by using this code after creating the polygon layer: myalayer = root.findLayer(self.poly.id()) myClone = myalayer.clone() parent = myalayer.parent() ...
user avatar
  • 75

Top 50 recent answers are included