3

While modifying some geometries in QGIS in my previous question Adjusting flow map styles in QGIS: Varying buffers' sizes I ended up with a huge confusion regarding the dimensions/units that Geometry Generator in QGIS works with.


For instance, I do have a point layer that responds to my visualization purposes, units are Millimeters.

point_layer_millimeter

Points are visualized with Graduated symbols using the following specifications. 6 groups, sizes from 1 to 6 Millimeters.

Point_layer_setting

But when I apply Map units the visualization aspect changes dramatically. Those points are visible only at large map scales and cannot be viewed at the same map scale that used for the image above. As I should, I am working with projected CRS, where units are Meters.

How to convert the dimensions into Units or Pixels to be able to deploy Geometry Generator on the next step and at the same time maintain the visualization aspect? How should I adjust the parameters of my points?

Because when I want to use this point layer in the Geometry Generator (i.e. start_point() and end_point()) I have to have Map Units. I require those aspects to adjust the place where lines between points should start and end.

difference(
    difference($geometry,
        buffer(start_point($geometry),
        CASE
        WHEN "From_Value" IS NOT NULL THEN scale_exp("From_Value"/ "From_Value"*2, @From_min, @From_max, 2, 12, 1)
        ELSE 0
        END
        )
    ),
    buffer(end_point($geometry),
    CASE
    WHEN "To_Value" IS NOT NULL THEN scale_exp("To_Value"/ "To_Value"*2, @To_min, @To_max, 2, 12, 1)
    ELSE 0
    END)
)

Am I correctly understand that Geometry Generator works only with Map Units, or?

  • 1
    There are also points and inches units in QGIS 3.6 – ahmadhanb Mar 5 at 7:36
  • 1
    Perfect let's extend it! – Taras Mar 5 at 7:38
  • Geometry generator should work with mm, too. Unless you want to cover the exact geometric distance between two features, then you have to use map units. You could, however, scale your proportional point data by say 1/10, or even logarithmic. – Erik Mar 5 at 7:47
  • Using map units instead of 'desktop units' like mm gives you more control on geometry and label size in different zoom levels, since the size changes when zooming. In building a geological map for print in 1:100000 you need more control of geometry and labels. Remember to set a large size of label or geometry when using map units. For a 1:100000 i use 200-300 meters as size value. – Jakob Mar 5 at 8:01
  • 1
    @bugmenot123, let me accomplish that! Otherwise, I can just cut the "Example-based Question". What do you think will be the best idea? Deleting something from this question, if yes which part it might be? – Taras Mar 5 at 9:37
3

The size of the symbol can be defined in two ways :

Relative to the map canvas: pixel, points, millimeter and inches

or

Relative to the reality: maps unit

If you work with a size defined based on the map canvas, this size will remain constant when you zoom in and out. If you work in map unit, the size of the symbol will change when you zoom in and out (like if you had a buffer of the requested size around your point.)

In practice, the conversion from mm to points or pixels depends on the resolution of your screen (what is the size of your pixel in mm). And the conversion of map unit (in fact, unit of the coordinate system of the map) to millimeter depends on the scale. So, for example, let us assume that you are in UTM, then the unit of the map is in meters. If you want to display this data at a scale of 1/25000 with a point size of 5 mm, this is :

5 mm * 25000 = 125000 mm = 125 m

0

To get a geometry to display a certain size on the canvas regardless of scale, multiply your desired size in map units by the @map_scale variable - e.g. to get a 1 mm geometry on an Irish Grid map (metres) use 0.001*@map_scale.

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.