|
| 1 | +<div id="top"></div> |
| 2 | +<!-- |
| 3 | +*** Thanks for checking out the Best-README-Template. If you have a suggestion |
| 4 | +*** that would make this better, please fork the repo and create a pull request |
| 5 | +*** or simply open an issue with the tag "enhancement". |
| 6 | +*** Don't forget to give the project a star! |
| 7 | +*** Thanks again! Now go create something AMAZING! :D |
| 8 | +--> |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +<!-- PROJECT SHIELDS --> |
| 13 | +<!-- |
| 14 | +*** I'm using markdown "reference style" links for readability. |
| 15 | +*** Reference links are enclosed in brackets [ ] instead of parentheses ( ). |
| 16 | +*** See the bottom of this document for the declaration of the reference variables |
| 17 | +*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use. |
| 18 | +*** https://www.markdownguide.org/basic-syntax/#reference-style-links |
| 19 | +--> |
| 20 | +<!-- [![Contributors][contributors-shield]][contributors-url] |
| 21 | +[![Forks][forks-shield]][forks-url] |
| 22 | +[![Stargazers][stars-shield]][stars-url] |
| 23 | +[![Issues][issues-shield]][issues-url] |
| 24 | +[![MIT License][license-shield]][license-url] |
| 25 | +[![LinkedIn][linkedin-shield]][linkedin-url] --> |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +<!-- PROJECT LOGO --> |
| 30 | +<br /> |
| 31 | +<div align="center"> |
| 32 | + <a href="https://github.com/othneildrew/Best-README-Template"> |
| 33 | + <img src="images/satextractor.png" alt="Logo"> |
| 34 | + </a> |
| 35 | + |
| 36 | + <h3 align="center">SatExtractor</h3> |
| 37 | + |
| 38 | + <p align="center"> |
| 39 | + Build, deploy and extract satellite public constellations with one command line. |
| 40 | + <br /> |
| 41 | + <a href="https://github.com/othneildrew/Best-README-Template"> |
| 42 | + <img src="images/stac.gif" alt="Logo"> |
| 43 | + </a> |
| 44 | +</div> |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | +<!-- TABLE OF CONTENTS --> |
| 49 | +<details> |
| 50 | + <summary>Table of Contents</summary> |
| 51 | + <ol> |
| 52 | + <li> |
| 53 | + <a href="#about-the-project">About The Project</a> |
| 54 | + </li> |
| 55 | + <li> |
| 56 | + <a href="#getting-started">Getting Started</a> |
| 57 | + <ul> |
| 58 | + <li><a href="#structure">Structure</a></li> |
| 59 | + <li><a href="#prerequisites">Prerequisites</a></li> |
| 60 | + <li><a href="#installation">Installation</a></li> |
| 61 | + </ul> |
| 62 | + </li> |
| 63 | + <li><a href="#usage">Usage</a></li> |
| 64 | + <li><a href="#contributing">Contributing</a></li> |
| 65 | + <li><a href="#license">License</a></li> |
| 66 | + </ol> |
| 67 | +</details> |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +<!-- ABOUT THE PROJECT --> |
| 72 | +## About The Project |
| 73 | + |
| 74 | +- *tldr*: **SatExtractor** gets **all revisits in a date range** from a given **geojson region** from any public satellite constellation and store it in a **cloud friendly format**. |
| 75 | + |
| 76 | + |
| 77 | +The large amount of image data makes it difficult to create datasets to train models quickly and reliably. Existing methods for extracting satellite images take a long time to process and have user quotas that restrict access. |
| 78 | + |
| 79 | +Therefore, we created an open source extraction tool **SatExtractor** to perform worldwide datasets extractions using serverless providers such as **Google Cloud Platform** or **AWS** and based on a common existing standard: **STAC**. |
| 80 | + |
| 81 | +The tool scales horizontally as needed, extracting revisits and storing them in **zarr** format to be easily used by deep learning models. |
| 82 | + |
| 83 | +It is fully configurable using [Hydra]([hydra](https://hydra.cc/)). |
| 84 | + |
| 85 | +<p align="right">(<a href="#top">back to top</a>)</p> |
| 86 | + |
| 87 | + |
| 88 | +<!-- GETTING STARTED --> |
| 89 | +## Getting Started |
| 90 | + |
| 91 | +**SatExtractor** needs a cloud provider to work. Before you start using it, you'll need to create and configure a cloud provider account. |
| 92 | + |
| 93 | +We provide the implementation to work with [Google Cloud](https://cloud.google.com/), but **SatExtractor** is implemented to be easily extensible to other providers. |
| 94 | + |
| 95 | +### Structure |
| 96 | + |
| 97 | +The package is structured in a modular and configurable approach. It is basically a pipeline containing 6 important steps (separated in modules). |
| 98 | + |
| 99 | +- **Builder**: contains the logic to build the container that will run the extraction. <details> |
| 100 | + <summary>more info</summary> |
| 101 | + SatExtractor is based on a docker container. The Dockerfile in the root dir is used to build the core package and a reference in it to the specific provider extraction logic should be explicitly added (see the gcp example in directory providers/gcp). |
| 102 | + |
| 103 | + This is done by setting <code> ENV PROVIDER </code> var to point the provider directory. In the default Dockerfile it is set to gcp: <code> ENV PROVIDER providers/gcp </code>. |
| 104 | +</details> |
| 105 | + |
| 106 | +- **Stac**: converts a public constellation to the **STAC standard**. <details> |
| 107 | + <summary>more info</summary> |
| 108 | + If the original constellation is not already in STAC standard it should be converted. To do so, you have to implement the constellation specific STAC conversor. Sentinel 2 and Landsat 7/8 examples can be found in <code> src/satextractor/stac </code>. The function that is actually called to perform the conversion to the STAC standard is set in stac hydra config file ( <code> conf/stac/gcp.yaml </code>) |
| 109 | +</details> |
| 110 | + |
| 111 | +- **Tiler**: Creates tiles of the given region to perform the extraction. <details> |
| 112 | + <summary>more info</summary> |
| 113 | + The Tiler split the region in UTM tiles using <a href=https://sentinelhub-py.readthedocs.io/en/latest/examples/large_area_utilities.html> SentinelHub splitter </a>. There will be one Extraction Task per Tile. The config about the tiler can be found in <code> conf/tiler/utm.yaml </code>. There, the size of the tiles can be specified. Take into account that these tiles are not the actual patches that are later stored in your cloud provider, this is just the unit from where the (smaller) patches will be extracted. |
| 114 | +</details> |
| 115 | + |
| 116 | +- **Scheduler**: Decides how those tiles are going to be scheduled creating extractions tasks. <details> |
| 117 | + <summary>more info</summary> |
| 118 | + The Scheduler takes the resulting tiles from the Tiler and creates the actual patches (called also tiles) to be extracted. |
| 119 | + |
| 120 | + For example, if the Tiler splitted the region in 10000x10000 tiles, now the scheduler can be set to extract from each of the tiles smaller patches of, say, 1000x1000. Also, the scheduler calculates the intersection between the patches and the constellation STAC assets. At the end, you'll have and object called <code> ExtractionTask </code> with the information to extract one revisit, one band and one tile splitted in multiple patches. This <code> ExtractionTask </code> will be send to the cloud provider to perform the actual extraction. |
| 121 | + |
| 122 | + The config about the scheduler can be found in <code> conf/scheduler/utm.yaml </code>. |
| 123 | +</details> |
| 124 | + |
| 125 | +- **Preparer**: Prepare the files in the cloud storage. <details> |
| 126 | + <summary>more info</summary> |
| 127 | + The Preparer creates the cloud file structure. It creates the needed zarr groups and arrays in order to later store the extracted patches. |
| 128 | + |
| 129 | + The gcp preparer config can be found in <code> conf/preparer/gcp.yaml </code>. |
| 130 | +</details> |
| 131 | + |
| 132 | +- **Deployer**: Deploy the extraction tasks created by the scheduler to perform the extraction. <details> |
| 133 | + <summary>more info</summary> |
| 134 | + The Deployer sends one message per ExtractionTask to the cloud provider to perform the actal extraction. It works by publishing messages to a PubSub queue where the extraction is subscribed to. When a new message (ExtractionTask) arrives it will be automatically run on the cloud autoscaling. |
| 135 | + The gcp deployer config can be found in <code> conf/deployer/gcp.yaml </code>. |
| 136 | +</details> |
| 137 | + |
| 138 | + |
| 139 | +All the steps are **optional** and the user decides which to run the **main config file**. |
| 140 | + |
| 141 | + |
| 142 | +### Prerequisites |
| 143 | + |
| 144 | +In order to run **SatExtractor** we recommend to have a virtual env and a cloud provider user should already been created. |
| 145 | + |
| 146 | +### Installation |
| 147 | + |
| 148 | + |
| 149 | +1. Clone the repo |
| 150 | + ```sh |
| 151 | + git clone https://github.com/FrontierDevelopmentLab/sat-extractor |
| 152 | + ``` |
| 153 | +2. Install python packages |
| 154 | + ```sh |
| 155 | + pip install . |
| 156 | + ``` |
| 157 | + |
| 158 | +<p align="right">(<a href="#top">back to top</a>)</p> |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | +<!-- USAGE EXAMPLES --> |
| 163 | +## Usage |
| 164 | + |
| 165 | +Once a cloud provider user is set and the package is installed you'll need to grab the geojson region you want (you can get it from the super-cool tool [geojson.io](geojson.io)) and change the config files. |
| 166 | + |
| 167 | +1. Save the region as `<your_region_name>.geojson` and store it in the `outputs` folder (you can change your output dir in the `config.yaml`) |
| 168 | +2. Open the `config.yaml` and you'll see something like this: |
| 169 | + |
| 170 | +<img src="images/config.png" alt="Logo"> |
| 171 | + |
| 172 | +The important here is to set the `dataset_name` to `<your_region_name>`, define the `start_date` and `end_date` for your revisits, your `constellations` and the tasks to be run (you would want to run the `build` only one time and the comment it out.) |
| 173 | + |
| 174 | +**Important**: the `token.json` contains the needed credentials to access you cloud provider. In this example case it contains the gcp credentials. You'll need to provide it. |
| 175 | + |
| 176 | +3. Open the `cloud/<provider>.yaml` and add there your account info as in the default provided file. |
| 177 | + (optional): you can choose different configurations by changing modules configs: `builder`, `stac`, `tiler`, `scheduler`, `preparer`, etc. There you can change things like patch_size, chunk_size. |
| 178 | + |
| 179 | +4. Run `python src/satextractor/cli.py` and enjoy! |
| 180 | + |
| 181 | + |
| 182 | +<p align="right">(<a href="#top">back to top</a>)</p> |
| 183 | + |
| 184 | + |
| 185 | +See the [open issues](https://github.com/FrontierDevelopmentLab/sat-extractor/issues) for a full list of proposed features (and known issues). |
| 186 | + |
| 187 | +<p align="right">(<a href="#top">back to top</a>)</p> |
| 188 | + |
| 189 | + |
| 190 | + |
| 191 | +<!-- CONTRIBUTING --> |
| 192 | +## Contributing |
| 193 | + |
| 194 | +Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. |
| 195 | + |
| 196 | +If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". |
| 197 | +Don't forget to give the project a star! Thanks again! |
| 198 | + |
| 199 | +1. Fork the Project |
| 200 | +2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) |
| 201 | +3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) |
| 202 | +4. Push to the Branch (`git push origin feature/AmazingFeature`) |
| 203 | +5. Open a Pull Request |
| 204 | + |
| 205 | +<p align="right">(<a href="#top">back to top</a>)</p> |
| 206 | + |
| 207 | + |
| 208 | + |
| 209 | +<!-- LICENSE --> |
| 210 | +## License |
| 211 | + |
| 212 | +Distributed under the MIT License. See `LICENSE.txt` for more information. |
| 213 | + |
| 214 | +<p align="right">(<a href="#top">back to top</a>)</p> |
0 commit comments