New answers tagged

2

Your code worked just fine for me, so I think that make it throws that error because you have some topology error in your shape. I've just adapted your code adding a check and repair part in order to avoid error (st_is_valid and st_make_valid). Here you can download the data and code I've used. library(sf) library(mapview) # Load data my.sf <- st_read(...


1

I faced the same problem and according to me, the best way to solve it is to use v.clean GRASS tool with the following parameters. Input feature type: line Cleaning tool: break The line will be divided into segments at the overlapping points. Then you can use "Delete duplicate geometries"


2

I've made a PR to support your requirement at https://github.com/qgis/QGIS/pull/36479 You can take the file RandomPointsPolygons.py from the PR and replace the one on your machine with the same name (make a copy before, to be safe). Then, restart QGIS and it should do what you want.


5

I am assuming you have a single layer which contains the 400 polygons. Each of these polygons should have a unique ID field for this to work. This could be an integer, or if each of the polygons has a unique name then that would be fine too. First step is to use the "Split vector layer" tool from the processing toolbox with the input being your 400 polygon ...


3

You could split your points into a list where each element is a group (A, B). Then you can use lapply to iterate over each group. point_list <- split(pts, pts$id) # split points into list by id res <- lapply(point_list, function(x) length(unlist(st_intersects(x, sa_pa_data))) / nrow(x) ) unlist(res) A B 0.06 0.02


3

Similar to @Taras's answer, you can create a virtual layer to get the actual border lines, and then compute their length (or display them, or label them, or ...) Go to the menu Layer > Add Layer > Add/Edit Virtual Layer... and enter the following query. select a.id as poly1_id, b.id as poly2_id, st_intersection(a.geometry, b.geometry) as geometry, ...


5

Preamble: this solution was being written before the moment when the author demonstrated his efforts in the field calculator. In QGIS I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer.... Let's assume we have a layer "units_1" (yellow) with its corresponding attribute tables accordingly, see image below. With ...


5

Here I am using Virtual Layer approach because it can save me from following a step-by-step workflow, where the output of the previous has to be used as the input for the next geoalgorithm. In QGIS I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer.... Let's assume we have two layers "units_1" (yellow) and "...


6

Goal: Isolate the small polygons adjacent to the border which divides them into two different larger polygons/areas. Concept: Either select everything by hand (feasible if this is only a one-time-job and few polygons like in this case), or use the select by location tool to select all areas adjacent to the border. To do so we need to get the line feature of ...


1

This may reduce the steps in the workflow. (1) Explode lines (same as your first step) (2) On the Exploded layer, Count the number of overlaps using an expression: count('Explode', group_by:=geom_to_wkt($geometry)) Some use-cases will be: (A) To set the line width: (B) To use it for the label: Input Output


Top 50 recent answers are included