diff --git a/no_ui.ipynb b/no_ui.ipynb
index 4f63e10..7daf4e0 100644
--- a/no_ui.ipynb
+++ b/no_ui.ipynb
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -12,200 +12,18 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- ""
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- ""
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/javascript": [
- "/*******************************************************************************\n",
- " * remove any links from fontawesome 5 created by jupyter in favor of\n",
- " * fontawesome 6. to be removed when Jupyter updates it\n",
- " */\n",
- "\n",
- "function remove_fa5() {\n",
- " let links = document.querySelectorAll(\n",
- " \"link[href^='https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@^5']\"\n",
- " );\n",
- "\n",
- " links.forEach((link) => link.remove());\n",
- "}\n",
- "\n",
- "if (document.readyState != \"loading\") remove_fa5();\n",
- "else document.addEventListener(\"DOMContentLoaded\", remove_fa5);\n"
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "b2ccb26b9a874f7eaa675e2b2e237dda",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "ResizeTrigger()"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"from component import tile\n",
- "from component import model"
+ "from component import model\n",
+ "from sepal_ui.planetapi import PlanetView"
]
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -220,17 +38,26 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "planet_view = PlanetView()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"viz_model = model.VizModel()\n",
- "viz_input_tile = tile.InputTile(viz_model, tb_model)"
+ "viz_input_tile = tile.InputTile(viz_model, tb_model, planet_view=planet_view)"
]
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -238,164 +65,216 @@
"# result tile\n",
"export_results = tile.ExportResult()\n",
"# export data\n",
- "export_tile = tile.ExportData(export_model, viz_model, tb_model, export_results)"
+ "export_tile = tile.ExportData(\n",
+ " export_model,\n",
+ " viz_model,\n",
+ " tb_model,\n",
+ " export_results,\n",
+ " planet_model=planet_view.planet_model,\n",
+ ")"
]
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "08247763295e4351bbe9e33654671a51",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "TestTile(align_center=True, children=[Card(children=[Html(children=['Download test data File'], layout=None, t\u2026"
- ]
- },
- "execution_count": 13,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"test_tile"
]
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": null,
"metadata": {
"tags": []
},
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "fc8364a218824f58bbd52da795c727a9",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "FileTile(align_center=True, children=[Card(children=[Html(children=['Select a file'], layout=None, tag='h2'), \u2026"
- ]
- },
- "execution_count": 5,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"file_tile"
]
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "c366cabc3ff9494ea0bc1f613638e123",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "MapTile(align_center=True, children=[Card(children=[Html(children=['Display points'], layout=None, tag='h2'), \u2026"
- ]
- },
- "execution_count": 6,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"tb_map_tile"
]
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": null,
"metadata": {
"tags": []
},
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "154e818d593140b4bb7001081ae52900",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "InputTile(align_center=True, children=[Card(children=[Html(children=['set up your inputs'], layout=None, tag='\u2026"
- ]
- },
- "execution_count": 9,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"viz_input_tile"
]
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import rasterio as rio"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
"metadata": {
"tags": []
},
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "47eb112ce1ea49eab67211979c496a41",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "ExportData(align_center=True, children=[Card(children=[Html(children=['Export data'], layout=None, tag='h2'), \u2026"
- ]
- },
- "execution_count": 14,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"export_tile"
]
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from component.scripts.gee import gee_ee_image"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import threading\n",
+ "import concurrent.futures\n",
+ "\n",
+ "from typing import Literal, Tuple\n",
+ "import zipfile\n",
+ "from functools import partial\n",
+ "from pathlib import Path\n",
+ "from urllib.request import urlretrieve\n",
+ "\n",
+ "import ee\n",
+ "from osgeo import gdal\n",
+ "from sepal_ui import sepalwidgets as sw\n",
+ "from sepal_ui.scripts.utils import init_ee\n",
+ "\n",
+ "from component import parameter as cp\n",
+ "from component import widget as cw\n",
+ "from component.message import cm\n",
+ "\n",
+ "from component.scripts.utils import get_buffers, get_vrt_filename, min_diagonal"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "0fe955786e4f46b598e1047a29b356d2",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "ExportResult(align_center=True, children=[Card(children=[Html(children=['Export results'], layout=None, tag='h\u2026"
- ]
- },
- "execution_count": 16,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
+ "source": [
+ "def get_ee_image(\n",
+ " satellites: dict,\n",
+ " satellite_id: Literal[\"sentinel_2\", \"landsat_5\", \"landsat_7\", \"landsat_8\"],\n",
+ " start: str,\n",
+ " end: str,\n",
+ " str_bands: str,\n",
+ " aoi: ee.geometry.Geometry,\n",
+ ") -> Tuple[ee.ImageCollection, ee.Image]:\n",
+ "\n",
+ " # create the feature collection name\n",
+ " dataset = (\n",
+ " ee.ImageCollection(satellites[satellite_id])\n",
+ " .filterDate(start, end)\n",
+ " .filterBounds(aoi)\n",
+ " .map(cp.getCloudMask(satellite_id))\n",
+ " )\n",
+ "\n",
+ " bands = cp.getAvailableBands()[str_bands][satellite_id]\n",
+ " ee_image = dataset.median().clip(aoi).select(bands)\n",
+ "\n",
+ " # calculate the NDVI or NDWI if needed\n",
+ " # Bands are in the correct order to do the index calculation\n",
+ " if \"ndvi\" in str_bands or \"ndwi\" in str_bands:\n",
+ " ee_image = ee_image.normalizedDifference(bands).rename(\"ndvi\")\n",
+ "\n",
+ " return dataset, ee_image"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "sources = [\"sentinel\", \"landsat\"]\n",
+ "\n",
+ "aoi = ee.Geometry.Polygon(\n",
+ " [\n",
+ " [\n",
+ " [13.024513100356552, 5.333572819469696],\n",
+ " [13.026757769061255, 5.333572819469696],\n",
+ " [13.026757769061255, 5.335822103684232],\n",
+ " [13.024513100356552, 5.335822103684232],\n",
+ " [13.024513100356552, 5.333572819469696],\n",
+ " ]\n",
+ " ]\n",
+ ")\n",
+ "\n",
+ "# Test with Sentinel_2\n",
+ "bands = str_bands = \"Nir, Swir1, Red\"\n",
+ "satellite_id = \"landsat_5\"\n",
+ "year = 1990\n",
+ "start = str(year) + \"-01-01\"\n",
+ "end = str(year) + \"-12-31\"\n",
+ "satellites = cp.getSatellites(sources, year)\n",
+ "dataset, ee_image = get_ee_image(satellites, satellite_id, start, end, bands, aoi)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# create the feature collection name\n",
+ "dataset = (\n",
+ " ee.ImageCollection(satellites[satellite_id])\n",
+ " .filterDate(start, end)\n",
+ " .filterBounds(aoi)\n",
+ " .map(cp.getCloudMask(satellite_id))\n",
+ ")\n",
+ "bands = cp.getAvailableBands()[str_bands][satellite_id]\n",
+ "ee_image = dataset.median().clip(aoi)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
- "export_results"
+ "aoi"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "satellites[satellite_id]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
@@ -419,4 +298,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
-}
\ No newline at end of file
+}