In [1]:
# Import python libraries
import getpass
import json
import os
import pathlib
from glob import glob

import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt

import earthpy.appeears as eaapp
import hvplot.pandas
import hvplot.xarray
import rioxarray as rxr
import xarray as xr
In [2]:
asia_fires_url = "https://data.cyverse.org/dav-anon/iplant/projects/earthlab/firedpy_north_america/fired_central_asia_to2021182_events.gpkg"

asia_fires_gdf = gpd.read_file(asia_fires_url)
asia_fires_gdf
Out[2]:
id ig_date ig_day ig_month ig_year last_date event_dur tot_pix tot_ar_km2 fsr_px_dy ... lc_name lc_desc lc_type eco_mode eco_name eco_type ig_utm_x ig_utm_y tot_perim geometry
0 1 2000-11-02 307 11 2000 2000-11-02 1 2 0.429317 2.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Kazakh semi-desert WWF Terrestrial Ecoregions of the World 4.487647e+06 5.234044e+06 1861.250866 MULTIPOLYGON (((4487879.629 5233811.102, 44874...
1 2 2000-11-02 307 11 2000 2000-11-02 1 2 0.429317 2.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Kazakh semi-desert WWF Terrestrial Ecoregions of the World 4.490427e+06 5.235897e+06 1861.250866 MULTIPOLYGON (((4490659.505 5235664.353, 44901...
2 3 2000-11-02 307 11 2000 2000-11-02 1 2 0.429317 2.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Kazakh semi-desert WWF Terrestrial Ecoregions of the World 4.488574e+06 5.228484e+06 1861.250866 MULTIPOLYGON (((4488806.254 5228251.350, 44883...
3 5 2000-11-02 307 11 2000 2000-11-02 1 1 0.214659 1.0 ... Barren At least 60% of area is non-vegetated barren(s... IGBP global vegetation classification scheme 18.0 Kazakh semi-desert WWF Terrestrial Ecoregions of the World 4.707721e+06 5.251186e+06 1861.250866 MULTIPOLYGON (((4707487.856 5250953.673, 47079...
4 6 2000-11-02 307 11 2000 2000-11-02 1 3 0.643976 3.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Kazakh semi-desert WWF Terrestrial Ecoregions of the World 4.643320e+06 5.306321e+06 4641.127165 MULTIPOLYGON (((4644016.014 5306089.886, 46444...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
212184 817204 2021-08-01 213 8 2021 2021-08-01 1 6 1.287952 6.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 10.0 Kazakh steppe WWF Terrestrial Ecoregions of the World 4.309272e+06 5.597744e+06 7421.003464 MULTIPOLYGON (((4310894.171 5597050.272, 43113...
212185 817205 2021-08-01 213 8 2021 2021-08-01 1 3 0.643976 3.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 11.0 Central Asian riparian woodlands WWF Terrestrial Ecoregions of the World 4.830962e+06 4.826792e+06 1861.250866 MULTIPOLYGON (((4831194.352 4826559.224, 48307...
212186 817209 2021-08-01 213 8 2021 2021-08-01 1 1 0.214659 1.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Kazakh semi-desert WWF Terrestrial Ecoregions of the World 4.688261e+06 5.578285e+06 1861.250866 MULTIPOLYGON (((4688028.722 5578052.451, 46884...
212187 817217 2021-08-01 213 8 2021 2021-08-01 1 1 0.214659 1.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 9.0 Kazakh forest steppe WWF Terrestrial Ecoregions of the World 4.153599e+06 5.775193e+06 1861.250866 MULTIPOLYGON (((4153365.847 5774960.355, 41538...
212188 817224 2021-08-01 213 8 2021 2021-08-01 1 3 0.643976 3.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 10.0 Kazakh steppe WWF Terrestrial Ecoregions of the World 5.187712e+06 5.736275e+06 3714.501732 MULTIPOLYGON (((5187943.143 5735578.774, 51874...

212189 rows × 30 columns

In [3]:
fires_2021 = asia_fires_gdf[asia_fires_gdf["ig_year"]==2021]
fires_2021
Out[3]:
id ig_date ig_day ig_month ig_year last_date event_dur tot_pix tot_ar_km2 fsr_px_dy ... lc_name lc_desc lc_type eco_mode eco_name eco_type ig_utm_x ig_utm_y tot_perim geometry
207928 801338 2021-01-01 1 1 2021 2021-01-04 4 20 4.293173 5.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 3.0 Northwestern thorn scrub forests WWF Terrestrial Ecoregions of the World 6.661974e+06 3.670827e+06 7421.003464 MULTIPOLYGON (((6662204.207 3670593.997, 66617...
207929 801339 2021-01-01 1 1 2021 2021-01-10 10 20 4.293173 2.0 ... Croplands At least 60% of area is cultivated cropland IGBP global vegetation classification scheme 2.0 Western Himalayan subalpine conifer forests WWF Terrestrial Ecoregions of the World 6.683286e+06 3.821403e+06 7421.003464 MULTIPOLYGON (((6683518.592 3820707.317, 66830...
207930 801369 2021-01-02 2 1 2021 2021-01-04 3 18 3.863856 6.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.507690e+06 3.734764e+06 6494.378031 MULTIPOLYGON (((6507459.760 3734067.839, 65074...
207931 801371 2021-01-02 2 1 2021 2021-01-02 1 1 0.214659 1.0 ... Croplands At least 60% of area is cultivated cropland IGBP global vegetation classification scheme 3.0 Northwestern thorn scrub forests WWF Terrestrial Ecoregions of the World 6.898726e+06 2.841034e+06 1861.250866 MULTIPOLYGON (((6898493.693 2840800.921, 68989...
207932 801375 2021-01-02 2 1 2021 2021-01-05 4 10 2.146587 2.5 ... Barren At least 60% of area is non-vegetated barren(s... IGBP global vegetation classification scheme 26.0 Registan-North Pakistan sandy desert WWF Terrestrial Ecoregions of the World 5.882682e+06 3.477625e+06 6494.378031 MULTIPOLYGON (((5883377.531 3476465.968, 58829...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
212184 817204 2021-08-01 213 8 2021 2021-08-01 1 6 1.287952 6.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 10.0 Kazakh steppe WWF Terrestrial Ecoregions of the World 4.309272e+06 5.597744e+06 7421.003464 MULTIPOLYGON (((4310894.171 5597050.272, 43113...
212185 817205 2021-08-01 213 8 2021 2021-08-01 1 3 0.643976 3.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 11.0 Central Asian riparian woodlands WWF Terrestrial Ecoregions of the World 4.830962e+06 4.826792e+06 1861.250866 MULTIPOLYGON (((4831194.352 4826559.224, 48307...
212186 817209 2021-08-01 213 8 2021 2021-08-01 1 1 0.214659 1.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Kazakh semi-desert WWF Terrestrial Ecoregions of the World 4.688261e+06 5.578285e+06 1861.250866 MULTIPOLYGON (((4688028.722 5578052.451, 46884...
212187 817217 2021-08-01 213 8 2021 2021-08-01 1 1 0.214659 1.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 9.0 Kazakh forest steppe WWF Terrestrial Ecoregions of the World 4.153599e+06 5.775193e+06 1861.250866 MULTIPOLYGON (((4153365.847 5774960.355, 41538...
212188 817224 2021-08-01 213 8 2021 2021-08-01 1 3 0.643976 3.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 10.0 Kazakh steppe WWF Terrestrial Ecoregions of the World 5.187712e+06 5.736275e+06 3714.501732 MULTIPOLYGON (((5187943.143 5735578.774, 51874...

4261 rows × 30 columns

In [4]:
fires_2021.explore()
Out[4]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [4]:
pak_url = "https://stacks.stanford.edu/file/druid:st456dv9938/data.zip"
pak_gdf = gpd.read_file(pak_url)
pak_gdf
Out[4]:
ID_0 ISO NAME_0 ID_1 NAME_1 HASC_1 CCN_1 CCA_1 TYPE_1 ENGTYPE_1 NL_NAME_1 VARNAME_1 geometry
0 171 PAK Pakistan 1 Azad Kashmir PK.JK 0 None Centrally Administered Area Centrally Administered Area None Kashmir POLYGON ((74.64930 35.13991, 74.66885 35.12403...
1 171 PAK Pakistan 2 Baluchistan PK.BA 0 None Province Province None Balochistan|BéloutchistanBeluchistan|Baluchistão MULTIPOLYGON (((66.60542 24.90264, 66.60542 24...
2 171 PAK Pakistan 3 F.A.T.A. PK.TA 0 None Territory Territory None Federally Administered Tribal Areas POLYGON ((71.55066 34.93081, 71.56419 34.91536...
3 171 PAK Pakistan 4 F.C.T. PK.IS 0 None Capital Territory Capital Territory None Islamabad|Federal Capital Territory|Federal Ca... POLYGON ((72.88009 33.75444, 72.90147 33.75299...
4 171 PAK Pakistan 5 N.W.F.P. PK.NW 0 None Province Province None North-West Frontier Province POLYGON ((73.66302 36.88824, 73.66410 36.88670...
5 171 PAK Pakistan 6 Northern Areas PK.NA 0 None Centrally Administered Area Centrally Administered Area None None POLYGON ((74.74200 37.02206, 74.74920 37.02148...
6 171 PAK Pakistan 7 Punjab PK.PB 0 None Province Province None Pendjab|Penjab POLYGON ((73.53603 33.66520, 73.53673 33.65730...
7 171 PAK Pakistan 8 Sind PK.SD 0 None Province Province None Sindh MULTIPOLYGON (((68.07542 23.70542, 68.07542 23...
In [7]:
pak_gdf.explore()
Out[7]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [5]:
fata = pak_gdf[pak_gdf["NAME_1"]=="F.A.T.A."]
fata
Out[5]:
ID_0 ISO NAME_0 ID_1 NAME_1 HASC_1 CCN_1 CCA_1 TYPE_1 ENGTYPE_1 NL_NAME_1 VARNAME_1 geometry
2 171 PAK Pakistan 3 F.A.T.A. PK.TA 0 None Territory Territory None Federally Administered Tribal Areas POLYGON ((71.55066 34.93081, 71.56419 34.91536...
In [6]:
fata.plot()
print(fata.crs)
EPSG:4326
No description has been provided for this image
In [7]:
print(fires_2021.crs)
PROJCS["unknown",GEOGCS["unknown",DATUM["unknown",SPHEROID["unknown",6371007.181,0]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433]],PROJECTION["Sinusoidal"],PARAMETER["longitude_of_center",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH]]
In [8]:
# Reproject fire data 
fires_2021_4326 = fires_2021.to_crs('epsg:4326')
fires_2021_4326
Out[8]:
id ig_date ig_day ig_month ig_year last_date event_dur tot_pix tot_ar_km2 fsr_px_dy ... lc_name lc_desc lc_type eco_mode eco_name eco_type ig_utm_x ig_utm_y tot_perim geometry
207928 801338 2021-01-01 1 1 2021 2021-01-04 4 20 4.293173 5.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 3.0 Northwestern thorn scrub forests WWF Terrestrial Ecoregions of the World 6.661974e+06 3.670827e+06 7421.003464 MULTIPOLYGON (((71.44837 33.01041, 71.44340 33...
207929 801339 2021-01-01 1 1 2021 2021-01-10 10 20 4.293173 2.0 ... Croplands At least 60% of area is cultivated cropland IGBP global vegetation classification scheme 2.0 Western Himalayan subalpine conifer forests WWF Terrestrial Ecoregions of the World 6.683286e+06 3.821403e+06 7421.003464 MULTIPOLYGON (((72.81162 34.36041, 72.80657 34...
207930 801369 2021-01-02 2 1 2021 2021-01-04 3 18 3.863856 6.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.507690e+06 3.734764e+06 6494.378031 MULTIPOLYGON (((70.24698 33.58124, 70.24696 33...
207931 801371 2021-01-02 2 1 2021 2021-01-02 1 1 0.214659 1.0 ... Croplands At least 60% of area is cultivated cropland IGBP global vegetation classification scheme 3.0 Northwestern thorn scrub forests WWF Terrestrial Ecoregions of the World 6.898726e+06 2.841034e+06 1861.250866 MULTIPOLYGON (((68.76286 25.54791, 68.76750 25...
207932 801375 2021-01-02 2 1 2021 2021-01-05 4 10 2.146587 2.5 ... Barren At least 60% of area is non-vegetated barren(s... IGBP global vegetation classification scheme 26.0 Registan-North Pakistan sandy desert WWF Terrestrial Ecoregions of the World 5.882682e+06 3.477625e+06 6494.378031 MULTIPOLYGON (((61.89947 31.26457, 61.89458 31...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
212184 817204 2021-08-01 213 8 2021 2021-08-01 1 6 1.287952 6.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 10.0 Kazakh steppe WWF Terrestrial Ecoregions of the World 4.309272e+06 5.597744e+06 7421.003464 MULTIPOLYGON (((60.73828 50.33543, 60.74481 50...
212185 817205 2021-08-01 213 8 2021 2021-08-01 1 3 0.643976 3.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 11.0 Central Asian riparian woodlands WWF Terrestrial Ecoregions of the World 4.830962e+06 4.826792e+06 1861.250866 MULTIPOLYGON (((59.80445 43.40624, 59.79869 43...
212186 817209 2021-08-01 213 8 2021 2021-08-01 1 1 0.214659 1.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Kazakh semi-desert WWF Terrestrial Ecoregions of the World 4.688261e+06 5.578285e+06 1861.250866 MULTIPOLYGON (((65.81552 50.16457, 65.82205 50...
212187 817217 2021-08-01 213 8 2021 2021-08-01 1 1 0.214659 1.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 9.0 Kazakh forest steppe WWF Terrestrial Ecoregions of the World 4.153599e+06 5.775193e+06 1861.250866 MULTIPOLYGON (((60.58245 51.93541, 60.58923 51...
212188 817224 2021-08-01 213 8 2021 2021-08-01 1 3 0.643976 3.0 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 10.0 Kazakh steppe WWF Terrestrial Ecoregions of the World 5.187712e+06 5.736275e+06 3714.501732 MULTIPOLYGON (((75.08194 51.58124, 75.07523 51...

4261 rows × 30 columns

In [9]:
# Plot fires (2021) and F.A.T.A. boundary on same axis
fig, ax = plt.subplots()
fires_2021_4326.plot(ax=ax)
fata.plot(color='grey', edgecolor='black', ax=ax)
Out[9]:
<Axes: >
No description has been provided for this image
In [10]:
# Clip fires to F.A.T.A. boundary
fata_fires = gpd.clip(fires_2021_4326, fata)
fata_fires
Out[10]:
id ig_date ig_day ig_month ig_year last_date event_dur tot_pix tot_ar_km2 fsr_px_dy ... lc_name lc_desc lc_type eco_mode eco_name eco_type ig_utm_x ig_utm_y tot_perim geometry
208419 802235 2021-02-14 45 2 2021 2021-02-14 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.522053e+06 3.637468e+06 1861.250866 POLYGON ((69.70667 32.71041, 69.70994 32.71459...
208523 802679 2021-03-01 60 3 2021 2021-03-01 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.522053e+06 3.637931e+06 1861.250866 POLYGON ((69.70993 32.71457, 69.71320 32.71876...
208517 802594 2021-02-28 59 2 2021 2021-02-28 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.521126e+06 3.638395e+06 1861.250866 POLYGON ((69.70328 32.71874, 69.70655 32.72293...
208377 802088 2021-02-11 42 2 2021 2021-02-15 5 18 3.863856 3.600000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.521590e+06 3.638858e+06 7421.003464 POLYGON ((69.70823 32.71874, 69.71149 32.72291...
211529 815782 2021-06-29 180 6 2021 2021-07-06 8 36 7.727712 4.500000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.499351e+06 3.681020e+06 11127.505197 POLYGON ((69.77861 33.09791, 69.77364 33.09791...
211665 816028 2021-07-04 185 7 2021 2021-07-04 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.644368e+06 3.493378e+06 1861.250866 POLYGON ((70.01500 31.41457, 70.01812 31.41876...
208528 802699 2021-03-01 60 3 2021 2021-03-01 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.571628e+06 3.624495e+06 1861.250866 POLYGON ((70.14495 32.59374, 70.14822 32.59793...
208515 802583 2021-02-28 59 2 2021 2021-03-04 5 48 10.303616 9.600000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.555412e+06 3.732911e+06 19467.134094 POLYGON ((70.75005 33.56041, 70.75003 33.56041...
208341 802039 2021-02-08 39 2 2021 2021-02-10 3 10 2.146587 3.333333 ... Savannas Tree cover 10-30% (canopy>2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.532709e+06 3.738007e+06 5567.752598 POLYGON ((70.54248 33.60624, 70.54589 33.61041...
208475 802426 2021-02-23 54 2 2021 2021-03-08 14 58 12.450203 4.142857 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.535026e+06 3.737080e+06 21320.384960 POLYGON ((70.56749 33.60624, 70.56249 33.60624...
208993 804627 2021-03-29 88 3 2021 2021-03-29 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.537342e+06 3.739397e+06 1861.250866 POLYGON ((70.60457 33.62707, 70.60800 33.63126...
208617 803704 2021-03-18 77 3 2021 2021-03-18 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.536879e+06 3.739397e+06 1861.250866 POLYGON ((70.59956 33.62707, 70.60299 33.63126...
208526 802695 2021-03-01 60 3 2021 2021-03-04 4 24 5.151808 6.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.568848e+06 3.624959e+06 7421.003464 POLYGON ((70.12517 32.59374, 70.12022 32.59374...
207945 801397 2021-01-03 3 1 2021 2021-01-04 2 8 1.717269 4.000000 ... Open Shrublands Dominated by woody perennials (1-2m height)10-... IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.526223e+06 3.682409e+06 4641.127165 POLYGON ((70.07043 33.11457, 70.06545 33.11457...
208518 802595 2021-02-28 59 2 2021 2021-03-02 3 172 36.921292 57.333333 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.526686e+06 3.719011e+06 25953.512126 POLYGON ((70.34514 33.44374, 70.34017 33.44374...
208176 801763 2021-01-23 23 1 2021 2021-01-23 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.513250e+06 3.726887e+06 1861.250866 POLYGON ((70.25275 33.51457, 70.25615 33.51876...
208006 801519 2021-01-11 11 1 2021 2021-01-13 3 56 12.020886 18.666667 ... Open Shrublands Dominated by woody perennials (1-2m height)10-... IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.515567e+06 3.727351e+06 15752.632362 POLYGON ((70.26936 33.51041, 70.26436 33.51041...
208594 803272 2021-03-09 68 3 2021 2021-03-17 9 150 32.198801 16.666667 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.505374e+06 3.729204e+06 23173.635826 POLYGON ((70.21777 33.51457, 70.22115 33.51874...
208173 801758 2021-01-23 23 1 2021 2021-01-23 1 2 0.429317 2.000000 ... Open Shrublands Dominated by woody perennials (1-2m height)10-... IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.514177e+06 3.729204e+06 1861.250866 POLYGON ((70.27967 33.53541, 70.28308 33.53959...
208508 802532 2021-02-27 58 2 2021 2021-03-05 7 94 20.177915 13.428571 ... Savannas Tree cover 10-30% (canopy>2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.504911e+06 3.732911e+06 16687.257795 POLYGON ((70.21196 33.58126, 70.21198 33.58126...
208081 801626 2021-01-15 15 1 2021 2021-01-23 9 88 18.889963 9.777778 ... Savannas Tree cover 10-30% (canopy>2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.507690e+06 3.733837e+06 14834.006929 POLYGON ((70.22987 33.54791, 70.22985 33.54791...
208031 801559 2021-01-12 12 1 2021 2021-01-12 1 2 0.429317 2.000000 ... Savannas Tree cover 10-30% (canopy>2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.505837e+06 3.733837e+06 1861.250866 POLYGON ((70.22356 33.57707, 70.22697 33.58126...
207930 801369 2021-01-02 2 1 2021 2021-01-04 3 18 3.863856 6.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.507690e+06 3.734764e+06 6494.378031 POLYGON ((70.24696 33.58124, 70.24198 33.58124...
208602 803404 2021-03-12 71 3 2021 2021-03-14 3 6 1.287952 2.000000 ... Savannas Tree cover 10-30% (canopy>2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.504911e+06 3.735227e+06 3714.501732 POLYGON ((70.22534 33.58541, 70.22034 33.58541...
207967 801458 2021-01-07 7 1 2021 2021-01-07 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.521126e+06 3.741713e+06 1861.250866 POLYGON ((70.44647 33.64791, 70.44989 33.65209...
208092 801640 2021-01-16 16 1 2021 2021-01-26 11 132 28.334945 12.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.494254e+06 3.743103e+06 47265.897086 POLYGON ((70.16635 33.66041, 70.16975 33.66457...
207935 801379 2021-01-02 2 1 2021 2021-01-05 4 78 16.743377 19.500000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.494254e+06 3.748663e+06 15760.632362 POLYGON ((70.21019 33.68957, 70.20520 33.68957...
208892 804375 2021-03-27 86 3 2021 2021-03-27 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.536416e+06 3.739860e+06 1861.250866 POLYGON ((70.59797 33.63124, 70.60140 33.63543...
208053 801587 2021-01-13 13 1 2021 2021-01-17 5 14 3.005221 2.800000 ... Savannas Tree cover 10-30% (canopy>2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.521126e+06 3.741250e+06 6494.378031 POLYGON ((70.44966 33.63957, 70.45307 33.64374...
208214 801831 2021-01-29 29 1 2021 2021-01-29 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.568384e+06 3.743103e+06 1861.250866 POLYGON ((70.96731 33.66041, 70.97076 33.66459...
208435 802285 2021-02-16 47 2 2021 2021-02-22 7 18 3.863856 2.571429 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.554022e+06 3.742177e+06 9274.254331 POLYGON ((70.81717 33.66043, 70.81374 33.65626...
207949 801406 2021-01-04 4 1 2021 2021-01-10 7 36 7.727712 5.142857 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.542902e+06 3.743103e+06 11127.505197 POLYGON ((70.70518 33.65207, 70.70516 33.65207...
208450 802325 2021-02-18 49 2 2021 2021-02-18 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.568848e+06 3.743567e+06 1861.250866 POLYGON ((70.97575 33.66457, 70.97921 33.66876...
208332 802019 2021-02-07 38 2 2021 2021-02-07 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.538732e+06 3.743567e+06 1861.250866 POLYGON ((70.65035 33.66457, 70.65379 33.66876...
208728 804063 2021-03-24 83 3 2021 2021-03-24 1 4 0.858635 4.000000 ... Croplands At least 60% of area is cultivated cropland IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.529929e+06 3.757003e+06 3714.501732 POLYGON ((70.65463 33.78541, 70.65807 33.78957...
211353 815448 2021-06-21 172 6 2021 2021-06-28 8 92 19.748598 11.500000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 18.0 Sulaiman Range alpine meadows WWF Terrestrial Ecoregions of the World 6.539659e+06 3.776925e+06 15760.632362 POLYGON ((70.88970 33.94791, 70.88468 33.94791...
211072 814599 2021-06-02 153 6 2021 2021-06-02 1 2 0.429317 2.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.556338e+06 3.785728e+06 1861.250866 POLYGON ((71.15576 34.04374, 71.15927 34.04793...
211178 814984 2021-06-10 161 6 2021 2021-06-13 4 32 6.869078 8.000000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.535026e+06 3.818160e+06 16679.257795 POLYGON ((71.16179 34.32707, 71.17109 34.33892...
208367 802072 2021-02-10 41 2 2021 2021-02-13 4 58 12.450203 14.500000 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.487305e+06 3.749590e+06 17613.883228 MULTIPOLYGON (((70.15732 33.72293, 70.15656 33...
208478 802439 2021-02-23 54 2 2021 2021-03-01 7 12 2.575904 1.714286 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.490548e+06 3.750980e+06 5567.752598 POLYGON ((70.19075 33.72707, 70.18574 33.72707...
208386 802111 2021-02-11 42 2 2021 2021-02-16 6 80 17.172694 13.333333 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.482208e+06 3.751906e+06 20393.759527 POLYGON ((70.08233 33.73541, 70.08573 33.73957...
208509 802535 2021-02-27 58 2 2021 2021-03-05 7 22 4.722491 3.142857 ... Savannas Tree cover 10-30% (canopy>2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.500741e+06 3.754223e+06 10200.879764 POLYGON ((70.32488 33.75624, 70.32829 33.76041...

42 rows × 30 columns

In [11]:
# Plot F.A.T.A. fires (2021)
fig, ax = plt.subplots(figsize=(10,20))
fata.plot(color='grey', edgecolor='black', ax=ax)
fata_fires.plot(color='red', edgecolor='black', ax=ax)
ax.set(title="F.A.T.A fires - 2021")
plt.show()
No description has been provided for this image
In [15]:
# Largest fire 2021
big_fire = fata_fires[fata_fires["tot_pix"]==172]
big_fire
Out[15]:
id ig_date ig_day ig_month ig_year last_date event_dur tot_pix tot_ar_km2 fsr_px_dy ... lc_name lc_desc lc_type eco_mode eco_name eco_type ig_utm_x ig_utm_y tot_perim geometry
208518 802595 2021-02-28 59 2 2021 2021-03-02 3 172 36.921292 57.333333 ... Grasslands Dominated by herbaceous annuals (<2m) IGBP global vegetation classification scheme 7.0 Baluchistan xeric woodlands WWF Terrestrial Ecoregions of the World 6.526686e+06 3.719011e+06 25953.512126 POLYGON ((70.34514 33.44374, 70.34017 33.44374...

1 rows × 30 columns

In [16]:
fata_fires.explore()
Out[16]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [12]:
# Create a path to the data
fata_dir = os.path.join(pathlib.Path.home(), 'fata-data')

# Make the data directory
os.makedirs(fata_dir, exist_ok=True)

fata_dir
Out[12]:
'/home/jovyan/fata-data'
In [11]:
# Initialize AppeearsDownloader for MODIS NDVI data
ndvi_downloader = eaapp.AppeearsDownloader(
    download_key='fata-ndvi',
    ea_dir=fata_dir,
    product='MOD13Q1.061',
    layer='_250m_16_days_NDVI',
    start_date="07-01",
    end_date="07-31",
    recurring=True,
    year_range=[2019, 2023],
    polygon=fata
)

ndvi_downloader.download_files(cache=True)
In [13]:
# Get a list of NDVI tif file paths
fata_paths = sorted(glob(os.path.join(fata_dir, 'fata-ndvi', '*', '*NDVI*.tif')))
print(fata_paths)
len(fata_paths)
['/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2019177_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2019193_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2019209_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2020177_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2020193_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2020209_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2021177_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2021193_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2021209_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2022177_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2022193_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2022209_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2023177_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2023193_aid0001.tif', '/home/jovyan/fata-data/fata-ndvi/MOD13Q1.061_2019167_to_2023212/MOD13Q1.061__250m_16_days_NDVI_doy2023209_aid0001.tif']
Out[13]:
15
In [14]:
scale_factor = 10000
doy_start = -19
doy_end = -12
In [15]:
# Build data list of data arrays
fata_das = []
for fata_path in fata_paths:
    # Get date from file name
    doy = fata_path[doy_start:doy_end]
    date = pd.to_datetime(doy, format='%Y%j')

    # Open dataset
    da = rxr.open_rasterio(fata_path, masked=True).squeeze()

    # Add date dimension and clean up metadata
    da = da.assign_coords({'date': date})
    da = da.expand_dims({'date': 1})
    da.name = 'NDVI'

    # Multiple by scale factor
    da = da / scale_factor

    # Prepare for concatenation
    fata_das.append(da)

len(fata_das)
Out[15]:
15
In [16]:
# Combine into single array by date
fata_da = xr.combine_by_coords(fata_das, coords=['date'])
fata_da
Out[16]:
<xarray.Dataset>
Dimensions:      (x: 1230, y: 1870, date: 15)
Coordinates:
    band         int64 1
  * x            (x) float64 69.24 69.24 69.24 69.24 ... 71.79 71.79 71.8 71.8
  * y            (y) float64 34.96 34.96 34.96 34.96 ... 31.07 31.07 31.07 31.07
    spatial_ref  int64 0
  * date         (date) datetime64[ns] 2019-06-26 2019-07-12 ... 2023-07-28
Data variables:
    NDVI         (date, y, x) float32 0.6893 0.6074 0.6154 ... 0.0442 0.0442
xarray.Dataset
    • x: 1230
    • y: 1870
    • date: 15
    • band
      ()
      int64
      1
      array(1)
    • x
      (x)
      float64
      69.24 69.24 69.24 ... 71.8 71.8
      array([69.238542, 69.240625, 69.242708, ..., 71.794792, 71.796875, 71.798958])
    • y
      (y)
      float64
      34.96 34.96 34.96 ... 31.07 31.07
      array([34.961458, 34.959375, 34.957292, ..., 31.071875, 31.069792, 31.067708])
    • spatial_ref
      ()
      int64
      0
      crs_wkt :
      GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]
      semi_major_axis :
      6378137.0
      semi_minor_axis :
      6356752.314245179
      inverse_flattening :
      298.257223563
      reference_ellipsoid_name :
      WGS 84
      longitude_of_prime_meridian :
      0.0
      prime_meridian_name :
      Greenwich
      geographic_crs_name :
      WGS 84
      horizontal_datum_name :
      World Geodetic System 1984
      grid_mapping_name :
      latitude_longitude
      spatial_ref :
      GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]
      GeoTransform :
      69.23749999379734 0.0020833333331466974 0.0 34.96249999686788 0.0 -0.0020833333331466974
      array(0)
    • date
      (date)
      datetime64[ns]
      2019-06-26 ... 2023-07-28
      array(['2019-06-26T00:00:00.000000000', '2019-07-12T00:00:00.000000000',
             '2019-07-28T00:00:00.000000000', '2020-06-25T00:00:00.000000000',
             '2020-07-11T00:00:00.000000000', '2020-07-27T00:00:00.000000000',
             '2021-06-26T00:00:00.000000000', '2021-07-12T00:00:00.000000000',
             '2021-07-28T00:00:00.000000000', '2022-06-26T00:00:00.000000000',
             '2022-07-12T00:00:00.000000000', '2022-07-28T00:00:00.000000000',
             '2023-06-26T00:00:00.000000000', '2023-07-12T00:00:00.000000000',
             '2023-07-28T00:00:00.000000000'], dtype='datetime64[ns]')
    • NDVI
      (date, y, x)
      float32
      0.6893 0.6074 ... 0.0442 0.0442
      array([[[0.6893, 0.6074, 0.6154, ..., 0.4311, 0.3889, 0.4265],
              [0.6362, 0.659 , 0.6568, ..., 0.3889, 0.3889, 0.3889],
              [0.642 , 0.6306, 0.6306, ..., 0.4253, 0.4239, 0.4575],
              ...,
              [0.1456, 0.1456, 0.1107, ..., 0.0502, 0.0544, 0.0543],
              [0.1091, 0.1091, 0.0711, ..., 0.0477, 0.0543, 0.0555],
              [0.1038, 0.0729, 0.0729, ..., 0.0483, 0.0488, 0.0488]],
      
             [[0.6664, 0.5904, 0.6547, ..., 0.4585, 0.4585, 0.4732],
              [0.5904, 0.6467, 0.6419, ..., 0.4485, 0.4625, 0.4625],
              [0.6127, 0.6224, 0.6224, ..., 0.4734, 0.5024, 0.5412],
              ...,
              [0.1674, 0.1674, 0.1192, ..., 0.06  , 0.06  , 0.0642],
              [0.1225, 0.0959, 0.0881, ..., 0.0543, 0.0498, 0.0498],
              [0.1225, 0.0887, 0.0887, ..., 0.0548, 0.0498, 0.0498]],
      
             [[0.6526, 0.6316, 0.6264, ..., 0.6513, 0.6513, 0.7442],
              [0.6455, 0.6547, 0.6547, ..., 0.614 , 0.7341, 0.7341],
              [0.6353, 0.6054, 0.6054, ..., 0.614 , 0.7562, 0.7254],
              ...,
      ...
              [0.2038, 0.2038, 0.2038, ..., 0.06  , 0.06  , 0.0702],
              [0.1486, 0.1272, 0.0964, ..., 0.0538, 0.0702, 0.0702],
              [0.1355, 0.0891, 0.0891, ..., 0.0538, 0.0499, 0.0499]],
      
             [[0.5534, 0.5057, 0.5133, ..., 0.4965, 0.4578, 0.5193],
              [0.5528, 0.5138, 0.5202, ..., 0.4531, 0.4399, 0.4399],
              [0.5462, 0.5302, 0.5302, ..., 0.4858, 0.4854, 0.4836],
              ...,
              [0.2142, 0.2142, 0.1444, ..., 0.0445, 0.0533, 0.0555],
              [0.1627, 0.1627, 0.1168, ..., 0.0459, 0.0566, 0.0597],
              [0.1254, 0.1069, 0.1069, ..., 0.0479, 0.0435, 0.0435]],
      
             [[0.6312, 0.5675, 0.5786, ..., 0.7258, 0.721 , 0.6796],
              [0.6154, 0.6269, 0.6311, ..., 0.721 , 0.7144, 0.7144],
              [0.6104, 0.5632, 0.5632, ..., 0.7026, 0.6885, 0.7068],
              ...,
              [0.2075, 0.2075, 0.1519, ..., 0.0588, 0.0588, 0.0636],
              [0.1756, 0.1724, 0.1389, ..., 0.0522, 0.052 , 0.0521],
              [0.1269, 0.1189, 0.1189, ..., 0.0467, 0.0442, 0.0442]]],
            dtype=float32)
    • x
      PandasIndex
      PandasIndex(Index([69.23854166046391, 69.24062499379706,  69.2427083271302,
             69.24479166046335,  69.2468749937965, 69.24895832712964,
             69.25104166046279, 69.25312499379594, 69.25520832712908,
             69.25729166046223,
             ...
             71.78020832690288, 71.78229166023603, 71.78437499356917,
             71.78645832690232, 71.78854166023547, 71.79062499356861,
             71.79270832690176,  71.7947916602349, 71.79687499356805,
              71.7989583269012],
            dtype='float64', name='x', length=1230))
    • y
      PandasIndex
      PandasIndex(Index([  34.9614583302013, 34.959374996868156,  34.95729166353501,
              34.95520833020186, 34.953124996868716,  34.95104166353557,
              34.94895833020242, 34.946874996869276,  34.94479166353613,
              34.94270833020298,
             ...
             31.086458330548446,   31.0843749972153, 31.082291663882152,
             31.080208330549006,  31.07812499721586, 31.076041663882712,
             31.073958330549566,  31.07187499721642, 31.069791663883272,
             31.067708330550126],
            dtype='float64', name='y', length=1870))
    • date
      PandasIndex
      PandasIndex(DatetimeIndex(['2019-06-26', '2019-07-12', '2019-07-28', '2020-06-25',
                     '2020-07-11', '2020-07-27', '2021-06-26', '2021-07-12',
                     '2021-07-28', '2022-06-26', '2022-07-12', '2022-07-28',
                     '2023-06-26', '2023-07-12', '2023-07-28'],
                    dtype='datetime64[ns]', name='date', freq=None))
In [17]:
# Compute the difference in NDVI before and 2021
fata_diff = (
    fata_da
        .sel(date=slice('2021', '2023'))
        .mean('date')
        .NDVI 
   - fata_da
        .sel(date=slice('2019', '2021'))
        .mean('date')
        .NDVI
)

fata_diff
Out[17]:
<xarray.DataArray 'NDVI' (y: 1870, x: 1230)>
array([[-0.03661114, -0.03126669, -0.03695565, ...,  0.02910003,
         0.02556667,  0.01021111],
       [-0.03023332, -0.03587776, -0.04015559, ...,  0.02942222,
         0.00923336,  0.00923336],
       [-0.02385557, -0.03790003, -0.03790003, ...,  0.03593332,
         0.01067775,  0.01486659],
       ...,
       [ 0.02211113,  0.02211113,  0.01124446, ..., -0.0048    ,
        -0.00538889,  0.00071111],
       [ 0.01797779,  0.02203332,  0.0165    , ..., -0.00223334,
        -0.00221111,  0.00073333],
       [ 0.01944444,  0.01374444,  0.01374444, ..., -0.00487778,
        -0.00511111, -0.00511111]], dtype=float32)
Coordinates:
    band         int64 1
  * x            (x) float64 69.24 69.24 69.24 69.24 ... 71.79 71.79 71.8 71.8
  * y            (y) float64 34.96 34.96 34.96 34.96 ... 31.07 31.07 31.07 31.07
    spatial_ref  int64 0
xarray.DataArray
'NDVI'
  • y: 1870
  • x: 1230
  • -0.03661 -0.03127 -0.03696 -0.05184 ... -0.004878 -0.005111 -0.005111
    array([[-0.03661114, -0.03126669, -0.03695565, ...,  0.02910003,
             0.02556667,  0.01021111],
           [-0.03023332, -0.03587776, -0.04015559, ...,  0.02942222,
             0.00923336,  0.00923336],
           [-0.02385557, -0.03790003, -0.03790003, ...,  0.03593332,
             0.01067775,  0.01486659],
           ...,
           [ 0.02211113,  0.02211113,  0.01124446, ..., -0.0048    ,
            -0.00538889,  0.00071111],
           [ 0.01797779,  0.02203332,  0.0165    , ..., -0.00223334,
            -0.00221111,  0.00073333],
           [ 0.01944444,  0.01374444,  0.01374444, ..., -0.00487778,
            -0.00511111, -0.00511111]], dtype=float32)
    • band
      ()
      int64
      1
      array(1)
    • x
      (x)
      float64
      69.24 69.24 69.24 ... 71.8 71.8
      array([69.238542, 69.240625, 69.242708, ..., 71.794792, 71.796875, 71.798958])
    • y
      (y)
      float64
      34.96 34.96 34.96 ... 31.07 31.07
      array([34.961458, 34.959375, 34.957292, ..., 31.071875, 31.069792, 31.067708])
    • spatial_ref
      ()
      int64
      0
      crs_wkt :
      GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]
      semi_major_axis :
      6378137.0
      semi_minor_axis :
      6356752.314245179
      inverse_flattening :
      298.257223563
      reference_ellipsoid_name :
      WGS 84
      longitude_of_prime_meridian :
      0.0
      prime_meridian_name :
      Greenwich
      geographic_crs_name :
      WGS 84
      horizontal_datum_name :
      World Geodetic System 1984
      grid_mapping_name :
      latitude_longitude
      spatial_ref :
      GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]
      GeoTransform :
      69.23749999379734 0.0020833333331466974 0.0 34.96249999686788 0.0 -0.0020833333331466974
      array(0)
    • x
      PandasIndex
      PandasIndex(Index([69.23854166046391, 69.24062499379706,  69.2427083271302,
             69.24479166046335,  69.2468749937965, 69.24895832712964,
             69.25104166046279, 69.25312499379594, 69.25520832712908,
             69.25729166046223,
             ...
             71.78020832690288, 71.78229166023603, 71.78437499356917,
             71.78645832690232, 71.78854166023547, 71.79062499356861,
             71.79270832690176,  71.7947916602349, 71.79687499356805,
              71.7989583269012],
            dtype='float64', name='x', length=1230))
    • y
      PandasIndex
      PandasIndex(Index([  34.9614583302013, 34.959374996868156,  34.95729166353501,
              34.95520833020186, 34.953124996868716,  34.95104166353557,
              34.94895833020242, 34.946874996869276,  34.94479166353613,
              34.94270833020298,
             ...
             31.086458330548446,   31.0843749972153, 31.082291663882152,
             31.080208330549006,  31.07812499721586, 31.076041663882712,
             31.073958330549566,  31.07187499721642, 31.069791663883272,
             31.067708330550126],
            dtype='float64', name='y', length=1870))
In [21]:
# Plot the difference
fig, ax = plt.subplots(figsize=(12,20))

fata_diff.plot(x='x', y='y', cmap='PiYG', robust=True, ax=ax)
fata.plot(edgecolor='black', color='none', ax=ax)
fata_fires.plot(edgecolor='black', color='none', ax=ax)
plt.title('NDVI Difference (July)\nFederally Administered Tribal Areas, Pakistan\n2021-2023 vs. 2019-2021', fontsize=20)
plt.show()
No description has been provided for this image
The Kernel crashed while executing code in the current cell or a previous cell. 

Please review the code in the cell(s) to identify a possible cause of the failure. 

Click <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. 

View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details.
In [ ]:
%%capture
%%bash
jupyter nbconvert *.ipynb --to html