<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi list members:<br>
</p>
<p>The subject says it : How to convert the geometry part from a
geojson string to a QgsGeometry<br>
</p>
<p>Some details: <br>
</p>
<p>How can I convert the geojson "geometry" part to a QgsGeometry ?
i.e. The part marked in <b>bold</b> ?</p>
<figure class="highlight">
<pre><code class="language-json" data-lang="json"><span class="p">{</span><span class="w">
</span><span class="s2">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Feature"</span><span class="p">,</span><span class="w">
</span><b><span class="s2">"geometry"</span></b><b><span class="p">:</span></b><b><span class="w"> </span></b><b><span class="p">{</span></b><b><span class="w">
</span></b><b><span class="s2">"type"</span></b><b><span class="p">:</span></b><b><span class="w"> </span></b><b><span class="s2">"Point"</span></b><b><span class="p">,</span></b><b><span class="w">
</span></b><b><span class="s2">"coordinates"</span></b><b><span class="p">:</span></b><b><span class="w"> </span></b><b><span class="p">[</span></b><b><span class="mf">125.6</span></b><b><span class="p">,</span></b><b><span class="w"> </span></b><b><span class="mf">10.1</span></b><b><span class="p">]</span></b><b><span class="w">
</span></b><span class="p"><b>}</b>,</span><span class="w">
</span><span class="s2">"properties"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="s2">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Dinagat Islands"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">}
</span></code><code class="language-json" data-lang="json"><span class="p"></span></code></pre>
</figure>
<p>It's not the only "point" type, but all the geometry types (minus
"geometry collection"): linestring, polygon, multipoint,
multilinestring and multipolygon.<br>
</p>
<p>The json text is already converted to a python dict using
json.dumps(). AFAIK, it's trivial to convert from QgsGeometry to
geojson, but I can't find an existing method to do the opposite.</p>
<pre class="moz-signature" cols="72">--
Med venlig hilsen / Kind regards
Bo Victor Thomsen</pre>
</body>
</html>