Tailoring flood images

Sai Krishna Dammalapati
CivicDataLab
Published in
6 min readAug 18, 2022

There is a sea of water all around, but not a drop to drink. The very hands that prayed for ample rains are now swollen and pruned, rowing boats and flushing out water. The mighty flood carried with it the grain, money, stock and life; giving back infections, hunger, homelessness and death. The survivors, gulping with fear, scrambled the leftover buildings and prayed looking at the skies with teary eyes, that someone would see their plight from above and rescue them. Be it Gods or the men of the army. But a far greater eye is seeing them, from thousands of feet above — the Satellite.

CivicDataLab’s IDEA-FRM Project

One of our current projects at CivicDataLab is to develop an Intelligent Data Ecosystem for Assam- Flood Response & Management (IDEA-FRM). In this project, we are linking fiscal, geospatial and socio-economic data into an intelligent data model that will enable decision makers in improving the flood response, making the State reach the most vulnerable. We have detailed the IDEA-FRM project in one of our previous blogs [Link]. Also, this blog post helps in a general understanding of the Governance of Flood Management in Assam.

Fig 1: Data Hypothesis of IDEA-FRM project.

This blog details the process of capturing one of these datasets — Flood Inundations. We are making similar efforts to create machine-readable, ML ready datasets in the Fiscal, Geospatial and Socio-Economic categories to ensure that the annual floods of Assam don’t shock us every year and that we are well-prepared to deal with such disasters, especially in the looming danger of climate change.

Dataset

Assam is reeling under floods. Millions of people are affected, and their plight is being observed by various means — the Chief Minister took an aerial survey, the Indian Air Force deployed Chinook helicopters, and private companies like Garuda Aerospace deployed Drones. While all these observations are crucial, there are satellites overseeing all of it silently from space. BHUVAN, ISRO’s Geoportal, is making these images available for various states from 2006 onwards. If these images can be made machine-readable, they aid in not only observing the plight of victims but also in becoming intelligent about their plight and ways to address it.

Fig 2: Assam Floods 2022 — Image Source BHUVAN

BHUVAN makes the flood inundation maps available through GeoServer, with WMS image service. As a result, the maps are available as images (PNG) of 256*256 pixels. However, the user can choose what area can fit in a single image — the entire Assam or a village in it! — by sending the latitudes and longitudes of their area of interest. The lowest possible range of an image can be 0.0439453125 degrees longitudinally and latitudinally. As a result, each of the 256*256 pixels corresponds to a 10m*10m area on average. A sample flood map image is as below: [URL]

Fig 3: Flood map on 2021–07–01. BBOX=94.5703125,26.9384765625,94.6142578125,26.982421875

To cover the entire Assam at this resolution, 13,680 such images have to be downloaded and stitched latitudinally and longitudinally. To make things challenging, a few of these images come with a BHUVAN watermark, which has to be removed so that the computer doesn’t mistake the watermark for a flood. The next section details the tailoring done to clean and stitch these 13,680 images to represent a flood inundation map for a given day.

Tailoring images

1.Download images

For a given day, all the 13,680 images that pan across Assam have to be downloaded. For which, the Bounding box (BBOX) coordinates of the 13,680 boxes of interest should be found. I use the fact that the width and height of a single image is 0.0439453125 degrees to create a list of all 13,680 BBOXs.

The above code snippet gives the following output:

Fig 4: Output to the download_images.py code

This means that there are 144 images latitudinally and 95 images longitudinally (13,680 in total). I then download these images by naming them using their BBOX coordinates through the following function.

Voila! I now downloaded all the 13,680 images for a given day that represent the flooding situation in Assam. The next step is to clean watermarks from them and stitch them together so that I can represent Assam Floods in a single image.

2.Clean water marks.

Some of the 13,680 come with a BHUVAN watermark. A sample is attached below.

Fig 5: Flood image with “bhu” water mark on top-right.

There is a danger that the computer reads the watermark as a flood. Hence, these have to be removed from images.

Simplistically, an image is nothing but numbers in pixels. If it’s a colour image, there are three bands of pixels — RGB — the combination of which produces numerous colours we see. We can see that the above image is colourful (Flood in Blue, watermark in various shades of Grey). I opened this image in QGIS to read the numerical values of watermarks. Fortunately, there was a pattern; for a watermark, the values on three bands are equal, i.e., R=G=B. And this is not the case with areas where there are floods.

Fig 6: RGB values for water mark

I use this fact to remove watermarks, wherever they exist, using the following code:

Fig 7: Removed water mark.

3.Stitch images

Fig 8: Schematic representation of the 13680 images (144*95) that pan across Assam

I go about stitching these 13,680 images in three steps:

  • Firstly, I write a function that takes in two images and returns a merged image, either horizontally or vertically.
  • I then stitch images vertically (latitudinally) — there are 144 vertical stretches, 95 images per a vertical stretch.
  • Then I stitch the 144 resultant vertical images horizontally (longitudinally).
Fig 9: Final stitched image after converting in into grayscale.

Geo-reference the image

The flood map image is finally made, but the pixels of this image do not contain any latitude-longitude value. This is needed for any geo-intelligence that we have to gather from the image. This PNG is thus converted into a NetCDF file and GeoTIFF by adding locational information to the pixels as well.

The geo-referenced image can be analysed on any geospatial software like QGIS.

Fig 10: Georeferenced flood images representing 2017 floods in Assam.

And thus we get to historically and dynamically survey the flood situation in Assam, by utilising the eye in the sky, the Satellite. We aim to use this data in driving decisions about flood relief, preparation and prevention — making flood relief management intelligent and responsive.

References

If you are further keen to know more about our work on flood management in Assam or about data solutions to disaster management, the following links can help you get started:

  • 2022 Assam Flood Response Repository: A crowdsourced repository to keep a track of all important official and unofficial sources of information regarding 2022 Assam Floods, to help citizens monitor and track the on-ground situation and rally their support.
  • Disaster Services by BHUVAN: A geo-spatial data service on various disasters in India, provided by ISRO.

Or write to us at info@civicdatalab.in or saikrishna@civicdatalab.in if you have any questions, ideas or suggestions!

--

--

Sai Krishna Dammalapati
CivicDataLab

Interested in inter-sectoral areas of Technology and Socio-Economic Development.