1+ {
2+ "nbformat" : 4 ,
3+ "nbformat_minor" : 0 ,
4+ "metadata" : {
5+ "colab" : {
6+ "name" : " Spectral_modulation_for_Sentinel2A" ,
7+ "provenance" : []
8+ },
9+ "kernelspec" : {
10+ "name" : " python3" ,
11+ "display_name" : " Python 3"
12+ }
13+ },
14+ "cells" : [
15+ {
16+ "cell_type" : " markdown" ,
17+ "metadata" : {
18+ "id" : " 2Ica80EZrT6b"
19+ },
20+ "source" : [
21+ " ### Performed Spectral Modulation for Sentinel-2A Dataset\n " ,
22+ " - Results are obtained using modulations of \n " ,
23+ " \n " ,
24+ " '111211','111112','111111','112122','201111','221111','211111','111122','111110','111222','111102','111022', '111011', '111201'."
25+ ]
26+ },
27+ {
28+ "cell_type" : " code" ,
29+ "metadata" : {
30+ "colab" : {
31+ "base_uri" : " https://localhost:8080/"
32+ },
33+ "id" : " 8WY7wmHEmEgZ" ,
34+ "outputId" : " b7485417-e524-407e-8b83-9af279c854f1"
35+ },
36+ "source" : [
37+ " pip install rasterio\n "
38+ ],
39+ "execution_count" : null ,
40+ "outputs" : [
41+ {
42+ "output_type" : " stream" ,
43+ "text" : [
44+ " Collecting rasterio\n " ,
45+ " \u001b [?25l Downloading https://files.pythonhosted.org/packages/33/1a/51baddc8581ead98fcef591624b4b2521b581943a9178912a2ac576e0235/rasterio-1.1.8-1-cp36-cp36m-manylinux1_x86_64.whl (18.3MB)\n " ,
46+ " \u001b [K |████████████████████████████████| 18.3MB 46.9MB/s \n " ,
47+ " \u001b [?25hRequirement already satisfied: attrs in /usr/local/lib/python3.6/dist-packages (from rasterio) (20.3.0)\n " ,
48+ " Collecting snuggs>=1.4.1\n " ,
49+ " Downloading https://files.pythonhosted.org/packages/cc/0e/d27d6e806d6c0d1a2cfdc5d1f088e42339a0a54a09c3343f7f81ec8947ea/snuggs-1.4.7-py3-none-any.whl\n " ,
50+ " Collecting cligj>=0.5\n " ,
51+ " Downloading https://files.pythonhosted.org/packages/42/1e/947eadf10d6804bf276eb8a038bd5307996dceaaa41cfd21b7a15ec62f5d/cligj-0.7.1-py3-none-any.whl\n " ,
52+ " Requirement already satisfied: click<8,>=4.0 in /usr/local/lib/python3.6/dist-packages (from rasterio) (7.1.2)\n " ,
53+ " Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from rasterio) (1.18.5)\n " ,
54+ " Collecting affine\n " ,
55+ " Downloading https://files.pythonhosted.org/packages/ac/a6/1a39a1ede71210e3ddaf623982b06ecfc5c5c03741ae659073159184cd3e/affine-2.3.0-py2.py3-none-any.whl\n " ,
56+ " Collecting click-plugins\n " ,
57+ " Downloading https://files.pythonhosted.org/packages/e9/da/824b92d9942f4e472702488857914bdd50f73021efea15b4cad9aca8ecef/click_plugins-1.1.1-py2.py3-none-any.whl\n " ,
58+ " Requirement already satisfied: pyparsing>=2.1.6 in /usr/local/lib/python3.6/dist-packages (from snuggs>=1.4.1->rasterio) (2.4.7)\n " ,
59+ " Installing collected packages: snuggs, cligj, affine, click-plugins, rasterio\n " ,
60+ " Successfully installed affine-2.3.0 click-plugins-1.1.1 cligj-0.7.1 rasterio-1.1.8 snuggs-1.4.7\n "
61+ ],
62+ "name" : " stdout"
63+ }
64+ ]
65+ },
66+ {
67+ "cell_type" : " code" ,
68+ "metadata" : {
69+ "id" : " Ry8H0ytyGbiy"
70+ },
71+ "source" : [
72+ " import rasterio as rio\n " ,
73+ " from rasterio.plot import show\n " ,
74+ " import os\n " ,
75+ " from matplotlib import pyplot as plt\n " ,
76+ " \n " ,
77+ " import warnings\n " ,
78+ " warnings.filterwarnings('ignore')\n "
79+ ],
80+ "execution_count" : null ,
81+ "outputs" : []
82+ },
83+ {
84+ "cell_type" : " code" ,
85+ "metadata" : {
86+ "colab" : {
87+ "base_uri" : " https://localhost:8080/"
88+ },
89+ "id" : " jPxPpsyjHnCn" ,
90+ "outputId" : " 9c34638d-6615-4cad-ad72-61349c56febc"
91+ },
92+ "source" : [
93+ " !pip install import-ipynb\n " ,
94+ " import import_ipynb\n " ,
95+ " # Install the PyDrive wrapper & import libraries.\n " ,
96+ " # This only needs to be done once per notebook.\n " ,
97+ " !pip install -U -q PyDrive\n " ,
98+ " from pydrive.auth import GoogleAuth\n " ,
99+ " from pydrive.drive import GoogleDrive\n " ,
100+ " from google.colab import auth\n " ,
101+ " from oauth2client.client import GoogleCredentials\n " ,
102+ " \n " ,
103+ " # Authenticate and create the PyDrive client.\n " ,
104+ " # This only needs to be done once per notebook.\n " ,
105+ " auth.authenticate_user()\n " ,
106+ " gauth = GoogleAuth()\n " ,
107+ " gauth.credentials = GoogleCredentials.get_application_default()\n " ,
108+ " drive = GoogleDrive(gauth)"
109+ ],
110+ "execution_count" : null ,
111+ "outputs" : [
112+ {
113+ "output_type" : " stream" ,
114+ "text" : [
115+ " Requirement already satisfied: import-ipynb in /usr/local/lib/python3.6/dist-packages (0.1.3)\n "
116+ ],
117+ "name" : " stdout"
118+ }
119+ ]
120+ },
121+ {
122+ "cell_type" : " code" ,
123+ "metadata" : {
124+ "id" : " 3TGxUJXNH922"
125+ },
126+ "source" : [
127+ " your_module = drive.CreateFile({'id':'1wmsXiQGCur82zONnX2TwQXmUZ6g45bRz'})"
128+ ],
129+ "execution_count" : null ,
130+ "outputs" : []
131+ },
132+ {
133+ "cell_type" : " code" ,
134+ "metadata" : {
135+ "id" : " _oAdYgYGIFAU"
136+ },
137+ "source" : [
138+ " your_module.GetContentFile('Spectral_Modulation.ipynb')"
139+ ],
140+ "execution_count" : null ,
141+ "outputs" : []
142+ },
143+ {
144+ "cell_type" : " code" ,
145+ "metadata" : {
146+ "id" : " er3ntpViILpW"
147+ },
148+ "source" : [
149+ " import numpy as np\n " ,
150+ " import pandas as pd\n " ,
151+ " import matplotlib.pyplot as plt\n " ,
152+ " from tqdm import tqdm\n " ,
153+ " import gdal\n " ,
154+ " import osr\n " ,
155+ " import os\n " ,
156+ " import Spectral_Modulation"
157+ ],
158+ "execution_count" : null ,
159+ "outputs" : []
160+ },
161+ {
162+ "cell_type" : " markdown" ,
163+ "metadata" : {
164+ "id" : " EKSJdAayreZe"
165+ },
166+ "source" : [
167+ " Taking Input for Okeechobe Lake,Florida US"
168+ ]
169+ },
170+ {
171+ "cell_type" : " code" ,
172+ "metadata" : {
173+ "id" : " REXeIn3qJicj" ,
174+ "colab" : {
175+ "base_uri" : " https://localhost:8080/"
176+ },
177+ "outputId" : " aecb0d8e-dc93-4b61-bdad-5e5eba41e23b"
178+ },
179+ "source" : [
180+ " from Spectral_Modulation import readBand\n " ,
181+ " Okch_R20 = '/content/drive/MyDrive/Sentinel-2A Data/Okeechobee/S2B_MSIL2A_20181222T160509_N0211_R054_T17RNK_20181222T195126.SAFE/GRANULE/L2A_T17RNK_A009375_20181222T160507/IMG_DATA/R20m/'\n " ,
182+ " green=readBand('B03',Okch_R20 + 'T17RNK_20181222T160509_B03_20m.jp2')\n " ,
183+ " red=readBand('B04',Okch_R20 + 'T17RNK_20181222T160509_B04_20m.jp2')\n " ,
184+ " nir=readBand('B8A',Okch_R20 + 'T17RNK_20181222T160509_B8A_20m.jp2')\n " ,
185+ " swir=readBand('B11',Okch_R20 + 'T17RNK_20181222T160509_B11_20m.jp2')\n " ,
186+ " print(swir[0].shape)\n " ,
187+ " print(red[0].shape)\n " ,
188+ " print(green[0].shape)\n " ,
189+ " print(nir[0].shape)"
190+ ],
191+ "execution_count" : null ,
192+ "outputs" : [
193+ {
194+ "output_type" : " stream" ,
195+ "text" : [
196+ " (5490, 5490)\n " ,
197+ " (5490, 5490)\n " ,
198+ " (5490, 5490)\n " ,
199+ " (5490, 5490)\n "
200+ ],
201+ "name" : " stdout"
202+ }
203+ ]
204+ },
205+ {
206+ "cell_type" : " markdown" ,
207+ "metadata" : {
208+ "id" : " DJSRT3C5r4vN"
209+ },
210+ "source" : [
211+ " Spectral Modulation"
212+ ]
213+ },
214+ {
215+ "cell_type" : " code" ,
216+ "metadata" : {
217+ "colab" : {
218+ "base_uri" : " https://localhost:8080/"
219+ },
220+ "id" : " ScBrZQkQKhCE" ,
221+ "outputId" : " bccf2b2c-5423-4167-ea8c-57acb2c352ed"
222+ },
223+ "source" : [
224+ " from Spectral_Modulation import spectral_modulation\n " ,
225+ " # 7,9,10,12,15,19,21,27,28,2930,31,32,34\n " ,
226+ " \n " ,
227+ " spectral_modulation((green,red,nir,swir),'Okeechobe_Sentinel')"
228+ ],
229+ "execution_count" : null ,
230+ "outputs" : [
231+ {
232+ "output_type" : " stream" ,
233+ "text" : [
234+ "{'222222': [1, 5735819], '222221': [2, 5859501], '122221': [3, 9063922], '122222': [4, 705944], '022221': [5, 53275], '121221': [6, 56452], '111211': [7, 106873], '122220': [8, 2767], '111112': [9, 2037779], '111111': [10, 803274], '111221': [11, 136902], '112122': [12, 45880], '211112': [13, 12119], '221211': [14, 253411], '201111': [15, 13351], '011111': [16, 13424], '222211': [17, 53428], '212112': [18, 1965], '221111': [19, 944598], '121211': [20, 307885], '211111': [21, 1567147], '021211': [22, 4478], '222220': [23, 9480], '112222': [24, 37126], '222112': [25, 938], '121201': [26, 1170], '111122': [27, 1480861], '111110': [28, 66229], '111222': [29, 420639], '111102': [30, 154644], '111022': [31, 68748], '111011': [32, 20756], '111220': [33, 29286], '111201': [34, 17317], '212122': [35, 8446], '222122': [36, 6430], '222111': [37, 1336], '022222': [38, 19252], '111000': [39, 3594], '120221': [40, 1412], '022220': [41, 53], '221011': [42, 3022], '222201': [43, 1395], '222022': [44, 234], '110122': [45, 829], '102222': [46, 1073], '101211': [47, 386], '211110': [48, 351], '112022': [49, 1081], '011112': [50, 477], '110222': [51, 668], '012122': [52, 447], '202122': [53, 211], '101221': [54, 260], '222011': [55, 38], '020201': [56, 23], '210112': [57, 118], '001011': [58, 15], '220211': [59, 1164], '202112': [60, 24], '212102': [61, 101], '220111': [62, 38], '222110': [63, 38], '100220': [64, 11], '222102': [65, 39], '110022': [66, 30], '202102': [67, 2], '101201': [68, 5], '011110': [69, 9], '200110': [70, 0], '002022': [71, 21], '010102': [72, 5], '222000': [73, 0], '220011': [74, 0]}\n",
235+ " [[255. 255. 255. ... 0. 0. 0.]\n " ,
236+ " [255. 255. 255. ... 0. 0. 0.]\n " ,
237+ " [255. 255. 255. ... 0. 0. 0.]\n " ,
238+ " ...\n " ,
239+ " [255. 255. 255. ... 0. 0. 0.]\n " ,
240+ " [255. 255. 255. ... 0. 0. 0.]\n " ,
241+ " [255. 255. 255. ... 0. 0. 0.]]\n " ,
242+ " [[ 1. 1. 1. ... 27. 9. 9.]\n " ,
243+ " [ 1. 1. 4. ... 9. 9. 9.]\n " ,
244+ " [ 1. 1. 1. ... 30. 9. 27.]\n " ,
245+ " ...\n " ,
246+ " [ 1. 1. 1. ... 27. 27. 29.]\n " ,
247+ " [ 1. 1. 1. ... 27. 27. 27.]\n " ,
248+ " [ 1. 1. 1. ... 27. 27. 29.]]\n "
249+ ],
250+ "name" : " stdout"
251+ }
252+ ]
253+ },
254+ {
255+ "cell_type" : " markdown" ,
256+ "metadata" : {
257+ "id" : " bWPjwyeyrtJ1"
258+ },
259+ "source" : [
260+ " Taking Input for Chilikha Lake,Orissa"
261+ ]
262+ },
263+ {
264+ "cell_type" : " code" ,
265+ "metadata" : {
266+ "id" : " Grc7JIwnb6er"
267+ },
268+ "source" : [
269+ " from Spectral_Modulation import readBand\n " ,
270+ " Chlk_R20 = '/content/drive/MyDrive/Sentinel-2A Data/Chilika /S2B_MSIL2A_20181224T045219_N0211_R076_T45QTC_20181224T081321.SAFE/GRANULE/L2A_T45QTC_A009397_20181224T050049/IMG_DATA/R20m/'\n " ,
271+ " green=readBand('B03',Chlk_R20 + 'T45QTC_20181224T045219_B03_20m.jp2')\n " ,
272+ " red=readBand('B04',Chlk_R20 + 'T45QTC_20181224T045219_B04_20m.jp2')\n " ,
273+ " nir=readBand('B8A',Chlk_R20 + 'T45QTC_20181224T045219_B8A_20m.jp2')\n " ,
274+ " swir=readBand('B11',Chlk_R20 + 'T45QTC_20181224T045219_B11_20m.jp2')"
275+ ],
276+ "execution_count" : null ,
277+ "outputs" : []
278+ },
279+ {
280+ "cell_type" : " markdown" ,
281+ "metadata" : {
282+ "id" : " WtcedOS-r1Te"
283+ },
284+ "source" : [
285+ " Spectral Modulation"
286+ ]
287+ },
288+ {
289+ "cell_type" : " code" ,
290+ "metadata" : {
291+ "colab" : {
292+ "base_uri" : " https://localhost:8080/"
293+ },
294+ "id" : " HiiqJJvwfzFQ" ,
295+ "outputId" : " c7d598d7-b1a3-4db3-873e-b302287cbe62"
296+ },
297+ "source" : [
298+ " spectral_modulation((green,red,nir,swir),'Chilikha_Sentinel')"
299+ ],
300+ "execution_count" : null ,
301+ "outputs" : [
302+ {
303+ "output_type" : " stream" ,
304+ "text" : [
305+ "{'222222': [1, 6077743], '122221': [2, 21091140], '122222': [3, 99835], '111112': [4, 23427], '222221': [5, 2487986], '222220': [6, 8875], '111111': [7, 215974], '111211': [8, 9581], '222211': [9, 5540], '121211': [10, 8017], '022221': [11, 25675], '112222': [12, 2464], '022222': [13, 3532], '222022': [14, 33], '112122': [15, 1310], '211111': [16, 32838], '211112': [17, 4400], '221111': [18, 4882], '212122': [19, 1566], '121221': [20, 13401], '221211': [21, 5074], '122220': [22, 952], '222111': [23, 1114], '222122': [24, 3063], '212112': [25, 937], '111221': [26, 2953], '101221': [27, 38], '222112': [28, 765], '121201': [29, 70], '111122': [30, 3009], '011111': [31, 214], '111222': [32, 2100], '011112': [33, 35], '111110': [34, 694], '220211': [35, 26], '111011': [36, 106], '211110': [37, 58], '022220': [38, 25], '111102': [39, 20], '120221': [40, 116], '111201': [41, 52], '102222': [42, 23], '110222': [43, 13], '111022': [44, 30], '111220': [45, 39], '201111': [46, 35], '221011': [47, 22], '222201': [48, 65], '212102': [49, 6], '202122': [50, 15], '222102': [51, 11], '021211': [52, 31], '112022': [53, 13], '222011': [54, 12], '222110': [55, 11], '210112': [56, 10], '220111': [57, 7], '101211': [58, 35], '202112': [59, 5], '110122': [60, 12], '012122': [61, 2], '000000': [62, 0], '202102': [63, 0]}\n",
306+ " [[255. 255. 255. ... 255. 255. 255.]\n " ,
307+ " [255. 255. 255. ... 255. 255. 255.]\n " ,
308+ " [255. 255. 255. ... 255. 255. 255.]\n " ,
309+ " ...\n " ,
310+ " [255. 255. 255. ... 255. 255. 255.]\n " ,
311+ " [255. 255. 255. ... 255. 255. 255.]\n " ,
312+ " [255. 255. 255. ... 255. 255. 255.]]\n " ,
313+ " [[1. 1. 1. ... 1. 1. 1.]\n " ,
314+ " [1. 1. 1. ... 5. 5. 5.]\n " ,
315+ " [1. 1. 1. ... 5. 5. 5.]\n " ,
316+ " ...\n " ,
317+ " [2. 1. 1. ... 1. 1. 1.]\n " ,
318+ " [1. 1. 1. ... 1. 1. 1.]\n " ,
319+ " [2. 2. 2. ... 1. 1. 1.]]\n "
320+ ],
321+ "name" : " stdout"
322+ }
323+ ]
324+ }
325+ ]
326+ }
0 commit comments