I have an automated system in QGIS that separates loops from GPX traces and works out their centroid using 'Polygonize' >> 'Keep N biggest parts' >> 'Centroids'.
However, quite often it includes part of the 'loop approach' in the polygon:
This distorts the centroid calculation.
I think there might be a way to use a line buffer to separate the loop from the GPX trace. I don't care about preserving the GPX data but I want to avoid 'dangles'.
I can use a buffer to make a polygon around the GPX trace:
But I cannot work out how to make the area inside the 'buffer polygon' (shown in yellow) into a separate polygon that I can use to calculate the centroid.
It is essential that the process can be automated. I have hundreds of files that need to be processed.
Negative buffers don't help:
They change the buffer but don't make a polygon from the area surrounded by the buffered line.
But maybe I am missing something.
here is the GPX trace for the simple square so you can test it:
<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" creator="Open GPX Tracker for iOS">
<trk>
<trkseg>
<trkpt lat="100.000" lon="100.000">
</trkpt>
<trkpt lat="100.000" lon="200.000">
</trkpt>
<trkpt lat="200.000" lon="200.000">
</trkpt>
<trkpt lat="200.000" lon="100.000">
</trkpt>
<trkpt lat="100.000" lon="100.000">
</trkpt>
</trkseg>
</trk>
</gpx>