1

enter image description hereIn QGIS 3.14 I want for a layer with street contours (polygons) to record the names of the areas through which the street passes and the numbers of cadastral plots through which it passes.

If a street intersects several objects, their names must be written in one field after a comma. How do I solve this problem?

enter image description here if the area of the area falling into the boundaries of the street is less than the specified value, then its name is not taken into account

enter image description here

5
  • 3
    Hi Ivan, it is a bit unclear what you're asking. You seem to have a solution, which you don't present, and then ask for a more efficient one. How should we decide, if our solution is more efficient than yours? Or are you asking "how do I do this"? Both possible questions lack details, e.g. your existing solution, your data structure, some example data, and an example of your desired output.
    – Erik
    Commented Nov 23, 2020 at 11:34
  • 1
    Hi Erik, I edited my question
    – Ivan M
    Commented Nov 23, 2020 at 12:11
  • Thank you! But this is only the first part of the task. I need to add conditions - if the area of the area falling into the boundaries of the street is less than the specified value, then its name is not taken into account
    – Ivan M
    Commented Nov 23, 2020 at 13:35
  • Please accept the answer that I posted if it solves your question.
    – Taras
    Commented Dec 11, 2020 at 7:39
  • 1
    Thanks for your help!
    – Ivan M
    Commented Dec 14, 2020 at 7:57

1 Answer 1

0

To extend the query in this answer with an "area"-rule, i.e. consider value only if the intersection is more than a certain value, then consider a slightly adjusted query:

SELECT a.*, GROUP_CONCAT(b.info) AS concat_b_info
FROM "Layer_B" AS b, "Layer_A" As a
WHERE ST_INTERSECTS(a.geometry, b.geometry)
      AND ST_AREA(ST_INTERSECTION(a.geometry, b.geometry)) > 80000000
GROUP BY a.id

Or consider in the Field Calculator the following expression:

aggregate(
  layer:='Layer_B',
  aggregate:='concatenate',
  expression:="info",
  concatenator:=',',
  filter:=(intersects($geometry,geometry(@parent)) AND area(intersection($geometry,geometry(@parent))) > 80000000)
)

Keep in mind that 'area'-function

Returns the area of a geometry polygon object. Calculations are always planimetric in the Spatial Reference System (SRS) of this geometry, and the units of the returned area will match the units for the SRS. This differs from the calculations performed by the $area function, which will perform ellipsoidal calculations based on the project's ellipsoid and area unit settings.

When areas of the overlapping features have to be additionally calculated, use this

SELECT a.*, GROUP_CONCAT(b.info) AS concat_b_info,
            GROUP_CONCAT(round(ST_AREA(ST_INTERSECTION(a.geometry, b.geometry)), 4)) AS a_b_areas
            -- GROUP_CONCAT(round(ST_AREA(b.geometry), 4)) AS b_areas
FROM "Layer_B" AS b, "Layer_A" As a
WHERE ST_INTERSECTS(a.geometry, b.geometry)
      AND ST_AREA(ST_INTERSECTION(a.geometry, b.geometry)) > 80000000
GROUP BY a.id

or in the Field Calculator with a new field for area values:

aggregate(
  layer:='Layer_B',
  aggregate:='concatenate',
  expression:=to_string(round(area(intersection($geometry,geometry(@parent))),4)),
  # expression:=to_string(round(area($geometry),4)),
  concatenator:=',',
  filter:=(intersects($geometry,geometry(@parent)) AND area(intersection($geometry,geometry(@parent))) > 80000000)
)
3
  • Thank you! It works! And what function should I use in the field calculator to write the areas of incoming areas over a comma? Or their sum. Thank you!
    – Ivan M
    Commented Nov 23, 2020 at 14:57
  • Taras,two options are possible - the sum of the areas of the crossing parts or the values ​ ​ of the areas of the crossing parts by a comma.
    – Ivan M
    Commented Nov 23, 2020 at 15:17
  • How to write this one "Full areas use (GROUP_CONCAT(ST_AREA(b.geometry))) or (GROUP_CONCAT(ST_AREA(ST_INTERSECTION(a.geometry, b.geometry))))" in the field calculator?
    – Ivan M
    Commented Nov 23, 2020 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.