Skip to main content
added 458 characters in body
Source Link
Babel
  • 74.9k
  • 15
  • 87
  • 227

To get an array withCalculate the length of the border the current polygon shares with all bordering polygons, use this expression that creates an array:

Convert it to a string with array_to_string(), add the $id to identify tothe polygons etcand add other modifications (see below).

A polygon layer with an expression-generated label, based on the expression from above, that generates a text-string list of length with all neighboring polygons (see below for the exact expression used here):

  • The expression used to generate the red line in the screenshot, using Geometry generator:

    The expression used to generate the red line in the screenshot, using Geometry generator:

    if ($id = 1, intersection ( $geometry, overlay_touches (@layer, $geometry)[0]),'')
    
if ($id = 1, intersection ( $geometry, overlay_touches (@layer, $geometry)[0]),'')
  • To generate the length of the common boundary line of polygons b and c, stored in the field named name, use this expression (change layer name and value in lines 2 and 6):

    if (
        name = 'b', 
        length(
            intersection ( 
                $geometry, 
                geometry (get_feature (@layer, 'name', 'c'))
            )
        ),
        ''
    )
    
  • The expression used to generate the label in the screenshot - can be used without changes on any polygon layer:

    The expression used to generate the label in the screenshot - can be used without changes on any polygon layer:

     'Length border of polygon '  || 
     $id || ' with: '  ||  '\n'  ||  
     array_to_string (
         array_foreach (
             overlay_touches (@layer, $id),
             '   - polygon'  || 
             @element || ': ' || 
             round (
                 length (
                     intersection (
                         $geometry, 
                         geometry (
                             get_feature_by_id (
                                 @layer, 
                                 @element
                             )
                         )
                     )
                 ), 
                 3
             ) 
         )
     )
    
'Length border of polygon '  || 
$id || ' with: '  ||  '\n'  ||  
array_to_string (
    array_foreach (
        overlay_touches (@layer, $id),
        '   - polygon'  || 
        @element || ': ' || 
        round (
            length (
                intersection (
                    $geometry, 
                    geometry (
                        get_feature_by_id (
                            @layer, 
                            @element
                        )
                    )
                )
            ), 
            3
        ) 
    )
)

To get an array with the length of the border the current polygon shares with all bordering polygons, use this expression:

Convert it to a string with array_to_string(), add the $id to identify to polygons etc.

A polygon layer with an expression-generated label, based on the expression from above, that generates a text-string list of length with all neighboring polygons (see below for the expression used here:

  • The expression used to generate the red line in the screenshot, using Geometry generator:
if ($id = 1, intersection ( $geometry, overlay_touches (@layer, $geometry)[0]),'')
  • The expression used to generate the label in the screenshot - can be used without changes on any polygon layer:
'Length border of polygon '  || 
$id || ' with: '  ||  '\n'  ||  
array_to_string (
    array_foreach (
        overlay_touches (@layer, $id),
        '   - polygon'  || 
        @element || ': ' || 
        round (
            length (
                intersection (
                    $geometry, 
                    geometry (
                        get_feature_by_id (
                            @layer, 
                            @element
                        )
                    )
                )
            ), 
            3
        ) 
    )
)

Calculate the length of the border the current polygon shares with all bordering polygons, use this expression that creates an array:

Convert it to a string with array_to_string(), add the $id to identify the polygons and add other modifications (see below).

A polygon layer with an expression-generated label, based on the expression from above, that generates a text-string list of length with all neighboring polygons (see below for the exact expression used here):

  • The expression used to generate the red line in the screenshot, using Geometry generator:

    if ($id = 1, intersection ( $geometry, overlay_touches (@layer, $geometry)[0]),'')
    
  • To generate the length of the common boundary line of polygons b and c, stored in the field named name, use this expression (change layer name and value in lines 2 and 6):

    if (
        name = 'b', 
        length(
            intersection ( 
                $geometry, 
                geometry (get_feature (@layer, 'name', 'c'))
            )
        ),
        ''
    )
    
  • The expression used to generate the label in the screenshot - can be used without changes on any polygon layer:

     'Length border of polygon '  || 
     $id || ' with: '  ||  '\n'  ||  
     array_to_string (
         array_foreach (
             overlay_touches (@layer, $id),
             '   - polygon'  || 
             @element || ': ' || 
             round (
                 length (
                     intersection (
                         $geometry, 
                         geometry (
                             get_feature_by_id (
                                 @layer, 
                                 @element
                             )
                         )
                     )
                 ), 
                 3
             ) 
         )
     )
    
added 752 characters in body
Source Link
Babel
  • 74.9k
  • 15
  • 87
  • 227

To get an array with the length of the border the current polygon shares with all bordering polygons, use this expression:


    array_foreach (
        overlay_touches (@layer, $geometry),
        length (intersection ($geometry, @element))  
    )

Convert it to a string with array_to_string(), add the $id to identify to polygons etc.

A polygon layer with an expression-generated label, based on the expression from above, that generates a text-string list of length with all neighboring polygons (see below for the expression used here:

enter image description here

  • The expression used to generate the red line in the screenshot, using Geometry generator:
if ($id = 1, intersection ( $geometry, overlay_touches (@layer, $geometry)[0]),'')
  • The expression used to generate the label in the screenshot - can be used without changes on any polygon layer:
'Length border of polygon '  || 
$id || ' with: '  ||  '\n'  ||  
array_to_string (
    array_foreach (
        overlay_touches (@layer, $id),
        '   - polygon'  || 
        @element || ': ' || 
        round (
            length (
                intersection (
                    $geometry, 
                    geometry (
                        get_feature_by_id (
                            @layer, 
                            @element
                        )
                    )
                )
            ), 
            3
        ) 
    )
)

To get an array with the length of the border the current polygon shares with all bordering polygons, use this expression:


    array_foreach (
        overlay_touches (@layer, $geometry),
        length (intersection ($geometry, @element))  
    )

Convert it to a string with array_to_string(), add the $id to identify to polygons etc.

To get an array with the length of the border the current polygon shares with all bordering polygons, use this expression:


    array_foreach (
        overlay_touches (@layer, $geometry),
        length (intersection ($geometry, @element))  
    )

Convert it to a string with array_to_string(), add the $id to identify to polygons etc.

A polygon layer with an expression-generated label, based on the expression from above, that generates a text-string list of length with all neighboring polygons (see below for the expression used here:

enter image description here

  • The expression used to generate the red line in the screenshot, using Geometry generator:
if ($id = 1, intersection ( $geometry, overlay_touches (@layer, $geometry)[0]),'')
  • The expression used to generate the label in the screenshot - can be used without changes on any polygon layer:
'Length border of polygon '  || 
$id || ' with: '  ||  '\n'  ||  
array_to_string (
    array_foreach (
        overlay_touches (@layer, $id),
        '   - polygon'  || 
        @element || ': ' || 
        round (
            length (
                intersection (
                    $geometry, 
                    geometry (
                        get_feature_by_id (
                            @layer, 
                            @element
                        )
                    )
                )
            ), 
            3
        ) 
    )
)
Source Link
Babel
  • 74.9k
  • 15
  • 87
  • 227

To get an array with the length of the border the current polygon shares with all bordering polygons, use this expression:


    array_foreach (
        overlay_touches (@layer, $geometry),
        length (intersection ($geometry, @element))  
    )

Convert it to a string with array_to_string(), add the $id to identify to polygons etc.