diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..e6422e4 --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +max-line-length = 100 +per-file-ignores = __init__.py:F401 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f1980e --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# secrets +.env + +# data +.data/* + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class +.ipynb_checkpoints + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST +site/ + +# keep all .gitkeep files and their parent folders +!.gitkeep \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3ba0fe4 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +freeze: + pip freeze --exclude-editable | grep -v "file:///" > requirements.txt + +verify: + isort --check-only . + black --diff --check . + flake8 . + pytest . + +clean: + rm -r *.egg-info 2> /dev/null || true + py3clean . \ No newline at end of file diff --git a/README.md b/README.md index e69de29..739d51c 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,35 @@ +# Bare soil analysis + +Analysis of bare soil in fields across England. + +## Inputs + +Makes use of the following public data sources: + +- Satellite reflectance data at 10m² resolution from ESA [Sentinel 2A](https://scihub.copernicus.eu). +- Land cover data at 10m² resolution from [UK CEH](https://catalogue.ceh.ac.uk/documents/017313c6-954b-4343-8784-3d61aa6e44da). +- Rainfall at 1km² resolution from Met Office [HadUK-Grid] (https://catalogue.ceda.ac.uk/uuid/4dc8450d889a491ebb20e724debe2dfb). +- LIDAR at 1m² from the Environment Agency's [National LIDAR Programme](https://www.data.gov.uk/dataset/f0db0249-f17b-4036-9e65-309148c97ce4/national-lidar-programme). + + +## Objective + +The objective of this analysis is to build a model to detemine the best predictors of bare soil by building an explanatory model in python. +For the purposes of this study bare soil will be defined as where the Normalised Difference Vegetation Index (NDVI) is below 0.2, as calculated from Sentinel 2A red (B04) and near infared (B08) bands. + +## Approach + +The dependent variable will be NDVI, or where NDVI < 0.2. + +The independant variables will include features engineered from the following aspects: + +- Time, e.g. year, day of year +- Land use +- Topography, e.g. slope, altitude, adjacent slopes +- Adjacent vegetation +- Proximity to water courses +- Rainfall + +A raster dataset will be created for a location in England and layers will be derived from the above datasets. +A best model will be selected through feature engineering and model selection. +Results will be discussed. \ No newline at end of file diff --git a/bare_soils_analysis/__init__.py b/bare_soils_analysis/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/data/0_raw/.gitkeep b/data/0_raw/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/data/1_proc/.gitkeep b/data/1_proc/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7e490d4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,35 @@ +affine==2.4.0 +attrs==22.2.0 +certifi==2022.12.7 +charset-normalizer==3.1.0 +click==8.1.3 +click-plugins==1.1.1 +cligj==0.7.2 +contextily==1.3.0 +contourpy==1.0.7 +cycler==0.11.0 +fonttools==4.39.0 +geographiclib==2.0 +geopy==2.3.0 +idna==3.4 +joblib==1.2.0 +kiwisolver==1.4.4 +matplotlib==3.7.1 +mercantile==1.2.1 +numpy==1.24.2 +packaging==23.0 +pandas==1.5.3 +Pillow==9.4.0 +pyparsing==3.0.9 +pyproj==3.4.1 +python-dateutil==2.8.2 +pytz==2022.7.1 +rasterio==1.3.6 +requests==2.28.2 +rioxarray==0.13.4 +seaborn==0.12.2 +six==1.16.0 +snuggs==1.4.7 +urllib3==1.26.14 +xarray==2023.2.0 +xyzservices==2023.2.0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7f3b2c3 --- /dev/null +++ b/setup.py @@ -0,0 +1,44 @@ +from setuptools import find_packages, setup + +__title__ = "bare_soil_analysis" +__description__ = "Analysis of bare soil across England" +__author_email__ = "Edward Burrows" +__author__ = "burrowsej@gmail.com" +__version__ = "0.1" +__licence__ = "MIT" + +REQUIRED_PACKAGES = [ + "rasterio>=1.3.6", + "pandas>=1.5.3", + "seaborn>=0.12.2", + "contextily>=1.3.0", +] + +TEST_PACKAGES = [ + "black>=23.1.0", + "flake8>=6.0.0", + "isort>=5.12.0", + "pytest>=7.2.1", +] + +DEV_PACKAGES = [ + *TEST_PACKAGES, + "pylint>=2.16.2", + "ipython>=8.10.0", + "ipykernel>=6.21.2", + "ipywidgets>=8.0.4", + "dbx>=0.7.0", +] + + +setup( + name=__title__, + description=__description__, + version=__version__, + packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), + install_requires=REQUIRED_PACKAGES, + extras_require={"test": TEST_PACKAGES, "dev": DEV_PACKAGES}, + author=__author__, + author_email=__author_email__, + licence=__licence__, +)