14 votes

Best practices to show extent of Print Composer maps in main canvas in QGIS

There is a native feature in QGIS to display print extents in the map canvas. But if you want proper GIS polygons in a layer, you should indeed use some PyQGIS with the script provided in the other ...
  • 6,566
13 votes
Accepted

Rotating polygons to follow the curve (line) in 90 degree in QGIS

Create the line (if not already done) Use the algorithm "Points along geometry" to create your points. This algorithm will automatically add a field called "angle" to the points. ...
  • 29.8k
10 votes

Converting lines (edges) to polygons with Python

I will firstly start with your code. There is no need to manipulate the list with lists of coordinates, as you did it with geometry.Polygon([[p[0], p[1]] for p in cxy]). The class Polygon(shell[, ...
  • 27.3k
9 votes

Rotating polygons to follow the curve (line) in 90 degree in QGIS

If you start with the only blue line and don't want to add new layers : Set up the points and squares at a specific distance by adding two symbols lines (one for each). On the square line, make sure ...
  • 914
9 votes
Accepted

Smoothing round border of created buffer in QGIS

This is a case for a convex or concave hull - depending how much additional space you want to include. Concave hull gives you more flexibility: there is just one single convex hull per geometry, but ...
  • 52.5k
9 votes
Accepted

Creating polygons from points with postal codes in QGIS

Starting with a set of points with attribute "code", shown here as a label: First use "Voronoi Polygons" to construct the polygons that divide the space up to the region nearest ...
  • 56.8k
8 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: ...
  • 27.3k
8 votes
Accepted

Best practices to show extent of Print Composer maps in main canvas in QGIS

PyQGIS is a solution. Below a script that creates a new memory layer with you map item extent as a polygon and adds it to the canvas. You have just to configure the constants with your layout name and ...
  • 14.4k
8 votes

Finding the largest empty circle that fits within point layer in QGIS

What you can do is the following: create Voronoi polygons from your 'points' (will provide equal distance lines from points) - Processing Toolbox/Voronoi create a convex hull from your points (will ...
  • 1,967
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 ...
  • 13.1k
6 votes
Accepted

Creating minimal enveloping polygon to set of geometries in GeoPandas

What you need is a concave hull. Create a list of all polygons coordinates and concave hull them. This takes about 30 s for two polygon groups so try it on a subset if you have a very large dataset. ...
  • 58.4k
6 votes
Accepted

Create polygons around centroids, maintaining information

You can use "Rectangles, ovals, diamonds" tool. Make sure the unit is degrees. If you use this tool, each grid polygon will have all information of the related point, but possible. Result: ...
6 votes

Getting part of polygon that is closer to point A than point B in QGIS

You can use QGIS expressions with either "Geometry generator" (for visualization only) or "Geometry by expression" (to create actual geometries): see here for details about both ...
  • 52.5k
5 votes

Removing overlapping polygons without merging any polygons in QGIS

You can use the following script if it is not important which polygon part to delete. (after selecting the layer) layer = iface.activeLayer() dpr = layer.dataProvider() # iterate over the layer for ...
5 votes
Accepted

Removing overlapping polygons without merging any polygons in QGIS

If I understood you correctly, all you need to is an intersect of the poylgon layer with itself, and in the resulting attribute table you will have the intersections of polygons with all other ...
  • 2,278
5 votes

Сreating buffer in meters using GeoPandas

Yes you need to reproject into a coordinate system with meters as units. import geopandas as gpd df = gpd.read_file(r'C:\GIS\data\tempdata\points_wgs84.shp') df = df.to_crs(3043) #Pick another df['...
  • 58.4k
5 votes
Accepted

Creating middle line between two lines in QGIS

Generic/algorithmic description On one of the lines, create points in a regular interval. Connect these points to the closest point of the other line by creating a line. Get the centroid of these ...
  • 52.5k
5 votes
Accepted

Importing grid layer from CSV in QGIS

If you import your CSV as a delimited text layer, you could use the Geometry by Expression tool on the layer to construct the polygons with this expression: make_rectangle_3points( make_point(&...
  • 10.4k
5 votes

Importing grid layer from CSV in QGIS

A PyQGIS solution. Proceed with Plugins > Python Console > Show Editor and paste the script below: # imports from csv import reader from ast import literal_eval from os.path import normpath from ...
  • 27.3k
4 votes
Accepted

Setting flat end caps for polygon using Geometry Generator in QGIS

As of the current QGIS 3.22 (LTR) the buffer() function in Expression Builder now has parameters for join type, cap type etc. So by using for example buffer($geometry,2, cap:='flat') one can have a ...
  • 8,419
4 votes

Representing roads consisting of polylines as polygons in QGIS

You can make polygons with the buffer tool.
  • 2,299
4 votes

Scaling polygons in vector grid around polygon centers in QGIS

From QGIS 3.24, you can use the "Geometry by expression" tool with the scale function. scale( geometry:=$geometry, x_scale:=0.5, y_scale:=0.7 )
  • 10.4k
4 votes

Getting part of polygon that is closer to point A than point B in QGIS

Here's an approach that might need some adjustment for a particular case. Use "Points to path" to create a line joining the two points. Use "Extend lines" to add a large distance ...
  • 56.8k
4 votes

Creating polygon by specifying area and some (irregular) boundaries

I have created a script that work well for a few examples I made. The calculations are all cartesian, so if the Coordinate Reference System of your polygon layer has poor accuracy or is geographic, ...
4 votes

Splitting polygon on the curving edges using QGIS

Working with provided input layer called 'data', see the image below. Step 1. Apply the "Oriented minimum bounding box" geoalgorithm Step 2. Make use of the "Centroids" and the &...
  • 27.3k
4 votes
Accepted

Union polygons by intersection lines in QGIS

Use the "Join Attributes by Location" tool via Vector -> Data Management Tools -> Join Attributes by Location. For your specific needs, I would suggest starting with the following ...
4 votes

Union polygons by intersection lines in QGIS

You can achieve this using a "Virtual Layer". Go to the menu Layer > Add Layer > Add/Edit Virtual Layer... and enter the following query. Modify the name of the layers and feel free to ...
  • 37.3k
4 votes

Smoothing round border of created buffer in QGIS

You can increase the number of segments used to approximate a curve using the "Segments" parameter of the QGIS's Buffer tool: 150m buffer created using the default 5 segments on top of a ...
  • 56.8k
4 votes

Smoothing round border of created buffer in QGIS

Another option is first to apply another buffer at a relativele larger distance and then apply once again a buffer with the negative value of this distance. This keeps the result more or less at the ...
  • 52.5k
4 votes

Importing grid layer from CSV in QGIS

If you can generate additional columns in your .csv you can generate a WKT string (POLYGON) column directly in the .csv: POLYGON(left bottom, left top, right top, right bottom, left bottom) and then ...
  • 1,967

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