kartoza / stream_feature_extractor

A QGIS plugin to extract stream features (wells, sinks, confluences etc.) from a stream network
GNU General Public License v2.0
6 stars 9 forks source link

We need a node extractor helper method #8

Closed timlinux closed 10 years ago

timlinux commented 10 years ago

Problem

The method should when given a line layer, extract start and end nodes plus line ID as new point layer.

Proposed solution

Implement a helper method (no gui) that takes as input:

def extract_nodes(stream_layer, snapping_distance):
    """Extract the nodes from a stream layer.

    :param stream_layer: A vector line layer.
    :type stream_layer: QgsVectorLayer

    :param snapping_distance: The distance (radius) within which two nodes should be considered
        super-imposed.
    :type snapping_distance: float, int

    :returns: The layer instance of the extracted nodes layer which will be a temporary memory layer.
    :rtype: QgsVectorLayer
     """
     pass

The method should extract all start and end nodes from the passed in line layer and write them to a new point layer with the following attributes:

id line_id node_type node_list node_count
1 1 upstream 1
2 1 downstream 12, 14, 44 4

Note that the node list is exclusive of the current node (it lists other nodes that are super-imposed based on the specified snapping distance) while the node_count is inclusive of the current node (it is the count of all nodes occurring at this position within the the snapping distance).

It is expected that this attribute table will be appended to but other helper functions (see #12 , #13 , #14, #15, #16, #17).

Expected outcome

A generated layer which lists all the nodes for the input dataset and that can be used as the basis for further feature extraction.

ismailsunni commented 10 years ago

So, the new point layer will have attributes: node_id - line_id - node_type (start node or end node)?

timlinux commented 10 years ago

To start with yes. Depending on which of the functions (find wells, find sinks etc.) we run, each will add a new column to the table e.g.

id line_id node_type
1 1 upstream
2 1 downstream

Then we do count and enumeration and it becomes:

id line_id node_type node_list node_count
1 1 upstream 5, 10 , 15 4
2 1 downstream 12, 14, 44 4

etc.

ismailsunni commented 10 years ago

From you comment, and from #12's problem desription:

Given a line layer, identify by selection all wells (points with no upstream nodes)

So, it should be given a point layer not given a line layer, shouldn't it?

timlinux commented 10 years ago

@ismailsunni No think from the user perspective: I have a stream network and I want to identify well features. The line layer should always be the starting point for them and the fact that we use a point layer for processing / computation is an implementation detail.

ismailsunni commented 10 years ago

Ok I got it.

So the workflow will be something like this:

  1. User choose a line layer
  2. Click "Extract" button (so, there will be only a button for all feature extracting process, right?, Or one button for each feature extraction?)
  3. User gets all features.

So, it brings me to another question. In what form is the result? A table that contains the features? Or a point layer that contains all points that represent the features?

timlinux commented 10 years ago

User choose a line layer

Correct

Click "Extract" button (so, there will be only a button for all feature extracting process, right?, Or one button for each feature extraction?)

One button click will create a new river features point layer with one column per feature type as per the tickets listed in this issue tracker. So ultimately we end up with a point layer whose attribute looks like this:

id line_id node_type upstream_node_list downstream_node_list upstream_node_count downstream_node_count well sink confluence branch has_pseudonodes watershed
1 1 upstream 5, 10 , 15 4, 7 4 2 1 0 0 0 0 0
2 1 downstream 12, 14, 44 5, 9 3 3 0 0 0 0 0 0

User gets all features.

User sees a new layer added to view which has symbols for each feature type we have extracted. We probably need to think about removing duplicate nodes that occur in the same snapped position but we can come to that later.

So, it brings me to another question. In what form is the result? A table that contains the features? Or a point layer that contains all points that represent the features?

OK I think that is explained above - it is a point layer with an attribute table as described above.