Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Estimation of river turbidity using sentinel-2 satellite data #742

Open
wants to merge 2 commits into
base: master
from

Conversation

@shivanip32
Copy link
Contributor

shivanip32 commented Jul 20, 2020

This notebook shows how river turbidity can be estimated using satellite data without any field measurement.


Checklist

Please go through each entry in the below checklist and mark an 'X' if that condition has been met. Every entry should be marked with an 'X' to be get the Pull Request approved.

  • All imports are in the first cell? First block of imports are standard libraries, second block are 3rd party libraries, third block are all arcgis imports? Note that in some cases, for samples, it is a good idea to keep the imports next to where they are used, particularly for uncommonly used features that we want to highlight.
  • All GIS object instantiations are one of the following?
    • gis = GIS()
    • gis = GIS('https://www.arcgis.com', 'arcgis_python', 'P@ssword123')
    • gis = GIS(profile="your_online_profile")
    • gis = GIS('https://pythonapi.playground.esri.com/portal', 'arcgis_python', 'amazing_arcgis_123')
    • gis = GIS(profile="your_enterprise_portal")
  • If this notebook requires setup or teardown, did you add the appropriate code to ./misc/setup.py and/or ./misc/teardown.py?
  • If this notebook references any portal items that need to be staged on AGOL/Python API playground, did you coordinate with a Python API team member to stage the item the correct way with the api_data_owner user?
  • Code refactored & split out across multiple cells, useful comments?
  • Consistent voice/tense/narrative style? Thoroughly checked for typos?
  • All images used like <img src="base64str_here"> instead of <img src="https://some.url">? All map widgets contain a static image preview? (Call mapview_inst.take_screenshot() to do so)
  • All file paths are constructed in an OS-agnostic fashion with os.path.join()? (Instead of r"\foo\bar", os.path.join(os.path.sep, "foo", "bar"), etc.)
  • IF YOU WANT THIS SAMPLE TO BE DISPLAYED ON THE DEVELOPERS.ARCGIS.COM WEBSITE, ping @ DavidJVitale so he can add it to the list for the next deploy
@review-notebook-app
Copy link

review-notebook-app bot commented Jul 20, 2020

Check out this pull request on  ReviewNB

Review Jupyter notebook visual diffs & provide feedback on notebooks.


Powered by ReviewNB

@shivanip32 shivanip32 requested a review from priyankatuteja Jul 20, 2020
@shivanip32 shivanip32 self-assigned this Jul 20, 2020
Shivani Pathak
@shivanip32
Copy link
Contributor Author

shivanip32 commented Jul 21, 2020

@priyankatuteja priyankatuteja requested a review from moonlanderr Aug 5, 2020
@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:32Z
----------------------------------------------------------------

Create geometry of AOI
Generate water body mask
Create water body mask

@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:33Z
----------------------------------------------------------------

Turbidity represents the level of suspended sediments in water also indicating water clarity or how clear is the water. It is mainly caused by the presence of silt, algae in a water body, or industrial waste disposed in the rivers by mining activity, factory operation, logging, etc.

Traditionally, turbidity is analyzed by evaluating water samples taken during field measurements. However, field studies are expensive, time and labor intensive, besides, during lockdown field surveys cannot be undertaken. Thus, a good alternative to field survey measurements is satellite remote sensing data, which can as well capture both spatial and temporal variations in river turbidity levels. Accordingly, Sentinel-2 multispectral data is used in the current study to evaluate the changes in river turbidity during COVID-19 lockdown, near the holy city of Allahabad, India.

The case study area of Allahabad is in the northern part of India, at the confluence of Ganga and Yamuna river, which is considered as one of the important cities in Hindu religion. Everyday thousands of Hindu devotees visit the city and disposes waste directly in the rivers. The small-scale factories situated in the city also disposes its waste into the rivers adding to the water pollution. On 25th March 2020, lockdown was announced in India for controlling the COVID-19 spread which meant total shutdown of industries and restricted human movement. The lockdown resulted in reduction of turbidity hence improved water quality in rivers throughout the country. This notebook will elaborate the steps to measure this change in turbidity using arcgis api for python tools.


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:34Z
----------------------------------------------------------------

Necessary


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:34Z
----------------------------------------------------------------

1. check if this line is needed

from arcgis import *

2. the arcgis imports can be grouped together like this,

import pandas as pd
from datetime import datetime
from ipywidgets import HBox, VBox, Label, Layout

import arcgis
from arcgis import *
from arcgis.features import GeoAccessor, GeoSeriesAccessor
from arcgis.raster.analytics import convert_feature_to_raster, convert_raster_to_feature
from arcgis.raster.functions import extract_band, greater_than, clip, remap, colormap, stretch
from arcgis.features.analysis import dissolve_boundaries



@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:35Z
----------------------------------------------------------------

Sentinel-2 Views was used in the analysis: - this multispectral and multitemporal imagery consists of 13 bands with 10, 20, and 60m spatial resolution, which is rendered on-the-fly and available for visualization and analytics. This imagery layer pulls directly from the Sentinel-2 on AWS collection and is updated daily with new imagery. 


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:36Z
----------------------------------------------------------------

add some description what is being done in this step of searching allahabad aoi, also why it is needed

@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:37Z
----------------------------------------------------------------

describe the methodology briefly in words as elaborated in the graphics

@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:38Z
----------------------------------------------------------------

Sentinel-2 Views imagery layers consists data for the whole world and span different time periods. Thus the first step is to filter out the data of the river in the Allahabad region prior to lockdwon and during the period of lockdown.


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:39Z
----------------------------------------------------------------

