2

I've been trying to carry out line simplification on polygons belonging to maps with the help of this CGAL guide, e.g. South Korea.

This is a screenshot of South Korea after line simplification with CGAL.

I carried out the line simplification by adding each polygon to CGAL::Constrained_triangulation_plus_2<CDT> ct and then running CGAL::Polyline_simplification_2::simplify(ct, Cost(), Stop(0.5));.

The outer boundaries will get simplified but the inner/shared boundaries (between provinces) will not. Is there any way to get the inner/shared boundaries simplified too?

I've also attempted to simplify each polygon individually and then combining them back together to form the whole country. The issue, however, is that each polygon would get simplified on its own, and so if Polygon1 gets simplified, there's no guarantee that the shared vertices of the adjacent Polygon2 will relocate to the same coordinates as Polygon1's vertices, and so intersections occur when you put them back together, as will happen with this South Korea map.

Thank you.

fillmoon
  • 85
  • 1
  • 4
  • I think you are getting into complications because you've chosen a wrong set of tools to represent geographical information. Did you look at GGAL `2D Arrangements`? You could use them more naturally to represent a plane graph with curved edges... The manual is here: https://doc.cgal.org/latest/Arrangement_on_surface_2/index.html – HEKTO Dec 04 '20 at 15:45
  • 1
    Hi HEKTO. Thank you for your reply/suggestion and apologies for the late reply. Taking 2D Arrangements into consideration, is there a way to convert Polygon_2 objects into 2D Arrangement objects and vice versa? Also, is there a way to simplify 2D Arrangements as a whole as there doesn't seem to exist a `simplify()` function for 2D Arrangements? Thank you again for your help. – fillmoon Dec 18 '20 at 17:35
  • The map you are working with consists of a number of polylines, connected in endpoints - you can store all this as an arrangement. Polylines can be simplified by themselves, not as parts of polygons. Polylines and polygons can be extracted from the arrangement using various iterators – HEKTO Dec 19 '20 at 04:52

1 Answers1

1

As you write "shared boundaries" I guess they are there twice, once seen from each province. You have to split the province-polygons where three provinces meet, and then only take one of the two shared boundaries.

Andreas Fabri
  • 1,144
  • 6
  • 9
  • 1
    Hi @Andreas, thank you for your response. I believe I understand your suggestion and would be willing to do it this way. However, hope I can clarify, does this then mean that CGAL does not offer any "native" way of carrying out line simplification for shared boundaries more conveniently? If it doesn't, would you know of any C++ packages that would allow for this convenient simplification of shared boundaries? Because I'm parsing GeoJSON fiels, I was also thinking of converting these GeoJSONs to TopoJSONs since I believe TopoJSON was made for topology-preserving transformation. – fillmoon Nov 13 '20 at 08:27
  • Note that you can achieve what Andreas recommends by using the function [split_graph_into_polylines()](https://doc.cgal.org/latest/BGL/group__PkgBGLRef.html#ga99ea6bf193f1194db5e523e713c82fb9) on a boost [`adjacency_list`](https://www.boost.org/doc/libs/1_74_0/libs/graph/doc/adjacency_list.html) initially filled with all the input segments. – sloriot Nov 18 '20 at 11:12
  • Sorry for the delay but I didn't get a notification yet. I added a small [example](https://gist.github.com/afabri/87619dd7e32ae33494e375804c697bfa) on gist.github.com. It is not really polished and should be inside the polyline simplification, but maybe it is useful directly. – Andreas Fabri Nov 18 '20 at 14:58
  • And I added a [feature request](https://github.com/CGAL/cgal/issues/5172) – Andreas Fabri Nov 18 '20 at 15:18
  • 1
    Hi sloriot and Andreas, thank you very much for the help. Apologies for the delay as well, I too did not receive a notification. I will try this out, thank you! – fillmoon Nov 24 '20 at 10:12
  • Hi sloriot and Andreas, I have a related question. I understand that I'll be simplifying the polylines by creating a CT object, then storing the polylines in there, then running CGAL::simplify(). After the simplification, however, how would I go about retrieving them in polygon form? Hence, ultimately, I would like to convert these simplified polylines to polygons so that I can export them as GeoJSON files. Thank you! – fillmoon Nov 27 '20 at 13:02
  • 1
    Hello fillmmon. We now also have a [pull request](https://github.com/CGAL/cgal/pull/5349) which can simplify polylines that have common subsequences. – Andreas Fabri Feb 01 '21 at 12:52