import plotly.express as px
import pandas as pd
import plotly
distarea = pd.read_csv('distarea.csv')
distarea['area'] = distarea['area'] * 1.0e-6
distarea.rename(columns = {'area':'area2'}, inplace = True)
# Year ---> 2010
df2010 = pd.read_csv('stat2010.csv', header=None)
df2010['year']='2010'
# print(df2010.head())
# Year ---> 2014
df2014 = pd.read_csv('stat2014.csv', header=None)
df2014['year']='2014'
# Year ---> 2018
df2018 = pd.read_csv('stat2018.csv', header=None)
df2018['year']='2018'
# Year ---> 2022
df2022 = pd.read_csv('stat2022.csv', header=None)
df2022['year']='2022'
df_all = [df2010, df2014, df2018, df2022]
df = pd.concat(df_all)
df.drop(1, inplace=True, axis=1)
df.drop(2, inplace=True, axis=1)
df.rename(columns = {0:'lu_id', 3:'district', 4:'area'}, inplace = True)
# df['area'] = df['area'].str.rstrip('%').astype('float')
df['area'] = df['area'] * 1.0e-6
result = df.join(distarea.set_index('district'), on = 'district', how='left')
result['pc'] = result['area']/result['area2']*100
print(result.head())
for i in range(1,7):
print(i)
df_n = result[result['lu_id']==i]
fig = px.bar(df_n, x = 'district', y ='pc', color = 'year', barmode='group',
labels={'pc':'area(%)'},
title = f"Land Use Change(LU = {i})")
fname = f'lu_{i}.png'
fig.write_image(fname)1 Analysis of Landuse and Land Cover Change Using Grass GIS
1.1 Background
Landuse and Land cover change is one of major area of GIS analysis which is used for various purposes. This analysis was done as a practice work to learn the Raster analysis using GIS(see Mallupattu (2013)). So on.
1.2 Data and Output
In this analysis MODIS land surface reflectance data which is provided by USGS freely was used. The data for four different years but the same date was used to understand the landuse change in similar season for last one decade. The detail of the data used is listed below.
- Month: November first week
- Year: 2010, 2014, 2018, 2022
- Vector data of Province-7 (Sudur Paschim) and its districts
- So on
NDVI (Normalized Difference Vegetation Index) was produced for each year compared using graph. So on.
1.2.1 MODIS Land surface Reflectance
Refer relevant articles and mention source of information. Explain in a couple of sentences about downloading the data, properties and projection (CRS) of downloaded data.
1.2.2 NDVI
Refer relevant articles and mention source of information.
1.3 Methodology
Grass GIS was used for this project. So on.
1.3.1 Creating Location in Grass GIS
Explain.
1.3.2 Importing raster and vector data
MODIS data was merged, clipped and then transformed to WGS84 Geographic Coordinate system.
Following data were imported to Grass.
- Clipped and projected Modis data of each band (Red and NIR)
- Vector data of Districts
1.3.3 Calculation of NDVI
Following Grass GIS command was used to calculate NDVI for each of the selected years. - i.vi red=clip_b1 …..etc (complete)
1.3.4 Reclassification of NDVI
Detail with grass command
1.3.5 Conversion of district data from vector to raster
Explain in detail: why & how.
1.3.6 Statistics of NDVI with respect to Districts
- Command
- Output
1.3.7 Creation of Graphs
Using Excel/Calc/python or others
python code for creating graphs (Note: You need to run the following code in Grass-GIS to use the following python program: ndvi-reclass should be first raster in the input)
Grass Code
r.stats -a -l -n --overwrite input=ndvi.reclass.2022@PERMANENT,state7dist@PERMANENT output=E:\GIS_Exercise\Exe07_Raster_analysis\stat2022.csv separator=comma
- Python program
1.4 Output
- Show the graphs