Using gdal library
install gdal
pip install gdal
Then, in your code
from osgeo import ogr
gml = """
<gml:Point xmlns:gml="http://www.opengis.net/gml">
<gml:coordinates>108420.33,753808.59</gml:coordinates>
</gml:Point>
"""
point = ogr.CreateGeometryFromGML(gml)
Using GeoDjango
Geodjango is part of django, you’ll just have to declare it in your INSTALL_APPS
INSTALLED_APPS = [
…
"django.contrib.gis",
…
]
Then, in the code
from django.contrib.gis.geos import GEOSGeometry
gml = """
<gml:Point xmlns:gml="http://www.opengis.net/gml">
<gml:coordinates>108420.33,753808.59</gml:coordinates>
</gml:Point>
"""
geometry = GEOSGeometry.from_gml(gml)
This geometry
object can be set to a GeometryField
Conclusion
I spent a lot of time to search the solution but finally, it was pretty simple in the execution