in geodjango i found that i can use WKT to insert geometry such as:
pnt = GEOSGeometry('POINT(5 23)')
but it doesn't show how to do it if the data is KML, as my data is in kml format, so my plan is to convert KML -> WKT -> GEOSGeometry.
Is there a way to convert kml to wkt using geodjango or using any python library?
Best Answer
Here is a working solution, that assumes you have your KML data in a string. If its in a file, you can skip the first step where a temp file is created. The KML driver from ogr only reads from file as far as I know.
Tthere might be some more elegant ways of converting the ogr feature to a GEOSGeometry (without converting it to json and back). But this is the first solution that I could come up with.
Then you get