2

I use QGIS 3 to create maps with coordinate grid. Often, when I change the extent of a map, my coordinate grid tilts and becomes not parallel with the paper borders. This looks very awful, and I have to manually change the orientation of the grid.

Is there a way to automate this manual process and make the edges of my coordinate grid stay parallel to the edges of the paper?

6

To perform dynamic North Pole grid orintation paste the code (see below) in Map rotation box parameter of your map item.

enter image description here

Here is a comparison with a static oriented grid:

enter image description here

Code block (in a line):

-1 * degrees(azimuth(map_get(item_variables('map'), 'map_extent_center'),transform(geom_from_wkt('POINT(0 90)'),'EPSG:4326',map_get(item_variables('map'),'map_crs'))))

Code block (human readable format):

-1 *
degrees(
        azimuth(
                map_get( 
                        item_variables('map'), 
                        'map_extent_center'
                        ),                      
                transform(
                          geom_from_wkt('POINT(0 90)'),
                          'EPSG:4326',
                          map_get( 
                                  item_variables('map'),
                                  'map_crs' 
                                  )
                          ) 
                ) 
            )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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