Geographic Information Systems Asked on June 27, 2021
I have shapes with attribute BLUE. I have shapes with attribute ORANGE.
The attribute table has two entries – BLUE, ORANGE – even though there are more isolated shapes ( islands in fact).
I wish to find the centroid of the dominant (largest by area) shape BLUE and the centroid of the dominant shape ORANGE. Red DOTS in image.
I suspect there must be a way to ignore the non-dominant island shapes and then find centroid of dominate shape.
The purpose is that I want to determine LAT-LONG of the centre of shape in order to place Capital name there.
It sounds like you have multipart polygons.
multipart to singlepart
to split the parts into separate features.centroids
tool, with the "selected features only" option, to find the centroid of the selected polygons.Update: based on the new information that you have hundreds of multipolygons, rather than only two as originally stated, manually selecting the large polygons in step 2 will be impractical. Instead, use select by expression
to select the larger polygons with an expression like $area > area_value
. Substitute an appropriate area value for the area_value
placeholder term.
Answered by csk on June 27, 2021
It looks like you have multi-part geometries so each record in the data table can refer to one or more shapes. Use the multi-part to single part tools to convert those data so single part features.
Next, use menu -> Vector -> Geometry tools -> polygon centroid to create the polygon centroid.
You may find that some of your islands have geometries such that the point created is not bound within the island polygon. If that is the case then consider this link to a plugin to ensure the point is within the polygon.
Of course, these tools will create points for all the islands. You can either select your dominate shapes before running these tools so that only points are created for the highlighted shapes or you could use the selection tools to find the point in the largest island by name (but that answer should be another post).
Answered by GBG on June 27, 2021
There is an easier way, without any geoprocessing, just using the expression editor:
centroid(coalesce( order_parts( $geometry, area($geometry), False)))
with order_parts
, you order the parts of every (multipart-)geometry ($geometry
) according to their area-values (area($geometry)
) and sort it descending (paramenter: False
). With coalesce
, you select the first, thus (after ordering them before) the biggest part of every multi-geometry. You now generate the centroids of this "biggest island" with centroid()
.
Paste this expression in the labeling dialogue in the positioning tab, select around center or distance from center and set data-driven override for centroid: here you past the expression above. The red dots in the screenshot are generated just for demonstration with an additional geometry-generated points-geoemtry in the styling dialogue, using exatly the same expression.
Answered by Babel on June 27, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP