Clip part from map with a boundary polygon and adjust intersected polygons from boundary – OSM Help

  1. Home
  2. map design tutorials
  3. Clip part from map with a boundary polygon and adjust intersected polygons from boundary – OSM Help

I want to extract (clip) a part of the map with a predefined boundary polygon. I have seen that I can do it with osmosis or osmconvert. But I get the problem, that polygons that intersects the predefined boundary polygon are no more polygons but only lines (because the polygon gets cropped). How can I automatically adjust intersected polygons to the boundary polygon? Please explain what you want to do with the extract once created. This will make it easier for us to suggest something. From your question I understand that you are aiming at clipping the map objects to/by an arbitrary polygon (CP, the Clipping Polygon). Especially, clipping areas defined by Multi-polygon relations. The subject is pretty complex and I don’t think you will find open/public code doing that. At the same time area clipping is one of the essential functions of any modern vector map-making so, many of us (must) have it. Here are some hints to one possible solution. 1. Pre-processing. Eliminate any replications (nodes, vectors…) and convert area objects into simple/primitive disjunctive objects (one outer and arbitrary inner border polygons). Strictly, this step is not necessary but soon or later these events may cause algorithm exceptions. 2. Detect and handle trivial cases (the area is guaranteed outside/inside the CP, the CP is inside a hole, the CP is covered by the area and so on). In these cases polygons don’t need to be really clipped. 3. For any area border polygon P, that should be clipped, detect the inside-out and the consecutive outside-in crossings with the CP (note that if one of these crossings exist the other one must exist too). Replace the outside P segment between these crossing points with the corresponding CP segment providing the same orientation. 4. Now, you have all polygons inside the CP (strictly inside or eventually with partly overlapping borders exactly on the CP). Make the area restructuring (detect the outer and the corresponding inner polygons). 5. Finally, if you really want a precise area clipping, remove the overlapping outer-inner polygon segments and reconnect the 2 complementary outer/inner segment. Note that while this is working fine, in practice we usually use another model. We detect all vector tails that are not outside the CP (e.g. country border, district border). This tile coverage provides a bit more than the first (more or less academic) option. Note also that there are many fine details missing in the hints. Most of them you may find in Polygon Algebra and Topology student books. Source.

whatsapp button