########################################################################################################
########### DESCRIPTION OF THE CONTENT OF THE REPOSITORY AND HOW TO USE IT #############################
########################################################################################################

This repository contains data and scripts to reproduce the work described in the research manuscript called "A generic algorithm to automatically classify urban fabric according to the Local Climate Zone system: implementation in GeoClimate 0.0.1 and application to French cities". 

In a first part, the content of the repository is described. The second part is dedicated to a step by step methodology to reproduce the results of the manuscript.




########################################################################################################
# CONTENT OF THE REPOSITORY #########################################################################
########################################################################################################

This repository contains 2 folders: "Data" and “Scripts”.

The folder “Data” contains two folders (“bdtopo_2_2” and “osm”) and one .csv file (“lcz_classes.csv”). The two folders contain output files from GeoClimate v0.0.1 (https://zenodo.org/record/6372337) for each dataset type (BDTopo v2.2 and OSM) and for each city studied in the manuscript. For each combination {dataset, city}, the output files consist in two .geojson files: “rsu_lcz.geojson” contains the RSU geometries and their corresponding LCZ type and other statistics resulting from the classification algorithm and “rsu_indicators.geojson” contains the RSU geometries and their corresponding set of indicators characterizing the content and the size of the unit.

In the “Script” folder, there is one .R script called “createFigures.R” and one .py script called “calculate_statistics.py”. Their names are quite talkative about what they do:
    - “createFigures.R” plots the Figures 5, 6 (Comparison of LCZ generated for city i by the GeoClimate method using BDT and OSM datasets) and all the ones being in the Annex. For this purpose it uses the R package lczexplore (https://zenodo.org/record/7646866#.Y-5PmNLMKEI).
    - “calculate_statistics.py” uses “rsu_lcz.geojson” files to calculate the fraction of undefined land for each city and each dataset.


########################################################################################################
# HOW TO REPRODUCE THE RESULTS #########################################################################
########################################################################################################

#### 1. Download this repository

Download the full content of this repository and save it on your computer.



#### 2. Download GeoClimate v0.0.1 and Java

If you want to recalculate all LCZ and indicators for each city and each dataset, you need to download the “geoClimate-0.0.1.jar” at https://zenodo.org/record/6372337.

Make sure you have Java installed on your computer. If this is not the case, please install the right version depending your OS: https://java.com/en/download/windows_manual.jsp for Windows, https://java.com/en/download/ for Linux or https://www.java.com/en/download/apple.jsp for MacOS. Make sure you download the version (32 or 64 bits) consistent with your system (even though most computers are nowaday 64 bits).




#### 3. Execute GeoClimate calculations

If you want to recalculate all LCZ and indicators for each city and each dataset, you first need to download BDTopo data (OSM data are downloaded automatically when running GeoClimate). You can find this data at https://geoservices.ign.fr/actualites/2023-01-23-bdtopo or http://data.cquest.org/ign/bdtopo/. You will be able to download all data for an entire department. The needed ones for the manuscript are 01, 17, 21, 31, 35, 44, 56, 68, 71, 73, 75, 92.

Then create 2 .json configuration file (one for each dataset) according to your operating system using the GeoClimate documentation (https://zenodo.org/record/6372337/files/GeoClimate_0.0.1_documentation.pdf?download=1):
    - For Linux and MacOS users, go to p. 34 and click on the “CLI” link corresponding to the dataset you want to apply (OSM or BDT).
    - For Windows users, go to p.47 and click on the “CLI” link corresponding to the dataset you want to apply (OSM or BDT).

You will there find an example of configuration file. Fill in the configuration file with the right computer paths (the one you want) and the list of cities (for OSM) or insee codes (for BDT) you want to calculate (names and insee code in the manuscript Table 2).

Then run GeoClimate according to the Tutorial explanations.



#### 4. Create manuscript figures using the lczexplore R package

To calculate all figures used in the manuscript, you then need to download and install the lczexplore R package (https://zenodo.org/record/7646866). Download the source files, extract it and follow the section “Installation” of the Readme.md file.

Once this is performed, open the “createFigures.R” located in the “Scripts” folder of the repository downloaded at step 1 and modify the paths to be consistent with your local paths where are the data.

You can then run the comparison, all figures should be saved in the “Data” folder of the repository downloaded at step 1.



#### 5. Calculate statistics

To calculate statistics about undefined lands in OSM and BDT (values used in the manuscript), you need a Python installation containing “geopandas”, “pandas” and “pathlib” libraries.

We recommend using conda to create a new environment and then install the needed libraries. If your are not familiar with Python, we strongly recommend you to install anaconda (https://www.anaconda.com/) to deal with libraries and related dependencies. Once Anaconda is install, open a command prompt in the folder of the downloaded repository and then paste:
	
conda create --name geoclimate_lcz
conda activate geoclimate_lcz
conda config --add channels conda-forge
conda install pandas geopandas pathlib

The first command creates a new anaconda environment, the second activate it, the third add a channel to download some Python libraries and the last install all required libraries.

Last, to execute the Python script “calculate_statistics.py” located in the “Scripts” folder of the repository downloaded at step 1, pen a command prompt in the “Scripts” folder of the downloaded repository and then paste:

conda activate geoclimate_lcz
python calculate_statistics.py

The results will be displayed in the command prompt.
