NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

# Clip part from map with a boundary polygon and adjust intersected polygons from boundary

 0 1 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? asked 05 Oct '15, 13:22 phlegx 11●1●1●3 accept rate: 0% Please explain what you want to do with the extract once created. This will make it easier for us to suggest something. (05 Oct '15, 14:45) Frederik Ramm ♦

 0 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. answered 06 Oct '15, 14:28 sanser 695●38●39●55 accept rate: 5%

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Question tags:

×132
×129
×92
×83
×49

question asked: 05 Oct '15, 13:22

question was seen: 6,019 times

last updated: 06 Oct '15, 14:28

### Related questions

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum