<div>Dear colleagues,<br></div><div><br></div><div data-value="0">I have just started to use Python and I would like to make a query to
Overpass and store the results in a geospatial format (e.g. GeoJSON) so I can programatically update the data.<br></div><div><p>As far as I know, there is a library called <code>overpy</code> that should be what I am looking for. After reading <a href="https://python-overpy.readthedocs.io/en/latest/example.html" rel="noreferrer nofollow noopener" target="_blank">its documentation</a> I came up with the following code:<br></p><pre style><code><span>
</span><span>import</span><span> overpy
API </span><span>=</span><span> overpy</span><span>.</span><span>Overpass</span><span>()</span><span>
</span><span># Fetch highways within Granollers' city.</span><span>
result </span><span>=</span><span> API</span><span>.</span><span>query</span><span>(</span><span>"""
area[name="Granollers"][admin_level=8];
// query part for: “highway=*”
(way["highway"](area);
relation["highway"](area);
);
// print results
out body;
"""</span><span>)</span><span>
</span></code><br></pre><p>The thing is that I am not familiar at all with Python and I don't know how to store <code>result</code> as a GeoJSON file (Honestly, I don't even know what kind of thing <code>result</code> is -I tried with <code>type(result)</code> and I get <code>overpy.Result</code> as an output, which doesn't mean much to my poor knowledge). I have been reading <code>overpy</code> documentation but I haven't been able to figure it out.<br></p></div><div><div>Can anyone give me a clue with this?<br></div><div><br></div></div><div><br></div><div><br></div><div class="protonmail_signature_block"><div class="protonmail_signature_block-user"><div>Carlos Cámara-Menoyo<br></div><div><a href="https://carloscamara.es" title="https://carloscamara.es">https://carloscamara.es</a><br></div></div><div class="protonmail_signature_block-proton protonmail_signature_block-empty"><br></div></div><div><br></div>