3

I want to interactively calculate the area of a geometric object and use different projections depending on its location.

Source data is stored in WGS 84. The area should be calculated in the WGS 84 UTM ХХ zones (also they are different for the south and north pole).

How can this be achieved using QGIS?

1 Answer 1

3

Interactive calculation of the object area depending on its location can be done in QGIS with the help of an auxiliary layer, which contains UTM zones and EPSG column, in which for each UTM zone must be a unique EPSG identifier (examples are in the question).

auxiliary layer UTM

This code should be used to calculate the EPSG column (see this answer). If the object is in more than one UTM zone, the expression determines which zone contains the largest portion of the object.


with_variable('feat',
              get_feature_by_id('UTM',
                                array_first(overlay_intersects('UTM', 
                                                               $id, 
                                                               sort_by_intersection_size:='des'
                                                               )
                                            )
                                ), 
             attribute(@feat, 'EPSG')
             )

This code should be used to calculate the area column:


area( 
     transform($geometry, 
               @layer_crs,
               'EPSG:' || to_string(EPSG)
               )
     )

Note that the projection of the auxiliary UTM layer and the layer in which the area is calculated must be the same.

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.