I have a river network (blue line in the below image) and I need to simplify this based on a grid. I basically need to snap the river to the closest vertex or middle-of-side of the grid cell's bounds (grey dots) so the simplified river is that shown in red.

river simplification

The ultimate goal is so that I can create this type of representation of the river in data (to input to a model), that describes the network as a series of river reaches (within grid cells) that are linked by pointing to their inflow grid cells.

"GridCell_1_1": {
    "RiverReach_1_1_1": { ... }
"GridCell_1_2": {
    "RiverReach_1_2_1": { "inflow": "RiverReach_1_1_1" }
"GridCell_2_1": {
    "RiverReach_2_1_1": { ... }
"GridCell_2_2": {
    "RiverReach_2_2_1": { "inflow": "RiverReach_1_2_1" },
    "RiverReach_2_2_2": { "inflow": "RiverReach_2_1_1" }

How can I achieve this using QGIS?

  • 1
    Please decide which of QGIS, ArcGIS Desktop and GeoPandas you wish to ask about in this particular question. That way you can focus your question and we can focus our answers. You can always ask about another product in separate question.
    – PolyGeo
    Jul 28, 2018 at 13:06
  • I left it broad because I wasn't sure if this would be more easily achieved using one over another. I'll narrow it down to QGIS, as that's what I've been using most recently, but if you think it'd be easier using something else, let me know. Jul 28, 2018 at 19:27
  • Seems to me this would be easier if you worked in raster space--do you need to maintain the vector representation? Even if so, you could write a Python script to reconstruct the vectors. My first thought was to rasterize your river vectors. You can set the resolution to match your model input requirements, and you can preserve the ordering (i.e. what drains into what) assuming you have an attribute in your river lines that contains this info. I didn't write an answer because it's not clear to me that this approach would solve your problem.
    – Jon
    Jul 28, 2018 at 20:16

1 Answer 1


You could use QGIS 3.0+ / Snap geometries to layer tool.

enter image description here

Your Answer

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

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