How can I merge osm files while retaining all node, way, and relation information?
<h2>Background</h2>
<p>I am trying to make a reduced size vector mbtiles file for the world for a compact offline maps solution I am working on for Windows desktop. To do so I have found OsmAnd's reduced size <em>World_basemap_2.obf</em> to be exactly what I need, but in the mbtiles OSM format so I can generate an mbtiles. The <em>obf</em> was created using the following OSM files generated from shape files. They are available at <a href="http://builder.osmand.net/basemap/" rel="nofollow noreferrer">http://builder.osmand.net/basemap/</a></p>
<p>The problem I have is that in order to make an mbtiles they need to be combined into one OSM file. <code>osm2vectortiles</code>' guide to generate an mbtiles found here <a href="http://osm2vectortiles.org/docs/own-vector-tiles/" rel="nofollow noreferrer">http://osm2vectortiles.org/docs/own-vector-tiles/</a>.</p>
<p>First I extract them to deal with the osm files.</p>
<h2>Problem</h2>
<p>When I use <code>osmconvert</code> to combine the files using the <code>--complete-ways</code> and <code>--complex-ways</code> flags, a lot of relations and ways are removed and the filesize is extremely different.</p>
<p>For ex:</p>
<pre class="lang-sh prettyprint-override"><code>osmconvert proc_line_tertiary_out.osm --complete-ways --complex-ways -o=tertiary.o5m
</code></pre>
<p>results in a file 133,691 kb in size</p>
<pre class="lang-sh prettyprint-override"><code>osmconvert tertiary.o5m --complete-ways --complex-ways -o=tertiary.csv
</code></pre>
<p>results in a CSV with a total of <strong>13131405</strong> nodes, ways, and relations</p>
<pre class="lang-sh prettyprint-override"><code>osmconvert tertiary.o5m proc_line_ferry_out.osm.o5m --complete-ways --complex-nodes -o=combined.o5m
</code></pre>
<p>merging <em>tertiary.o5m</em> with <em>proc_line_ferr_out.osm.o5m</em> (generated the same as shown above) and converting to CSV</p>
<p>results in a CSV with <strong>1195239</strong> total nodes, ways, and relations... which is significantly less and is very concerning. Combining two files should not make fewer nodes, ways, and relations than the original files.</p>
<h2>Question</h2>
<p>What am I doing wrong?</p>
<ul>
<li><p>Is there an alternative way to combine osm files? (I've read that <code>osmosis</code> can't deal with negative nodes.)</p>
</li>
<li><p>Is there an alternative way to generate an mbtiles, possibly from multiple osm files?</p>
</li>
</ul>
<h2>Files trying to combine</h2>
<ul>
<li>points.osm.bz2</li>
<li>polygon_aeroway_military_tourism.osm.bz2</li>
<li>polygon_lake_water.osm.bz2</li>
<li>polygon_natural_landuse.osm.bz2</li>
<li>proc_line_admin_level_out.osm.bz2</li>
<li>proc_line_ferry_out.osm.bz2</li>
<li>proc_line_motorway_out.osm.bz2</li>
<li>proc_line_primary_out.osm.bz2</li>
<li>proc_line_railway_out.osm.bz2</li>
<li>proc_line_secondary_out.osm.bz2</li>
<li>proc_line_tertiary_out.osm.bz2</li>
<li>proc_line_trunk_out.osm.bz2</li>
<li>cities.osm.bz2</li>
<li>coastline.osm.bz2</li>
</ul>
<h2><code>OSMConvert</code></h2>
<p><code>osmconvert</code> explains that</p>
<blockquote>
<h3>Merging two or more Geographical Areas</h3>
<p>Under certain conditions, OSM data files can be merged. If they hold objects (nodes, ways, relations) with the same <code>id</code>, they must have the same content. For example: If a way crosses the geographical border between two regional files, the way dataset must contain every node reference, even the references to nodes which do not lie within the borders of the regarding file. I.e., such a region must not have been cut out using the option <code>--drop-brokenrefs</code>.</p>
</blockquote>
<p>Does that mean I can't do what I am trying to do? I want to keep all nodes, ways, and relations, even if the files don't have them in common.</p>
<h2>Attempt</h2>
<pre class="lang-sh prettyprint-override"><code>osmconvert polygon_aeroway_military_tourism.osm polygon_natural_landuse.osm -o=result.osm
</code></pre>
<h2>Result</h2>
<pre class="lang-xml prettyprint-override"><code>    &lt;?xml version='1.0' encoding='UTF-8'?&gt;
    &lt;osm version=&quot;0.6&quot; generator=&quot;osmconvert 0.7T&quot;&gt;
        &lt;node id=&quot;-10000000000001&quot; lat=&quot;-1.0015443&quot; lon=&quot;-80.5349586&quot;/&gt;
        &lt;way id=&quot;-100000001&quot; version=&quot;1&quot;&gt;
            &lt;nd ref=&quot;-10000000000001&quot;/&gt;
            &lt;nd ref=&quot;-10000000000002&quot;/&gt;
            &lt;nd ref=&quot;-10000000000003&quot;/&gt;
            &lt;nd ref=&quot;-10000000000004&quot;/&gt;
            &lt;nd ref=&quot;-10000000000005&quot;/&gt;
            &lt;nd ref=&quot;-10000000000006&quot;/&gt;
            &lt;nd ref=&quot;-10000000000007&quot;/&gt;
            &lt;nd ref=&quot;-10000000000008&quot;/&gt;
            &lt;nd ref=&quot;-10000000000009&quot;/&gt;
            &lt;nd ref=&quot;-10000000000010&quot;/&gt;
            &lt;nd ref=&quot;-10000000000011&quot;/&gt;
            &lt;nd ref=&quot;-10000000000012&quot;/&gt;
            &lt;nd ref=&quot;-10000000000013&quot;/&gt;
            &lt;nd ref=&quot;-10000000000014&quot;/&gt;
            &lt;nd ref=&quot;-10000000000015&quot;/&gt;
            &lt;nd ref=&quot;-10000000000016&quot;/&gt;
            &lt;nd ref=&quot;-10000000000017&quot;/&gt;
            &lt;nd ref=&quot;-10000000000018&quot;/&gt;
            &lt;nd ref=&quot;-10000000000019&quot;/&gt;
            &lt;nd ref=&quot;-10000000000020&quot;/&gt;
            &lt;nd ref=&quot;-10000000000021&quot;/&gt;
            &lt;nd ref=&quot;-10000000000022&quot;/&gt;
            &lt;nd ref=&quot;-10000000000023&quot;/&gt;
            &lt;nd ref=&quot;-10000000000024&quot;/&gt;
            &lt;nd ref=&quot;-10000000000025&quot;/&gt;
            &lt;nd ref=&quot;-10000000000026&quot;/&gt;
            &lt;nd ref=&quot;-10000000000027&quot;/&gt;
            &lt;nd ref=&quot;-10000000000028&quot;/&gt;
            &lt;nd ref=&quot;-10000000000029&quot;/&gt;
            &lt;nd ref=&quot;-10000000000030&quot;/&gt;
            &lt;nd ref=&quot;-10000000000031&quot;/&gt;
            &lt;nd ref=&quot;-10000000000032&quot;/&gt;
            &lt;nd ref=&quot;-10000000000033&quot;/&gt;
            &lt;nd ref=&quot;-10000000000034&quot;/&gt;
            &lt;nd ref=&quot;-10000000000035&quot;/&gt;
            &lt;nd ref=&quot;-10000000000036&quot;/&gt;
            &lt;nd ref=&quot;-10000000000037&quot;/&gt;
            &lt;nd ref=&quot;-10000000000038&quot;/&gt;
            &lt;nd ref=&quot;-10000000000039&quot;/&gt;
            &lt;nd ref=&quot;-10000000000040&quot;/&gt;
            &lt;nd ref=&quot;-10000000000041&quot;/&gt;
            &lt;nd ref=&quot;-10000000000042&quot;/&gt;
            &lt;nd ref=&quot;-10000000000043&quot;/&gt;
            &lt;nd ref=&quot;-10000000000044&quot;/&gt;
            &lt;nd ref=&quot;-10000000000045&quot;/&gt;
            &lt;nd ref=&quot;-10000000000046&quot;/&gt;
            &lt;nd ref=&quot;-10000000000047&quot;/&gt;
            &lt;nd ref=&quot;-10000000000048&quot;/&gt;
            &lt;nd ref=&quot;-10000000000049&quot;/&gt;
            &lt;nd ref=&quot;-10000000000050&quot;/&gt;
            &lt;nd ref=&quot;-10000000000051&quot;/&gt;
            &lt;nd ref=&quot;-10000000000001&quot;/&gt;
        &lt;/way&gt;
    &lt;/osm&gt;
</code></pre>