2

This is the first time I am using any GIS program. I am trying to calculate area of inner polygon by offsetting sides by different amounts.

For example; I have a GeoJSON file, similiar to red polygon in the example image below.

enter image description here

I want to create the blue polygon by offsetting each line by different amount (in meters) and calculate the area of blue polygon.

I have tried converting polygon to lines, used one sided buffer for each amount (3 meters and 5 meters in this example) and used those new buffered layers as a guide to draw blue polygon by myself.

My method seems to work but it is labor intensive and error prone. I imagine there must be more practical and robust method to achive something like this in a GIS software.

3
  • How do you decide the distance to offset each segment? You want to do it manually for each? Commented Nov 7 at 20:11
  • Welcome to GIS SE. As a new user, please take the Tour, which emphasizes the importance of asking One question per Question. Please Edit the Question to remove the "Bonus question", which may cause closure. Commented Nov 7 at 23:35
  • 1
    @Bera Values are different for each polygon. I get values from technical documentation. So I have to input each one manually. Commented Nov 8 at 3:13

1 Answer 1

1
+50

You can use QGIS expressions with Geometry Generator or Geometry by Expression to create the polygon and then measure its area. For each side (edge) of the polygon, you can define the distance to shift the line.

Orange = initial polygon, blue = version modified with the expression: enter image description here

The expression (see below) works like this:

  1. Get the boundary of the polygon
  2. Get each segment as a separate line in an array
  3. Loop through this array and offset each of these lines with an individual, pre-defined distance (see next screenshot, first image on the left for the result so far)
  4. Connect the shited lines with the initial lines (screenshot: image 2, in the middle)
  5. Convert these lines to polygons and merge these polygons into a single one (screenshot: image 3 on the right)
  6. Get the difference of the initial polygon with the polygon created in step 5.

enter image description here

Use the following expression. In line 3 you find the values valid for each side of the initial polygon: how much should this side be moved inwards (if you put negative values: outwards). In my case, using the same shape as yours, the right side is the first one, it remains in place, thus: 0.

Then it turns clockwise, shifting the sides for 3,5,5 and another 5 meters:

with_variable( 'no', array(0,3,5,5,5), -- replace with your values with_variable( 'sides', geometries_to_array( segments_to_lines (@geometry) ), difference( @geometry, buffer( collect_geometries( array_foreach( generate_series( 0, array_length(@sides)-1 ), make_polygon( make_line( start_point(@sides[@element]), end_point(@sides[@element]), end_point ( offset_curve( @sides[@element], -@no[@element] ) ), start_point ( offset_curve( @sides[@element], -@no[@element] ) ) ) ) ) ), 0 ) ))) 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.