Frequently Asked Question
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 :
Open the table attributes
Edit the table
Add a new field
Create the "latitude" text field (length = 0)
Choose the newly created field "latitude" :
And clic the "E" symbol to open the Expression dialog
Enter the formula y(centroid($geometry)) (the output preview should give a correct latitude coordinate) :
Once validated ("OK"), update all the attributes :
In the same way, create a new text field "longitude" and feed the corresponding value with the formula x(centroid($geometry))
Save the edition and close the table attributes window
Then export the new layer :
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.