6

I have a data source with thousands of lakes, ponds and small puddles.

Using an algorithm of anitagraser.com I have managed to clean the ponds and small puddles, but with the big lakes I have a problem. They are formed by many lines, and none runs completely by its edges, are only pieces.

I put an image where you can see only one of this lakes in full:

Full Lake

And another image where you can see (in different colors) some of the lines that form it (they are not all, only a few, too much work mark each line in a different color, but you can have an idea)

Full lake but some lines mark in different colors

I've tried playing with 'dissolve' and with v.clean.snap, but I can not make much progress.

Do you have any idea how I can manage to make all this tangle of lines 1 only polygon? It must be a process that can be automated, nothing manual, since there are thousands of lakes like this one into the source. I am able to make complicated scripts, but I am an inexperienced one in GIS (using QGIS and PyQGIS). (Added after Evan comment -> The details are not important, it is more important to close the polygons, I would sacrifice the details if you can close the polygon and create a single figure)

Yes, we have something on our side, all the lines that form a large lake have the same label in the attribute table.

You can download this shape here: big_lake.zip

Note: My project (map) will be a open project, and all data will be save into OSM if possible.

2 Answers 2

4

I know what you want, but you can't do it as far as I know. You've got massive holes that need QAing. There is no easy way to solve this problem. You can

  1. Remove all detail but ensure that you capture all the points and polygons with convexhull
  2. Snap the points to a grid.
  3. Use some other form of simplification and error correction.

I don't know of anything that can fix such poor data. The problem isn't joining several inner and outer lines. The problem is connecting lines with massive breaks.

holes in the dataset

Just to show you snapping to grid looks like, I used postgis and I had to increase grid size to 0.001

Closing holes with st_snaptogrid

That will reduce your polygon's detail to something like this,

Simplified polygon

Someone may have a better solution, but this is a huge problem space when you start to introduce massive holes in the lines like you've got.

Created with st_snaptogrid(st_union(geom),0.001) AS geom from public.biglake;

2
  • Thank you very much, Evan. It has been a good explanation of my problem, I am a newbie in GIS and therefore I struggle to elucidate what I am looking for. So a possible solution would be to decrease the detail of the figures to facilitate their union. It is feasible, I do not need that the final figures have great detail, on the contrary, the simpler, the better. I will concentrate on narrowing the detail and trying to join the gaps. Dec 1, 2016 at 8:21
  • @JuanmaFont mark this answer as chosen if you're satisfied. Also worth nothing that this isn't sacrificing enough detail to accomplish your task. You can see on the far right hand side there is still unconnected red. My idea was to snap to grid the lines, union, and then polygonize them but you don't have a closed area. These are really poorly defined. Dec 1, 2016 at 8:30
0

An advance, but still is not complete 100%, only 99%:

I found concaveHull, that works over points. son I convert Lines to point (MMQGIS-> Modify -> convert geometry to -> Nodes)

and then use concaveHull (from Processing Toolbox -> Concave Hull), and get this:

enter image description here

So I have a full edges figure, I have only to fill the interior holes. But how? Answer -> How to fill holes in polygons automatically? So using toolbox tool "Delete Holes" I got it:

enter image description here

I have only to clean interior little polygons.

I have lost many details along the way but I have a single polygon.

I have tried "toolbox -> vclean -> snap -> 0.001" and get this into " ERROR LAYER " ->

enter image description here

The full polygon and without interior polygons, but I'm not sure if is it the best way.

1
  • How are you excluding the island on the left? Jan 4, 2017 at 5:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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