Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge multiple polygon files #272

Closed
thewire247 opened this issue Apr 29, 2022 · 1 comment
Closed

Merge multiple polygon files #272

thewire247 opened this issue Apr 29, 2022 · 1 comment

Comments

@thewire247
Copy link

Issue #268 has been very useful thanks, I managed to get the files merged. Following on from that, how would I merge the polygon files?

@Istador
Copy link
Contributor

Istador commented Apr 29, 2022

See this for the format definition with an example of two areas in one file:
https://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format

It does say:

Several of these files may be combined to one multi-sectioned file. In this case each section must be separated from its preceding section by an empty line (combined files are used by the programs osmrelpoly and osmassignpoly).

and based on that this should be enough to do the job:

# merge first.poly and second.poly
( cat first.poly && echo "" && cat second.poly ) >merged.poly

# merge first.poly, second.poly and third.poly
( cat first.poly && echo "" && cat second.poly && echo "" && cat third.poly ) >merged.poly

If that doesn't work (e.g. if osmosis doesn't support it, which I don't know), I'd suggest combining the contents into one section:

# merge first.poly and second.poly
( head -n -1 first.poly && echo 2 && tail -n +3 second.poly ) >merged.poly

# merge first.poly, second.poly and third.poly
( head -n -1 first.poly && echo 2 && ( tail -n +3 second.poly | head -n -1 ) && echo 3 && tail -n +3 third.poly ) >merged.poly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants