[QGIS-ZA-user] Polygon Centroids Extraction - New User

Frank Sokolic sokolic at worldonline.co.za
Thu Mar 4 00:32:16 PST 2021


Hi Herbert,

The attribute table of the Centroids file should have the cluster number 
as one of the attributes (let me know if it doesn't). You can then do 
the following:

1) Add the X/Y coordinates to the Centroids attribute table (from the 
menu bar select Vector > Geometry Tools > Add Geometry Attributes).
2) In the Layers panel, right-click on the name of the new layer 
produced in step 1 (it will be something like "Added geom info") and 
select "Export > Save features as". Set the format to "Comma separated 
value" and save the file.

That should do it.

Regards, Frank

On 2021/03/04 08:54, Herbert Chitate wrote:
> Hi Frank,
>
> You are an absolute life saver. Almost there. So I managed to generate 
> the centroids. Thoroughly impressed for a new user!!!
>
> I have attached a screen shot of the results.
>
> Final question though is how do I extract the lat and lon of the 
> centroids, into say a csv file with also a column with the cluster 
> number they belong to (cluster number is what i used to demacate the 
> different polygons in step 2 of your instructions)
>
> Many many many thanks
>
> Much appreciated
>
> Regards
>
> Herbert
>
> On Mon, Mar 1, 2021 at 2:25 PM Frank Sokolic via qgis-za-user 
> <qgis-za-user at lists.osgeo.org <mailto:qgis-za-user at lists.osgeo.org>> 
> wrote:
>
>     Hi Herbert,
>
>     I haven't tested it but you could try something like this:
>
>     1) Load the csv file into QGIS using the "Add Delimited Text
>     Layer" tool (Shift + Ctrl + T)
>     2) Use the "Minimum bounding geometry" tool to create a polygon
>     around each cluster (Processing Toolbox > Vector geometry >
>     Minimum bounding geometry)
>     3) Generate centroids for each polygon (Processing Toolbox >
>     Vector geometry > Centroids)
>
>     Hope this helps.
>
>     Regards, Frank.
>
>     On 2021/03/01 13:04, Herbert Chitate via qgis-za-user wrote:
>>     Good afternoon All,
>>
>>     I am new to QGIS and was wondering if someone might be able to
>>     assist me on an extraction I am trying to do.
>>
>>     I have lat and lon details for about 1,500 locations, which using
>>     python (kmeans), I have clustered the data into 20 clusters of
>>     which I have the details of the constituent members (+ gps
>>     locations) that make up the 20 clusters. Info now in a CSV file.
>>
>>     How can I use QGIS to establish the lat and lon of the centroids
>>     for each of the clusters?
>>
>>     Thank you for the assistance.
>>
>>     Regards
>>
>>     Herbert
>>
>>     _______________________________________________
>>     qgis-za-user mailing list
>>     qgis-za-user at lists.osgeo.org  <mailto:qgis-za-user at lists.osgeo.org>
>>     https://lists.osgeo.org/mailman/listinfo/qgis-za-user  <https://lists.osgeo.org/mailman/listinfo/qgis-za-user>
>
>
>     _______________________________________________
>     qgis-za-user mailing list
>     qgis-za-user at lists.osgeo.org <mailto:qgis-za-user at lists.osgeo.org>
>     https://lists.osgeo.org/mailman/listinfo/qgis-za-user
>     <https://lists.osgeo.org/mailman/listinfo/qgis-za-user>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-za-user/attachments/20210304/8a0e868a/attachment.html>


More information about the qgis-za-user mailing list