I have this code:
driver = ogr.GetDriverByName('KML')
data = driver.Open(kmlFile)
layer = data.GetLayer()
geom = nextFeature.GetGeometryRef()
print(geom.ExportToJson())
I am trying to export any kind of output like GeoJSON or WKT but;
{ "type": "MultiPolygon", "coordinates": [ [ [ [ 33.228451, 39.725639, 0.0 ], [ 33.18737, 39.653671, 0.0 ],
[ 33.234299, 39.644131, 0.0 ], [ 33.280369, 39.671131, 0.0 ]
the output is something like this and looks like the geometry that comes from KML file is in 3D projection or something, or at least the program thinks it is.
Here is the spatial reference if you need to know:
{
"$schema": "https://proj.org/schemas/v0.2/projjson.schema.json",
"type": "GeographicCRS",
"name": "WGS 84",
"datum": {
"type": "GeodeticReferenceFrame",
"name": "World Geodetic System 1984",
"ellipsoid": {
"name": "WGS 84",
"semi_major_axis": 6378137,
"inverse_flattening": 298.257223563
}
},
"coordinate_system": {
"subtype": "ellipsoidal",
"axis": [
{
"name": "Latitude",
"abbreviation": "lat",
"direction": "north",
"unit": "degree"
},
{
"name": "Longitude",
"abbreviation": "lon",
"direction": "east",
"unit": "degree"
}
]
},
"id": {
"authority": "EPSG",
"code": 4326
}
}
A Point that specifies the position of the Placemark on the Earth's surface (longitude, latitude, and optional altitude)
. That's 2.5D, not really 3D. If you want you can tell GDAL to save data as 2D and drop the Z used for height.-dim XY
or alternatively with another expression but identical meaning-dim 2
. The Python way is certainly documented somewhere.