Skip to content

Commit 9154aba

Browse files
authored
Merge pull request #381 from tbarsballe/docker-jupyter-2025
Update Dockerfile to 2025 build of jupyter/minimal-notebook
2 parents 08faa6c + ce16cd4 commit 9154aba

File tree

10 files changed

+89
-196
lines changed

10 files changed

+89
-196
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.

jupyter-notebooks/Analytics-API/user-guide/01_getting_started_with_the_planet_analytics_api.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,9 +1033,7 @@
10331033
{
10341034
"cell_type": "code",
10351035
"execution_count": null,
1036-
"metadata": {
1037-
"scrolled": false
1038-
},
1036+
"metadata": {},
10391037
"outputs": [],
10401038
"source": [
10411039
"subscription_1"
@@ -1073,6 +1071,8 @@
10731071
"outputs": [],
10741072
"source": [
10751073
"# Let's look at our multipolygon centroid in (Lat, Long)\n",
1074+
"import warnings\n",
1075+
"warnings.simplefilter('ignore')\n",
10761076
"print(subscription_1['geometry'].centroid)\n",
10771077
"\n",
10781078
"# We need to input the center of our map in reverse order (Long, Lat) \n",
@@ -1139,9 +1139,9 @@
11391139
"name": "python",
11401140
"nbconvert_exporter": "python",
11411141
"pygments_lexer": "ipython3",
1142-
"version": "3.9.12"
1142+
"version": "3.13.7"
11431143
}
11441144
},
11451145
"nbformat": 4,
1146-
"nbformat_minor": 2
1146+
"nbformat_minor": 4
11471147
}

jupyter-notebooks/use-cases/coastal-erosion-example/0_download_data.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
"name": "python",
3535
"nbconvert_exporter": "python",
3636
"pygments_lexer": "ipython3",
37-
"version": "3.8.13"
37+
"version": "3.13.7"
3838
}
3939
},
4040
"nbformat": 4,
41-
"nbformat_minor": 2
41+
"nbformat_minor": 4
4242
}

jupyter-notebooks/use-cases/coastal-erosion-example/1_rasterio_firstlook.ipynb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@
9898
"outputs": [],
9999
"source": [
100100
"# Let's import Rasterio\n",
101-
"import rasterio"
101+
"import rasterio\n",
102+
"import os"
102103
]
103104
},
104105
{
@@ -108,7 +109,7 @@
108109
"outputs": [],
109110
"source": [
110111
"# This notebook explores a single 3 band (blue, green, red) PlanetScope scene in a UTM projection.\n",
111-
"image_file = \"/content/20170831_172754_101c_3b_Visual.tif\""
112+
"image_file = f\"{os.getcwd()}/20170831_172754_101c_3b_Visual.tif\""
112113
]
113114
},
114115
{
@@ -120,7 +121,7 @@
120121
"name": "stdout",
121122
"output_type": "stream",
122123
"text": [
123-
"<open DatasetReader name='20170831_172754_101c_3b_Visual.tif' mode='r'>\n"
124+
"<open DatasetReader name='/home/jovyan/work/jupyter-notebooks/use-cases/coastal-erosion-example/20170831_172754_101c_3b_Visual.tif' mode='r'>\n"
124125
]
125126
}
126127
],
@@ -141,7 +142,7 @@
141142
"name": "stdout",
142143
"output_type": "stream",
143144
"text": [
144-
"20170831_172754_101c_3b_Visual.tif\n",
145+
"/home/jovyan/work/jupyter-notebooks/use-cases/coastal-erosion-example/20170831_172754_101c_3b_Visual.tif\n",
145146
"3\n"
146147
]
147148
}
@@ -268,9 +269,9 @@
268269
"name": "python",
269270
"nbconvert_exporter": "python",
270271
"pygments_lexer": "ipython3",
271-
"version": "3.9.6"
272+
"version": "3.13.7"
272273
}
273274
},
274275
"nbformat": 4,
275-
"nbformat_minor": 2
276+
"nbformat_minor": 4
276277
}

jupyter-notebooks/use-cases/coastal-erosion-example/2_rasterbands.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"outputs": [],
8484
"source": [
8585
"import rasterio\n",
86+
"import os\n",
8687
"import numpy as np\n",
8788
"import matplotlib.pyplot as plt"
8889
]
@@ -100,7 +101,7 @@
100101
"metadata": {},
101102
"outputs": [],
102103
"source": [
103-
"image_file = \"/content/20170831_172754_101c_3b_Visual.tif\""
104+
"image_file = f\"{os.getcwd()}/20170831_172754_101c_3b_Visual.tif\""
104105
]
105106
},
106107
{
@@ -112,7 +113,7 @@
112113
"name": "stdout",
113114
"output_type": "stream",
114115
"text": [
115-
"<open DatasetReader name='20170831_172754_101c_3b_Visual.tif' mode='r'>\n"
116+
"<open DatasetReader name='/home/jovyan/work/jupyter-notebooks/use-cases/coastal-erosion-example/20170831_172754_101c_3b_Visual.tif' mode='r'>\n"
116117
]
117118
}
118119
],
@@ -410,9 +411,9 @@
410411
"name": "python",
411412
"nbconvert_exporter": "python",
412413
"pygments_lexer": "ipython3",
413-
"version": "3.9.6"
414+
"version": "3.13.7"
414415
}
415416
},
416417
"nbformat": 4,
417-
"nbformat_minor": 2
418+
"nbformat_minor": 4
418419
}

jupyter-notebooks/use-cases/coastal-erosion-example/3_compute_NDWI.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"outputs": [],
8383
"source": [
8484
"import rasterio\n",
85+
"import os\n",
8586
"import numpy as np\n",
8687
"import matplotlib.pyplot as plt"
8788
]
@@ -99,7 +100,7 @@
99100
"metadata": {},
100101
"outputs": [],
101102
"source": [
102-
"image_file = \"/content/20170831_172754_101c_3B_AnalyticMS.tif\"\n",
103+
"image_file = f\"{os.getcwd()}/20170831_172754_101c_3B_AnalyticMS.tif\"\n",
103104
"satdat = rasterio.open(image_file)"
104105
]
105106
},
@@ -286,9 +287,9 @@
286287
"name": "python",
287288
"nbconvert_exporter": "python",
288289
"pygments_lexer": "ipython3",
289-
"version": "3.9.6"
290+
"version": "3.13.7"
290291
}
291292
},
292293
"nbformat": 4,
293-
"nbformat_minor": 2
294+
"nbformat_minor": 4
294295
}

0 commit comments

Comments
 (0)