2

I am using this dataset of rivers in France. I'd like to automatically distinguish between rivers flowing directly into the sea versus rivers that flow into another river and draw a map of only those rivers. How can I do this?

Each river in this dataset has a standard SANDRE code and can be looked up online (example), but they don't seem to record the information I need. I don't mind having to write code to do this, but I would like something reliable (i.e. no "guesswork"). For example, is there a way of knowing whether an endpoint of a river is on another river? If so, I could look for rivers in which neither endpoint is on a river. However, from what I can tell shapefiles don't store whether a vertex is "on" another line.

I'm open to any kind of approach. I'd like to use this dataset though since I think it's probably the most exhaustive (it's a French government dataset).

2
  • 3
    Are you familiar with any GIS tool - QGIS or ArcGIS?
    – Nil
    Jan 2, 2021 at 17:21
  • 1
    @Nil "Familiar" is a strong word, I discovered QGIS yesterday, but I've been using it to visualize the data.
    – Jack M
    Jan 2, 2021 at 17:27

1 Answer 1

5

You can make an overlay (intersects/touches) of your river lines with a polygon representing the sea.

Before you can do this, you need a polygon layer representing the sea. Best use data for the sea that is created by the same institution that you have your rivers from so that you can be sure that datasets match. This is important not to have topological errors like rivers that do not reach the sea because they are a too short and do not touch the coastline (even if just for a fraction of a millimeter).

One such case is the river Le Var that reaches the Mediterranean between the airport of Nice and Saint-Laurent-du-Var. But as you can see on the next screenshot, combining your river dataset with OpenStreetMap polygons for the Mediterranean, there is a small gap of ca. 30 meters (see red rectangle) between the end point of the river (dark blue line) and the coastline (black line):

enter image description here

As an alternative, when you use use any other polygons for the sea, than apply a small buffer to the sea polygons. I tried that with a part of the Mediterranean that borders France using the sea polygons I got from OpenStreetMap. The buffer size should be big enough to avoid the problem mentioned before and small enough not to reach riverlines in the inland that in fact do not touch the coastline. A value of 100 Meters could be a good start. In any case, check your data at random sample points to see how good it fits.

Do not forget to create a spatial index for both layers: rivers and sea/buffered sea. So create a spatial index, right click on the layer, Properties / Source tab and click Create spatial index. That helps to accelerate the processing time. Be sure that you unzip all data before loading to QGIS.

When you have your data ready (river line layer, sea polygon layer), it's time for the actual processing:

Run Menu Vector / Data Management Tools / Join attributes by location, set the rivers as Base Layer and the Sea polygons as Join layer. Check the boxes intersects and touches, than run the tool: it will output a copy layer of your rivers, but with new attributes. One is the id attribute (preceded with the prefix, if you defined one in the tool): it contains the identifier of the polygon layer it touches or intersects. Thus if you have a number there, you know that this river segment reaches the sea.

enter image description here

You can now use this output to style rivers that flow to the sea differntly than the others that do not reach the sea. In the screenshot below, I added a new symbol layer (green plus symbol), set it to Geometry generator / LineString and pasted this expression:

if (
     "imp_fid" >0,
    $geometry,
    ''
)

imp_fid is the field created by the tool that contains the feature id of the sea polygon that the line touches or intersect: if it is empty, the river does not have access to the see, if it is not empty, thus >0, QGIS should draw the river ($geometry), otherwise the output should be empty: ''.

It set this symbol layer to a thicker, dark blue line. The other symbol layer has a standard, thin black line: so you see that the blue lines are those rivers that reach the sea:

enter image description here

However, in your data you still have some strange cases that are difficult to assess in an automatical process. An example are the two small lines a few km north west of La Ciotat, nearby coordinates 5.564645,43.193170 (EPSG:4326). You should critically reflect what the data you have represents and what should be considered "a river" - you might want to apply a minimal length criteria for a line to be considered being "a river".

enter image description here

2
  • When I click "Create spatial index", I get the message "Creation of spatial index failed". Is there some other step that needs to be done first? I'm importing the data by just dragging the zip file into the project, if that's relevant.
    – Jack M
    Jan 2, 2021 at 18:38
  • You should first unzip the data
    – Babel
    Jan 2, 2021 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.