Skip to content

Commit ce16cd4

Browse files
authored
Merge pull request #1 from planetlabs/update-docker-workflow
clean up readmes, move imports to requirements
2 parents 4997aae + 0db2c61 commit ce16cd4

File tree

4 files changed

+37
-139
lines changed

4 files changed

+37
-139
lines changed

README.md

Lines changed: 30 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
## Planet Interactive Guides
1+
# Planet Jupyter Notebook Guides
22

33
In this repository, you'll find a collection of [Jupyter notebooks](http://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/what_is_jupyter.html) from the software developers, data scientists, and developer advocates at [Planet](https://www.planet.com/). These interactive, open-source ([APLv2](LICENSE)) guides are designed to help you work with our APIs and tools, explore Planet data, and learn how to extract information from our massive archive of high-cadence satellite imagery. We hope these guides will inspire you to ask interesting questions of Planet data. Need help? Find a bug? Please [file an issue](https://github.com/planetlabs/notebooks/issues/new) and we'll get back to you.
44

5-
## Install and use these notebooks
5+
## Install and Use Planet Jupyter Notebooks
66

77
### System Prerequisites
8-
* [Docker](https://store.docker.com/search?type=edition&offering=community)
9-
* [Planet Account](https://www.planet.com/explorer/?signup=1)
8+
* [Docker](https://docs.docker.com/get-started/get-docker/)
9+
* [Planet Account](https://insights.planet.com/sign-up)
1010
* [Planet API Key](https://www.planet.com/account/)
1111

12-
NOTE: After installing Docker, Windows users should install WSL2 Backend when prompted.
13-
14-
### Clone or update repo:
12+
### Clone or Update Repo
1513

1614
If you've never cloned the Planet notebooks repo, run the following:
1715

@@ -29,7 +27,7 @@ git pull
2927

3028
## Authentication
3129

32-
## Access your Planet API Key in Python
30+
## Access Your Planet API Key in Python
3331

3432
Authentication with Planet's API Key can be achieved by using a valid Planet API Key.
3533

@@ -53,7 +51,7 @@ PLANET_API_KEY = os.getenv('PL_API_KEY')
5351

5452
Now, your Planet API Key is stored in the variable ```PLANET_API_KEY``` and is ready to use in your Python code.
5553

56-
### Sentinel Hub Python SDK
54+
## Sentinel Hub Python SDK
5755
Some Notebooks in this repository use the [Sentinel Hub Python SDK](https://sentinelhub-py.readthedocs.io/en/latest/index.html). Currently, this SDK uses a different method of authenticating than what is used with the Planet APIs and SDK for Python.
5856

5957
For the Sentinel Hub Python SDK, you must provide a ```client_id``` and a ```client_secret``` which can be obtained from the [Dashboard](https://apps.sentinel-hub.com/dashboard/) app. You can find full instructions on setting up the client credentials in this SDK from the [SDK documentation](https://sentinelhub-py.readthedocs.io/en/latest/configure.html).
@@ -75,140 +73,45 @@ else:
7573
```
7674

7775
## Run Planet Notebooks in Docker
78-
Planet Notebooks rely on a complex stack of technologies that are not always easy to install and properly
79-
configure. To ease this complexity we provide a docker container for running the notebook on docker compatible
80-
systems. To install docker on your system please see docker's [documentation](https://docs.docker.com/engine/installation/)
81-
for your operating system.
76+
Planet Notebooks rely on a complex stack of technologies that are not always easy to install and properly configure. To ease this complexity we provide a Docker container for running the notebook on Docker compatible systems. To install Docker on your system please see [Docker documentation](https://docs.docker.com/get-started/get-docker/) for your operating system.
8277

83-
### Download prebuilt Docker image (recommended)
84-
The Docker image for these notebooks is hosted in the [planetlabs/notebooks](https://hub.docker.com/r/planetlabs/notebooks) repo on DockerHub. To download and prepare the image for use, run:
78+
### Build the Docker image
8579

86-
```bash
87-
cd notebooks
88-
docker pull planetlabs/notebooks
89-
docker tag planetlabs/notebooks planet-notebooks
90-
91-
# If you get errors running the above, you might have to add sudo to the beginning:
92-
#sudo docker pull planetlabs/notebooks
93-
#sudo docker tag planetlabs/notebooks planet-notebooks
94-
```
95-
96-
If you want to re-build the Docker image yourself, this is documented below in the "Appendix: Build the Docker image" section.
97-
98-
### Run the container
99-
To run the container (after building or downloading it), add your Planet API key below and issue the following command from the git repository root directory:
80+
First you must build the docker image. After checking out the repository, you run:
10081

10182
```bash
102-
docker run -it --rm -p 8888:8888 -v $PWD:/home/jovyan/work -e PL_API_KEY='[YOUR-API-KEY]' planet-notebooks
103-
104-
# If you get a permissions error running the above, you should add sudo to the front:
105-
# sudo docker run -it --rm -p 8888:8888 -v $PWD:/home/jovyan/work -e PL_API_KEY='[YOUR-API-KEY]' planet-notebooks
106-
# Windows users run: winpty docker run -it --rm -p 8888:8888 -v "/$PWD":/home/joyvan/work -e PL_API_KEY='[YOUR-API-KEY]' planet-notebooks
107-
83+
docker build -t planet-notebooks planet-notebook-docker/
10884
```
10985

110-
This does several things:
86+
This will build and install the Docker image on your system, making it available to run. This may take some time (from 10 minutes to an hour) depending on your network connection and how long Anaconda takes to configure its environment.
11187

112-
1. Maps the docker container's ```8888``` port to your system's ```8888``` port. This makes the
113-
container available to your host systems web browser.
88+
> [!IMPORTANT]
89+
> You may need to rebuild the Docker image if this repository changes or if you need to use newer versions of the Planet SDK for Python.
11490
115-
1. Maps a host system path ```$PWD``` to the docker container's working directory.
116-
This ensures that the notebooks you create, edit, and save are available on your host system under the
117-
`jupyter-notebooks` sub-directory and are not *destroyed* when you exit the container.
118-
This also allows for running tests in the `tests` sub-directory.
91+
### Run the Container
92+
To run the container after building it, add your Planet API key to the command below and run it from the cloned `planetlabs/notebooks` repository root directory in Unix bash, Windows PowerShell, Git Bash, or WSL.
11993

120-
1. Ensures that the directory in the Docker container named `/home/jovyan/work` that has the notebooks
121-
in them is accessible to the Jupyter notebook server.
94+
```bash
95+
docker run -it --rm -p 8888:8888 -v "$(pwd)/jupyter-notebooks:/home/jovyan/work" -e PL_API_KEY='your-key' planet-notebooks
96+
```
12297

123-
1. Starts an interactive terminal that is accessible through http://localhost:8888.
98+
> [!TIP]
99+
> If you get permission errors: Add sudo to the front (Linux/Mac) or run PowerShell as Administrator (Windows).
124100
125-
1. Sets an environment variable with your unique Planet API key for authenticating against the API.
101+
This does several things:
126102

127-
1. Includes the ```--rm``` option to clean up the notebook after you exit the process.
103+
1. **Maps port 8888** - Makes the container accessible at http://localhost:8888
104+
2. **Mounts your notebooks** - Maps `jupyter-notebooks/` folder to `/home/jovyan/work` so your work persists and notebooks are accessible to Jupyter
105+
3. **Sets your API key** - Replace `your-key` with your actual Planet API key for API authentication
106+
4. **Starts interactive terminal** - Accessible through the web browser
107+
5. **Auto-cleanup** - Removes container when you exit (`--rm`)
128108

129-
### Open Jupyter notebooks
109+
### Open Jupyter Notebooks
130110
Once the Docker container is running, the CLI output will display a URL that you will use to access Jupyter notebooks
131111
with your browser.
132112
```
133113
http://localhost:8888/?token=<UNIQUE-TOKEN>
134114
```
135115

136-
NOTE: This security token will change every time you start your Docker container.
137-
138-
## Repository Organization
139-
140-
### jupyter-notebooks
141-
142-
#### exploring_planet_data: Working with our various image products, how to use the udm mask or deliver imagery to our GEE integration
143-
144-
* [How to use the Data and Orders API to create analysis ready data](https://github.com/planetlabs/notebooks/tree/proserve_restructure/jupyter-notebooks/exploring_planet_data/analysis-ready-data)
145-
* [Converting Raster Results to Vector Features](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/analytics-snippets/README.md)
146-
* [Introduction to Cloud Native Geospatial Tools](https://github.com/planetlabs/notebooks/tree/master/jupyter-notebooks/cloud-native-geospatial)
147-
* [Comparing Planet Scope with Landsat 8]()
148-
* [Deliver data to GEE](https://github.com/planetlabs/notebooks/tree/master/jupyter-notebooks/cloud-native-geospatial)
149-
* [Start working with satellite imagery in Python](https://github.com/planetlabs/notebooks/tree/master/jupyter-notebooks/cloud-native-geospatial)
150-
* [Create labels using Planet imagery](https://github.com/planetlabs/notebooks/tree/master/jupyter-notebooks/cloud-native-geospatial)
151-
* [Pixel-by-pixel comparison of PlanetScope and Landsat Scenes](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/landsat-ps-comparison/landsat-ps-comparison.ipynb)
152-
* [Visualize and convert a UDM to a binary mask](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/udm/udm.ipynb)
153-
* [Work with the Usable Data Mask (UDM2)](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/udm2)
154-
155-
156-
157-
158-
#### Search, activate, download with the Data API
159-
* [Explore the Planet Data API with Python](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/data-api-tutorials/planet_data_api_introduction.ipynb)
160-
* [Search, activate, and download imagery with the Planet Python Client](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/data-api-tutorials/planet_python_client_introduction.ipynb)
161-
* [Search & Download Quickstart Guide](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/data-api-tutorials/search_and_download_quickstart.ipynb)
162-
* [Planet Data API reference](https://developers.planet.com/docs/apis/data/)
163-
164-
#### Ordering, delivery, and tools with the Orders API
165-
* [Ordering and Delivery](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/orders_api_tutorials/ordering_and_delivery.ipynb)
166-
* [Tools and Toolchains](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/orders_api_tutorials/tools_and_toolchains.ipynb)
167-
* [Planet Orders API reference](https://developers.planet.com/docs/orders/)
168-
169-
### Process Planet data
170-
* [Create a mosaic from multiple PlanetScope scenes](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/mosaicing/basic_compositing_demo.ipynb)
171-
* [Calculate a vegetation index from 4-band satellite imagery](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/ndvi/ndvi_planetscope.ipynb)
172-
* [Convert PlanetScope metadata from radiance to reflectance](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/toar/toar_planetscope.ipynb)
173-
174-
175-
### Analyze and visualize Planet data
176-
177-
* Analytics quickstart:
178-
1. [Summarizing Feeds and Subscriptions](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/analytics/quickstart/01_checking_available_feeds_and_subscriptions.ipynb)
179-
2. [Getting Analytic Feed Results](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/analytics/quickstart/02_fetching_feed_results.ipynb)
180-
3. [Visualizing Raster Results](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/analytics/quickstart/03_visualizing_raster_results.ipynb)
181-
* Analytics user guide:
182-
1. [Getting Started with Planet Analytics API](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/analytics/user-guide/01_getting_started_with_the_planet_analytics_api.ipynb)
183-
2. [Planet Analytic Feeds Results](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/analytics/user-guide/02_analytic_feeds_results.ipynb)
184-
3. [Change Detection](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/analytics/user-guide/03_change_detection.ipynb)
185-
4. [Summary Statistics - Buildings](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/analytics/user-guide/04_summary_statistics_buildings.ipynb)
186-
5. [Summary Statistics - Ships and Clouds](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/analytics/user-guide/05_summary_statistics_ships_and_clouds.ipynb)
187-
* Other analytics notebooks:
188-
* [Detect, count, and visualize ships in Planet imagery](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/ship-detector/01_ship_detector.ipynb)
189-
* [Pixel-by-pixel comparison of PlanetScope and Landsat Scenes](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/landsat-ps-comparison/landsat-ps-comparison.ipynb)
190-
* [Calculate Coverage for a Search Query](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/coverage/calculate_coverage.ipynb)
191-
* [Segment and Classify Crops](https://github.com/planetlabs/notebooks/tree/master/jupyter-notebooks/crop-segmentation-and-classification)
192-
* [Identify Forest Degradation](https://github.com/planetlabs/notebooks/tree/master/jupyter-notebooks/forest-monitoring)
193-
* [Identify the Temporal Signature of Crops](https://github.com/planetlabs/notebooks/tree/master/jupyter-notebooks/temporal-analysis)
194-
195-
* [Creating a Heatmap of Vector Results](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/analytics/change_detection_heatmap.ipynb)
196-
197-
198-
Soon we hope to add notebooks from the researchers, technologists, geographers, and entrepreneurs who are already using Planet data to ask interesting and innovative questions about our changing Earth. If you're working with our imagery and have a notebook (or just an idea for a notebook) that you'd like to share, please [file an issue](https://github.com/planetlabs/notebooks/issues) and let us know.
199-
200-
### Appendix: Build the Docker image
201-
202-
This documents how to build the docker image yourself, rather than using the recommended step of downloading pre-built Docker images. This is useful if you are a developer adding dependencies or a new Jupyter notebook to this repo, for example.
203-
204-
First you must build the docker image. Note, this only has to be done the first time you use it. After checking out the
205-
repository, you run:
206-
```bash
207-
cd planet-notebook-docker
208-
docker build --rm -t planet-notebooks .
209-
cd ..
210-
```
211-
212-
This will build and install the Docker image on your system, making it available to run. This may take some
213-
time (from 10 minutes to an hour) depending on your network connection and how long Anaconda takes to configure
214-
its environment.
116+
> [!NOTE]
117+
> This security token will change every time you start your Docker container.

planet-notebook-docker/Dockerfile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://github.com/jupyter/docker-stacks/wiki/minimal-notebook-414b5d749704
33
FROM quay.io/jupyter/minimal-notebook:8515ad39f045
44

5-
# install dependencies
5+
# Copy requirements file for package installation
66
COPY requirements.txt /tmp/requirements.txt
77

88
# libgl Required for opencv
@@ -18,14 +18,8 @@ USER $NB_UID
1818
RUN conda config --set channel_priority strict && \
1919
conda install -y -c conda-forge --file /tmp/requirements.txt
2020

21-
# install the following libraries w/ pip to support analytics/user-guide nb's
22-
# build fails due to long conda solves when these dependencies are added to requirements.txt
23-
# see https://github.com/planetlabs/notebooks/issues/135 for more details
24-
# python -m pip as per https://github.com/pypa/pip/issues/5599
25-
RUN python -m pip install descartes geoviews
26-
2721
# Attempts to avoid having to hardcode this failed.
2822
# ref: https://github.com/planetlabs/notebooks/issues/101
2923
ENV PROJ_LIB=/opt/conda/share/proj
3024

31-
WORKDIR work
25+
WORKDIR /home/jovyan/work

planet-notebook-docker/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Planet Notebook
1+
# Planet Notebooks Docker Instructions
22

3-
This image provides the dependencies for running jupyter notebooks in the [planetlabs/notebooks](https://github.com/planetlabs/notebooks) GitHub repository. A prebuilt version of this image can be downloaded from the [planetlabs/notebook](https://hub.docker.com/r/planetlabs/notebooks) dockerhub repo (recommended). Alternatively, this image can be built locally from the Dockerfile. The specifics of building and running this image are given in the planetlabs/notebooks GitHub [README.md](https://github.com/planetlabs/notebooks/blob/master/README.md) file.
3+
This image provides the dependencies for running jupyter notebooks in the [planetlabs/notebooks](https://github.com/planetlabs/notebooks) GitHub repository. This image must be built locally from the Dockerfile. The specifics of building and running this image are given in the planetlabs/notebooks GitHub [README.md](https://github.com/planetlabs/notebooks?tab=readme-ov-file#run-planet-notebooks-in-docker) file.
44

55
This image is based on the [jupyter/minimal-notebook](https://hub.docker.com/r/jupyter/minimal-notebook/) image and additional tips on running the jupyter notebook can be found in the documentation for that image.
66

planet-notebook-docker/requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# changes here should be reflected in
21
# please keep this in alphabetical order
32
cartopy
3+
descartes
44
fiona
55
gdal
66
geojson
77
geojsonio
88
geopandas
9+
geoviews
910
ipyleaflet
1011
ipywidgets
1112
matplotlib
1213
mercantile
1314
numpy
14-
# for pip, use opencv-python
1515
opencv
1616
pandas
1717
planet
@@ -24,3 +24,4 @@ scikit-learn
2424
sentinelhub
2525
shapely
2626
tqdm
27+
tslearn

0 commit comments

Comments
 (0)