Create geometry of area of interest (AOI)


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:40Z
----------------------------------------------------------------

The geometry of AOI was created for filtering out the Sentinel-2 tiles for the study area.


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:41Z
----------------------------------------------------------------

briefly refer where are you getting the fid=1


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:42Z
----------------------------------------------------------------

describe briefly what is being done here


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:43Z
----------------------------------------------------------------

briefly refer how you are getting category=1


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:43Z
----------------------------------------------------------------

briefly refer where you are getting the object id for filtering


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:45Z
----------------------------------------------------------------

provide a brief what will be done here along with the filter_by parameters source reference


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:45Z
----------------------------------------------------------------

Generate water body mask


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:46Z
----------------------------------------------------------------

Create normalized difference water index (NDWI) raster



@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:47Z
----------------------------------------------------------------

Normalized difference water index (NDWI) is a satellite based index used for mapping and detecting the surface water bodies. Water absorbs electromagnetic radiation in visible to infrared spectrum, that is why Green and Near Infrared bands are used to detect the water bodies. In the current study, band 3 (green) and band 8 (NIR) of Sentinel-2 is used for generating NDWI raster. Accordingly the bands are first extracted followed by creation of the NDWI raster as follows:

move the Extract bands section within this section of -Generate water bodies mask- after this paragraph so that it becomes clear why these particular bands are extracted, and change the content accordingly

@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:48Z
----------------------------------------------------------------

Binary raster is created from NDWI raster using a threshold value. The binary raster consists of two classes of water and non-water pixels where pixels with value greater than 0.03 are considered as water. Accordingly this threshold value of 0.03 is used for creating the binary raster using the greater_than function.


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:49Z
----------------------------------------------------------------

Create water body mask

add text explaining this step

@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:50Z
----------------------------------------------------------------

The binary rasters are converted to feature layer for extracting the boundaries of the water bodies.


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:50Z
----------------------------------------------------------------

In the feature layer returned above, 'gridcode=0' represents non water class and 'gridcode=1' represents water class. Thus the water polygons with 'gridcode=1 are selected using the query function from the dataframe of the feature layer and saved into a new feature layer created using gis.content.import function consisting of these water polygons.


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:51Z
----------------------------------------------------------------

explain the parameter t


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:52Z
----------------------------------------------------------------

Finally the features in the layer water_poly are dissolved using dissolve_boundaries function on the basis of gridcode column to obtain the water body mask in the following.


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:53Z
----------------------------------------------------------------

The Normalize Difference Turbidity Index (NDTI) which is estimated using the spectral reflectance values of the water pixels is used to estimate the turbidity in water bodies. It uses the phenomenon that the electromagnetic reflectance is higher in green spectrum than the red spectrum for clear water. Hence, with increase in turbidity the reflectance of red spectrum also increases. Accordingly in the current study Sentinel-2 green (band 3) and red (band 4) bands are used to create the NDTI raster in the following.


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:54Z
----------------------------------------------------------------

Once the NDTI raster is prepared, its portion for the water body is extracted using the water body mask obtained before. To do that first the geometry of dissolve_f is created as follows:

dissolve_f -is it the water mask created before? diss_f - is this one?

@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:55Z
----------------------------------------------------------------

Third step is to apply colormap for visualizing the results.


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:56Z
----------------------------------------------------------------

Finally all the above mentioned functions are used inside a loop and applied on the satellite imagery of the river from two different time periods: one before lockdown and the second, during the lockdown period, to visualize and compare the difference in the turbidity levels in them.


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:57Z
----------------------------------------------------------------

Result Visualization



@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:57Z
----------------------------------------------------------------

The NDTI rasters and their corresponding Sentinel-2 tiles are now accessed from the portal and used for visualization.


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:58Z
----------------------------------------------------------------

4 map wigets are created representing the NDTI raster and corresponding Sentinel-2 for 9th March (before lockdown) and 13th April (during lockdown).


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:04:59Z
----------------------------------------------------------------

All the maps are synchronized with each other using MapView.sync_navigation functionality. It helps in comparing the river turbidity before and during lockdown. Detailed description about advanced map widget options can be referred here


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:05:00Z
----------------------------------------------------------------

if possible add a legend for the pixel colors
if possible point out which one is the Yamuna & Ganga river

@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:05:01Z
----------------------------------------------------------------

The maps above shows the spatio-temporal variation in the Ganga and Yamuna river turbidity due to Covid-19 lockdown. The satellite imageries used in the analysis are from before lockdown situation, dated 9th march 2020 (bottom-left), and during the lockdown situation dated 13th April 2020 (botton-right).

It can be seen that turbidity declined in both the Ganga and Yamuna river during lockdown indicated by the Red pixels representing high turbidity, turning to Orange, Yellow and finally Green, which is the lowest level of turbidity. Compared to the Yamuna the Ganga river had a significant impact with the whole river stretch turning from red and yellow to mostly green pixels. The turbidity at the Sangam or the confluence point also declined followed by the same in the stretch downstream.


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 3, 2020

View / edit / reply to this conversation on ReviewNB

moonlanderr commented on 2020-09-03T07:05:02Z
----------------------------------------------------------------

Ganga and Yamuna river falls under the world's most polluted river due to dumping of waste from industrial and religious activities indicated by its highly turbid water. During the period of lock down there was a significant improvement in the pollution level of both the rivers due to complete shutdown of the above-mentioned functions. This change was investigated using Sentinel-2 satellite imageries of the river stretches, before and during the lockdown periods, with results suggesting substantial decrease in turbidity levels thereby validating the same. The same methodology can be implemented to study the changes in river turbidity for other regions with Sentinel-2 data using ArcGIS platform.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.