Frequently Asked Question

How to generate the pies coordinates automatically in Custom Map with QGIS
Dernière mise à jour il y a 2 ans

Symptom

  • Add automatically the pies coordinates for each zone of a Custom Map  (used in the Mapline or Drillmap components) with QGIS

Environment

  • QGIS v3.x
  • Need4Viz : all versions

Resolution

To add automatically the pies coordinates for each zone of a Custom Map, you need to add the "latitude" and "longitude" attributes of the center of each zone. This could be done automatically with QGIS by a calculation of the centroïdes.

Check the projection of the map. If it's not a WGS84, reproject the map in the WGS84 coordinates :

image
image

Open the table attributes

image

Edit the table

image

Add a new field

image

Create the "latitude" text field (length = 0)

image

Choose the newly created field "latitude" :

image

And clic the "E" symbol to open the Expression dialog

image

Enter the formula y(centroid($geometry)) (the output preview should give a correct latitude coordinate) :

image

Once validated ("OK"), update all the attributes :

image
image

In the same way, create a new text field "longitude" and feed the corresponding value with the formula x(centroid($geometry))

image

Save the edition and close the table attributes window

image

Then export the new layer :

image

If you want the pie of a specific zone to be displayed with different coordinates (to get a better render), just update the latitude and longitude coordinates attributes of the corresponding zone in the Geojson (or .js) file.

Veuillez patienter!

S'il vous plaît patienter... il faudra une seconde !