I am trying to use polygon coordinates to plot polygons on GeoTIFFs of satellite images using gdal or rasterio, yet somehow I keep failing. There is two things I want to do:
- create a mask with only the polygon as data and the rest as nodata, and
- overlay the mask on the image to see how accurate the polygons are.
I simply do not know how to create a mask and overlay it in gdal in python when starting from WKT or GeoJSON strings.
I have the GeoTIFF loaded (and can plot it), and have the polygon coordinates in wkt and geojson format (and also as a geometry object). I can also transform the coordinates to and from desired projections. But I simply have no idea how I can overlay them on an image in GDAL or Rasterio to check the accuracy of the polygon (or better yet: create a separate mask which I can plot on top of the image).
Here is an example of a polygon I have in wkt in EPSG 4326:
'POLYGON ((5.5937209 52.24012314 0,5.5936411 52.24048512 0,5.59413417 52.2415213 0,5.59434149 52.24151408 0,5.59463832 52.24015416 0,5.5937209 52.24012314 0))'
I've seen some potential answers using .shp files, but haven't managed to recreate them from my starting point. It is not impossible that the answer is already somewhere on the forums, but I've been reading and searching for a long time and can't find the right one.
I do know how to do it in QGIS using the quickWKT plugin which is very straightforward.
Eventually however, I want to create a process in python to use these polygons to create masks for smaller tiles of GeoTIFFs for modelling. I wouldn't mind going straight to creating masks using polygons and simply plot them with an alpha over the image.