Skip to content

Update linestopolygons algorithm description #9784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

phidrho
Copy link
Contributor

@phidrho phidrho commented Apr 11, 2025

Goal:
Create a better documentation for native LinesToPolygons processing algorthm.

Please review and suggest additional edits if needed.

After we finish final version, I will prepare similar one for native Polygonize algorithm.

Ticket(s): #

  • Backport to LTR documentation is requested

@phidrho
Copy link
Contributor Author

phidrho commented Apr 11, 2025

I didn't attach visualization (print screen) because it's a pretty long one in render.
But I can deliver it if that will be needed.

Copy link
Collaborator

@DelazJ DelazJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @phidrho
Really nice stuff. It will certainly help a lot of users.

- OUTPUT
- NOTE

* - **Feature a**: Single line LineString
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* - **Feature a**: Single line LineString
* - **Feature a**: Single segment LineString

Comment on lines +3865 to +3868
Lines to polygons on linestrings
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Features with 3 or more vertices are expected on input: **start point - vertex/vertices - end point**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first example contradicts this statement. And as I suggest later, I'd just merge concept of single and multiline segments together

Suggested change
Lines to polygons on linestrings
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Features with 3 or more vertices are expected on input: **start point - vertex/vertices - end point**

Comment on lines +3852 to +3853
Generates a polygon layer from line layer, considering LineString geometry with three
or more vertices as polygon rings. Input LineString geometry doesn't need to close a loop,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking.. Not really true because when you use a line with two vertices, you also get a polygon layer. Empty polygon geometry, as stated later, still a polygon layer.

Suggested change
Generates a polygon layer from line layer, considering LineString geometry with three
or more vertices as polygon rings. Input LineString geometry doesn't need to close a loop,
Generates a polygon layer using as polygon rings the individual line features from an input line layer.
Input LineString geometry doesn't need to close a loop,

algorithm will automatically connect last to first point when forming a polygon.
Result is always promoted to MultiPolygon.
LineString geometry that have less than three vertices will produce
new polygon features with **EMPTY** MultiPolygon geometry, attributes are kept.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new polygon features with **EMPTY** MultiPolygon geometry, attributes are kept.
new polygon features with **EMPTY** geometry.

Comment on lines 3859 to 3860
The attribute table of the output layer is the same as the one of
the input layer.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The attribute table of the output layer is the same as the one of
the input layer.
Attributes of the input line feature are ALWAYS kept in the output polygon geometry.

And then I wonder if we need to repeat it for every example below


.. list-table::
:header-rows: 1
:widths: 30 30 40
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:widths: 30 30 40
:widths: 30 30 40
:class: longtable

This allows in the PDF build to have long tables split across pages

|
| **Output has a valid (empty) geometry.**

* - **Feature b**: LineString with three vertices
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the number of vertice/segments matters? It is more the situation of a not closed linestring with more than one segment, no?

This can be fixed by using :ref:`qgisfixgeometries` algorithm with two possible scenarios:

1. *Fixing by structure repair method* - two parts will dissolve into MultiPolygon geometry with one part
2. *Fixing by linework repair method* - equal to symmetrical difference of two parts which results MultiPolygon geometry with one part (doughnut shape in this case)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. *Fixing by linework repair method* - equal to symmetrical difference of two parts which results MultiPolygon geometry with one part (doughnut shape in this case)
2. *Fixing by linework repair method* - equal to symmetrical difference of two parts which results in MultiPolygon geometry with one part (doughnut shape in this case)

?

:width: 25 em
:align: center

Two distinct LineStrings, one geometrically contained inside another
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(here and below) Are LineString and MultiPolygon (written with that casing) pluralizable? How about

Suggested change
Two distinct LineStrings, one geometrically contained inside another
Two distinct line features, one geometrically contained inside another

Comment on lines +3976 to +3977
- | **Feature e**: MultiPolygon
| **Feature f**: MultiPolygon
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this render in HTML?

@DelazJ DelazJ added Processing Alg (Features of) An algorithm. Use the Help button in the application to find the page. backport release_3.40 On merge create a backported pull request to 3.40 labels Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release_3.40 On merge create a backported pull request to 3.40 Processing Alg (Features of) An algorithm. Use the Help button in the application to find the page.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants