Hot answers tagged

14

You can use the following example script. The script removes all holes from a polygon whose area is greater than eps. from shapely import wkt from shapely.geometry import Polygon # sample polygon polygon_wkt = 'Polygon ((670651.58235156117007136 4087356.72129086637869477, 670941.20806862262543291 4087351.57990169199183583, 670944.42234629089944065 4087244....


10

There are several options to try. possibly all these yield a reasonable result, but sometimes one needs to be more creative. Basic options: buffer the layer by a very tiny amount (for example 0.01 meter), then dissolve use v.clean the bleacher ;) of all artifacts. You will have to play with some of its options among the ones under Cleaning tools. Judging ...


9

Using the green plus in the symbology tab of your layer properties, add a second symbology. Change that type to border - marker line and the placement of the markers to every vertex.


7

QGIS provides Field Calculator (abacus icon in Attributes Toolbar) which allows you to assign (calculate) attribute values to existing or new field, for selection or all features. You can also use Digitizing Toolbar which after making layer editable, and selecting features provides tool Modify the Attributes of All Selected Features Simultaneously (icon with ...


7

Use Categorized renderer, make the settings based on value, than change to Rule-based renderer and add another rule for category. To get a border around the category='yes' countries, but not between them, set the last style at the bottom to Geoemtry generator and use this expression: buffer ( collect ( $geometry, filter:=category = 'yes'...


7

You can define a custom function to get crs extent. from qgis.core import * from qgis.gui import * @qgsfunction(args='auto', group='Custom') def crs_extent(layer_name, feature, parent): layers = QgsProject.instance().mapLayersByName(layer_name) if layers: bounds = layers[0].crs().bounds() else: raise ValueError(f"Layer {...


5

Open the Processing Toolbox and search for the "Extract by location" tool. Choose your cadastral layer as "Extract features from", "contain" as geometric predicate and your houses layer as "By comparing with features from": Run it and done. You will get a new layer containing only the cadastral features which fully ...


5

You should union the 2 selects like: SELECT b.geometry FROM building b UNION SELECT p.geometry FROM plot p;


4

Create random points and from these, use Menu Processing / Toolbox / Rectangles, ovals, diamonds, select rectangles and set the size.


4

As suggested in this answer, use ST_ClusterDBSCAN to assign an id to each touching group of polygons: SELECT *, ST_ClusterDBSCAN(geom, 0, 1) OVER() AS clst_id FROM poly_table;


4

You can automate the classification using r.geomorphon: Zonal histogram then calculate the ratio of ridges (class 5, 6, 7). With my data if the value is <0.6 it is a valley.


3

I can offer up an alternative approach to processing the data. Reviewing your images it appears the segments of the straight line that fall inside your polygon you drop and you follow the polygon edge. A simple dropping of those would resolve most issues BUT as you have identified; when the polygon edge does a U-shape that logic breaks down. I see you have ...


3

For me your shapefile with polygons seems to be okay. I checked it with the "Check validity". Here is the recreated problem: It appeared because basic usage-requirements were not met when working with the "Split Features". So, there are several ideas on how to overcome it: Either the splitting line has to be drown beyond the geometry ...


3

It is not a solution using the expression, it may seem a bit lamer. Let's assume there are two layers: a point 'random_points_test' and a polygon 'poly_test' respectively, see image below. Step 1. Use the "Join attributes by location" to get "id"s from polygons Step 2. Proceed with the "Add autoincremental field" geoalgorithm ...


3

Apart from joining or virtual layer (this would be another, slightly more complex solution), you can simply use Select by expression on the layer polygon with this expression. In the second last line, replace Smith with the name you're looking for: array_contains( with_variable( 'id', id, aggregate( 'owner', ...


2

Yes, well, I finally solved it. Thanks everyone for the help! The solution was far from intuitive. It appears first I join empty, newly created shapefile with the corresponding Excel, and then export the shapefile to another one, and now I can edit the values in the atribute table like I'd expect. As to polygons - it seems they can be created either in the ...


2

Advice Your question seems quite basic, so I advice you to have a look at some tutorials (like Klas Karlsson's QGIS 3 for Absolute Beginners), books (like Kurt Menke's Discover QGIS 3.x) and the QGIS documentation - I added a few links below. There are many more great resources out there. The Problem Excel files, CSV data, KML etc. are file formats that have ...


2

Use this expression (explanation see below): to_int( array_find ( array_sort ( array_agg( x( geometry ( get_feature_by_id ( @layer, $id ))), group_by:= array_first ( ...


2

This can be achieved using a "Virtual Layer". Go the the menu layer / add layer / add-edit virtual layer and enter the following query. You would have to change the layer name and field name(s) to suit your needs. The output is a dynamic table, which you can then join back to your polygon layer. Since the line length is involved, it assumes the ...


2

Try the "Difference" that will do exactly what you want: Extracts features from the input layer that don’t fall within the boundaries of the overlay layer. 'Input layer': gray 'Overlay layer': yellow and get the desired output


2

You can extract the x and y coords from a Shapely polygon as follows. import shapely from shapely import wkt wkt = 'POLYGON ((5.458 8.644, 4.222 5.556, 3.000 6.000, 5.000 9.000, 5.458 8.644))' poly = shapely.wkt.loads(wkt) x,y = poly.exterior.coords.xy print(' x coords:', list(x), '\n', 'y coords:', list(y)) ## returns ## x coords: [5.458, 4.222, 3.0, 5....


2

You can merge touching polygons, see this answer: https://stackoverflow.com/a/49970447/2816941 This will produce a layer for these "islands". Then you can simply join back onto the islands from the original data using st_intersects(islands.geom, st_pointonsurface(original.geom))


2

You can modify the expression by using: line_locate_point (to get the distance from the start-point of the line to the point where the line intersects with the polygon (white dot on the screenshot below: the point point where the line intersects the polygon for the second time, = step 5 in the original solution) line_substring to get the substring (blue on ...


1

New Answer: It turned out, the thing I was looking for was the so-called concave hull, or alpha shape of the string. There are implementations to calculate the alpha shape, and I found one particularly helpful post on StackOverFlow. The only drawback is that alpha has to be chosen for each set of points within the MultiLineString individually. This alpha can ...


1

For raster layers, use raster calculator and create the sum of the values. For polygon layers, proceed as follows: Get all your isochrone layers in one with Merge vector layers Get the Bondary Create separate polygons with Split with lines (inputs: layeres from step 1 and 2) Delete duplicate geometries Use this expression to calculate for each ...


1

You can create the combination of the two geometries and use this as coverage layer for your Atlas. There are at least three possibilities to add the features of the two layers. The first (and preferable) one will not create new data and any change in one of the two initial layers is automatically reflected - that comes as close as possible as using two ...


1

I think you can solve this using a single coverage layer (the plots) and then use an expression to set the extent of the map to the bounds of the enclosing block based on the location of the plot.


1

In QGIS I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer... Let's assume there are two polygon layers 'grid_test' (red) and 'grid_test2' (green) respectively, see image below. With the following query, it is possible to achieve the result, i.e. to to calculate the population that each polygon in '...


1

You can do either from qgis.core import (QgsPolygon, QgsLineString, QgsPoint) # From a Python list points = [[0.0, 10.0, 3.0], [5.0, 8.0, 4.0], [9.0, 5.0, 1.0], [0, 10, 3.0]] poly3d = QgsPolygon(QgsLineString([QgsPoint(*point) for point in points])) or from qgis.core import (QgsPolygon, QgsLineString, QgsPoint) # We create manually list of 3D points but ...


1

No real solution has been found yet, but I got a workaround that worked quite nicely. I got rid of slivers around polygons in QGIS after a Difference tool by first buffering the feature by 5cm. For my case a slight inaccuracy in area was less important than getting rid of the "Difference slivers". The Difference tool also created some unwanted ...


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