3

I'm trying to rotate labels based on CRS of a Europe map EPSG:3035 ETRS89-extended / LAEA Europe but with Longitude of origin 18° and Latitude origin 49°.

According to the question Parameters of the coordinate system for calculating the rotation of labels along latitude lines in the EPSG:3035 is working perfectly: enter image description here

After i change the project CRS EPSG:3035 to USER:100000 (custom CRS based on LAEA +proj=laea +lat_0=49 +lon_0=18 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs +type=crs) in the expression window appears an error: enter image description here

Any suggestion how to fix this ?

5
  • did you have a look at this solution? It should do the job: gis.stackexchange.com/a/438539/88814
    – Babel
    Sep 11 at 12:49
  • Of course, its a good solution to label the grid but i need the point layer.
    – Iven Pepa
    Sep 11 at 13:17
  • Yeah, but you need a grid that the label can follow for the curved labels - you can hide the grid. A point does not have any direction you could use for labeling and simply rotating does not really make the text follow parallels; see for results along line with custom CRS for better understanding: it is not simply a rotation: i.stack.imgur.com/ggTkN.jpg
    – Babel
    Sep 11 at 13:27
  • Yes i understand what you explained, i actually followed your answer to add the grid in the map that i have posted here, but i need to rotate city labels as you can see in the first image not the parallel labels . I know that labels in this question are not curved but I'm satisfied just with the rotation for this project. According to curved labels still need the city labels (which is the point layer) and mby if it is possible country names( polygon layer. In other words i need all labels to act as polygons based on projection transformation. Maybe I'll post another question about this.
    – Iven Pepa
    Sep 11 at 14:07
  • OK, so I hope the solution I just posted here is OK for you? This also works for polygon layers (e.g. by replacing $geometry in line 6 with centroid($geometry)).
    – Babel
    Sep 11 at 14:11

2 Answers 2

3

Curved label along a parallel

See below for variant of rotated label of a point.

To create a curved label along parallels for a point layer, create a parallel through each point you want to label. You can achieve that using geometry generator in the label placement tab (details below) to create an invisible auxiliary line used for curved label placement.

Screenshot: World map in a custom CRS with point layer in EPSG:3857 that is labeled along parallels; the dotted parallel lines are just added for visualization purpose and will not appear on the map: enter image description here

  1. In the label placement tab, activate Geometry generator > LineString and paste this expression - in line 3, change 3857 to the EPSG-code of your point layer.

    This expression createas correct parallels through the point, regardless what CRS you use for map canvas (project CRS) and whatever layer CRS you have for the input points layer (if you adapt this once in line 3):

     with_variable (
         'mycrs',
         'EPSG:3857',  -- change here: EPSG-code of the CRS of your layer
     with_variable(
         'mypoint',
         transform ($geometry, @mycrs, 'EPSG:4326'),
         transform (
             densify_by_count( 
                 make_line (
                     @mypoint,
                     project (
                         @mypoint,
                         360,
                         radians(90)
                     )
                 ), 
                 100
             ),
             'EPSG:4326',
             @mycrs
         )
     ))
    
  2. Set Mode to Curved.

  3. Expand label Anchoring > Settings and set the position to Start of Line and Clipping to Use Entire Line


Variant: rotated label of a point

If you want to have not a curved label along the parallel, but simply rotate a label the angle of the parallel at the current point, you can use a variant of the solution above:

  1. Go to Label Settings > Placement tab. Set Mode = Parallel

  2. Activate Geometry Generator > LineString and insert this expression. In line 3, replace 3857 with the EPSG-code of the layer's CRS:

     with_variable (
          'mycrs',
          'EPSG:3857',  -- change here: EPSG-code of the CRS of your layer
      with_variable(
          'mypoint',
          transform ($geometry, @mycrs, 'EPSG:4326'),
          transform (
              densify_by_count( 
                  make_line (
                      @mypoint,
                      project (
                          @mypoint,
                          1,
                          radians(90)
                      )
                  ), 
                  1
              ),
              'EPSG:4326',
              @mycrs
          )
     ))
    
  3. Increase Label Overrun > Overrun distance to 9999 [Millimeters].

You can now show the map canvas in any projection (change project CRS) and the label will be rotated to follow the direction of the parallel going through the point.

Screenshot: parallel lines only for visualization purpose: enter image description here

2
  • Let say that the labels in this way are curved and this is a good start to continue finding the right way of trying to use this model of labeling the maps. There is a problem, after using your expression in the Geometry Generator appears only some of the labels and sometimes (even when i set fixed scale at -layer properties-rendering) they are far away from the point when i zoom out/in the project. Image (postimg.cc/pmCrWDXN) after following your instructions (change the code of EPSG to USER:100000 at line 3 of the expression in geometry generator).
    – Iven Pepa
    Sep 11 at 22:20
  • See updated version to create simple rotated, not curved, labels.
    – Babel
    Sep 12 at 14:38
2

First of all, clarify that the grid convergence is not the angle of rotation of the parallel, but that of the meridian. In most cases both lines are perpendicular and the function can be used to find the rotation of the parallel.


The custom grid_convergence() function uses the coordinate reference system definitions from the PROJ library database.

When calling that function, the third argument you are using is the @map_crs variable, which contains the value 'USER:100000', which is the identifier within QGIS internal database. But PROJ doesn't know about that identifier and returns the error.

However, if instead of the @map_crs variable, you were to pass the map projection's custom proj string ('+proj=laea +lat_0=49 +lon_0=18 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs +type=crs') to the function, it should be interpreted by PROJ without any problem.

1
  • 1
    Yea this work, i tried this way by changing the EPSG:;4326 of x and y not the @map_crs that's why didn't work. Now its fine and i think this will work for every custom proj that is needed. Thank you. Image of result (postimg.cc/hXTwTrQw)
    – Iven Pepa
    Sep 11 at 22:26

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.