Centroid refers to the centre point of an object, a polygon, a city. The coordinate of centroid could be useful for mapping the scatter point by using scatter-mapbox.

This post will focus on how to extract its coordinates by using QGIS.

Table of Contents

  1. Step 1. You need to download QGIS
  2. Step 2. Open any map shapefile
  3. Step 3. Open attribute table
  4. Step 4. Calculate the centroid
  5. Step 5. Export the data

Step 1. You need to download QGIS

Step 2. Open any map shapefile

Step 3. Open attribute table

Step 4. Calculate the centroid

open the field calculator, fill in the equation as the pictures show

The final two columns are the new variables representing the longitude (X_centroid) and latitude (y_centroid) of controid

Step 5. Export the data

Export the attribute table by clicking as follows.

Selected the fields or variables you want to export to CSV.

As the result, you get the file in the selected folder! 🥳