get_aoi_wkt(aoi_path: str | CloudPath | Path, as_str: bool = True) str | Polygon[source]#

Get AOI formatted as a WKT from files that can be read by Fiona (like shapefiles, …) or directly from a WKT file. The use of KML has been forced (use it at your own risks !).


It is assessed that:

  • only one polygon composes the AOI (as only the first one is read)

  • it should be specified in lat/lon (WGS84) if a WKT file is provided

  • aoi_path (AnyPathStrType) – Absolute or relative path to an AOI. Its format should be WKT or any format read by Fiona, like shapefiles.

  • as_str (bool) – If True, return WKT as a str, otherwise as a shapely geometry


AOI formatted as a WKT stored in lat/lon

Return type:

Union[str, Polygon]


>>> path = "path/to/vec.geojson"  # OK with ESRI Shapefile, geojson, WKT, KML...
>>> get_aoi_wkt(path)
'POLYGON Z ((46.1947755465253067 32.4973553439109324 0.0000000000000000, 45.0353174370802520 32.4976496856158974
0.0000000000000000, 45.0355748149750283 34.1139970085580018 0.0000000000000000, 46.1956059695554089
34.1144793800670882 0.0000000000000000, 46.1947755465253067 32.4973553439109324 0.0000000000000000))'