[QGIS-Developer] Convert geojson geometry to QgsGeometry in python

Bo Victor Thomsen bo.victor.thomsen at gmail.com
Mon Jan 4 09:14:16 PST 2021


Hi list members:

The subject says it : How to convert the geometry part from a geojson 
string to a QgsGeometry

Some details:

How can I convert the geojson "geometry" part to a QgsGeometry ? i.e. 
The part marked in *bold* ?

|{"type":"Feature",*"geometry"**:****{****"type"**:****"Point"**,****"coordinates"**:****[**125.6**,****10.1**]****}*,"properties":{"name":"Dinagat 
Islands"}} |||

It's not the only "point" type, but all the geometry types (minus 
"geometry collection"): linestring, polygon, multipoint, multilinestring 
and multipolygon.

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.

-- 
Med venlig hilsen / Kind regards

Bo Victor Thomsen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210104/0fd19a35/attachment-0001.html>


More information about the QGIS-Developer mailing list