[Qgis-user] visualize and export coordinates of centroids

Thayer Young thayeray at yahoo.com
Tue May 24 07:53:38 PDT 2022


 Hi Francesca,
Assuming that your layer has a geographic coordinate system like 4326. And you have found your centroids already:
Use the field calculator to add a new or virtual field with a numeric data type, e.g. double, and name it something like "lat". Then in the expression area enter the expression: $y      
and press OK. Do the same for "lon" and the expression will be: $x     

If you want to find the centroid of a polygon and its latitude in one step your expression would be: y(centroid($geometry))     
For longitude it would be: x(centroid($geometry))         

Note that different methods will give you different coordinates for your centroid. So you may need to use a spatial join to do your match. 

-Thayer

    On Tuesday, May 24, 2022, 06:22:46 AM EDT, qgis-user-request at lists.osgeo.org <qgis-user-request at lists.osgeo.org> wrote: 
----------------------------------------------------------------------
Date: Tue, 24 May 2022 09:52:26 +0200
From: Francesca Parente <francescaparente.rse at gmail.com>
To: QGIS User List <qgis-user at lists.osgeo.org>
Subject: [Qgis-user] visualize and export coordinates of centroids
Message-ID:
    <CAA8dZSc04zGiUy5JZhEARj0+ddP1L8z_abcSdXpRS5CYi6oieg at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hello group,

I would like to ask you what is in your opinion the best way to identify
the lat-lon attributes of derived centroids in order to export them to an
extra-QGis database where corresponding coordinates should match with
identified locations.

So far I've tried with Geocoding and MMQGIS plugins, but the resulting
attributes table doesn't inlcude the coordinates of geocoded points.

Thanks a lot for any advice!
Francesca

-- 
----------------------------
Francesca Parente

  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20220524/4b32af76/attachment.htm>


More information about the Qgis-user mailing list