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's gravatar image

phlegx
11113
accept rate: 0%

edited 05 Oct '15, 13:22

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 ♦

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.

permanent link

answered 06 Oct '15, 14:28

sanser's gravatar image

sanser
665333452
accept rate: 5%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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:

×106
×98
×69
×69
×43

question asked: 05 Oct '15, 13:22

question was seen: 2,854 times

last updated: 06 Oct '15, 14:28

powered by OSQA