cropmapteam / Scotland-crop-map

This is the repository for the Scottish Government collaboration with EDINA and JNCC to produce a crop map for Scotland by developing machine learning algorithms applied to Sentinel satellite data
3 stars 0 forks source link

Write script to mask out digitised radar interference RFI locations #31

Closed geojamesc closed 5 years ago

geojamesc commented 5 years ago

Team members will digitise in QGIS polygons describing the location of radar interference noise present in the radar data. Script should take the polygons and mask out in the associated image the pixels falling within the digitised polygons as nodata.

This is an alternative to #22

The manually digitised polygons should be retained as they could provide possible training data for #22

geojamesc commented 5 years ago

Perhaps we can use

https://rasterio.readthedocs.io/en/stable/api/rasterio.mask.html

rasterio.mask.mask(dataset, shapes, all_touched=False, invert=False, nodata=None, filled=True, crop=False, pad=False, indexes=None)

call.

geojamesc commented 5 years ago

Script https://github.com/cropmapteam/Scotland-crop-map/commit/33c359088dae2b5c21d86cec9a8af56c238f4725 which calls rasterio.mask.mask(raster_src, mask_polys, invert=True) was written.

Script was ran against all 51 shapefiles containing the digitised RFI locations. So in the image below the pixels in the image which fell inside the red digitised polygons have been set to nodata:

masked_out_rfi

Processing time per image is about 7 mins. On my local machine it took ~3hrs to process 43 images and mask out the RFI locations. The script detected problems with 8 of the shapefiles ( e.g. invalid geometries / duplicate features etc) during validation and so some of the images have not yet been processed. I will create a new issue to cover checking/editing of the digitised RFI locations.