{
"cells": [
{
"cell_type": "markdown",
"id": "3d887eed-ce30-4984-abd3-762deb9af0cc",
"metadata": {},
"source": [
"# Oberflächentemperatur (Land Surface Temperature)"
]
},
{
"cell_type": "markdown",
"id": "ee91c281-afd2-43b5-ba42-fdcef475dc81",
"metadata": {},
"source": [
"## Authentifizierung"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "dca5e519-d0ff-48f9-b493-80f42101eb35",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"Visit https://identity.dataspace.copernicus.eu/auth/realms/CDSE/device?user_code=QHKA-VXMK 📋 to authenticate."
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"✅ Authorized successfully"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Authenticated using device code flow.\n"
]
}
],
"source": [
"import openeo\n",
"\n",
"connection = openeo.connect(\"https://openeo.dataspace.copernicus.eu/\").authenticate_oidc()"
]
},
{
"cell_type": "markdown",
"id": "fc5b84c1-271a-436c-9363-8e6525e6fec7",
"metadata": {},
"source": [
"## Verwaltungsgrenzen von Bremen"
]
},
{
"cell_type": "markdown",
"id": "3140ba0c-bedc-4314-876e-01598e2826c8",
"metadata": {},
"source": [
"## Räumliche Ausdehnung\n",
"\n",
"Bestimmung der räumlichen Ausdehnung anhand der Vektorgeometrien"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6c86786f-1fd3-4859-9853-8e8b6fb20b30",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'west': 8.481758449250766,\n",
" 'south': 53.01115244699335,\n",
" 'east': 8.990813245344944,\n",
" 'north': 53.2289106605276}"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"spatial_extent = {'west': 8.721771, 'south': 53.025027, 'east': 8.904419, 'north': 53.114965}"
]
},
{
"cell_type": "markdown",
"id": "b52c35ce-9880-438f-8ed7-eb92e325eb7f",
"metadata": {},
"source": [
"## Zeitliche Ausdehnung"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "d985ba77-3ba7-418f-b84a-a8c817b9f512",
"metadata": {},
"outputs": [],
"source": [
"temporal_extent = [\"2024-06-01\", \"2024-08-31\"]"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "cca0787b-5f23-4c17-b2a7-e0c9f812fa15",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0:00:00 Job 'j-2510111146024febaf1f1d58a9a115af': send 'start'\n",
"0:00:13 Job 'j-2510111146024febaf1f1d58a9a115af': created (progress 0%)\n",
"0:00:18 Job 'j-2510111146024febaf1f1d58a9a115af': created (progress 0%)\n",
"0:00:24 Job 'j-2510111146024febaf1f1d58a9a115af': created (progress 0%)\n",
"0:00:32 Job 'j-2510111146024febaf1f1d58a9a115af': created (progress 0%)\n",
"0:00:42 Job 'j-2510111146024febaf1f1d58a9a115af': created (progress 0%)\n",
"0:00:55 Job 'j-2510111146024febaf1f1d58a9a115af': created (progress 0%)\n",
"0:01:10 Job 'j-2510111146024febaf1f1d58a9a115af': running (progress N/A)\n",
"0:01:29 Job 'j-2510111146024febaf1f1d58a9a115af': running (progress N/A)\n",
"0:01:53 Job 'j-2510111146024febaf1f1d58a9a115af': running (progress N/A)\n",
"0:02:23 Job 'j-2510111146024febaf1f1d58a9a115af': running (progress N/A)\n",
"0:03:00 Job 'j-2510111146024febaf1f1d58a9a115af': running (progress N/A)\n",
"0:03:47 Job 'j-2510111146024febaf1f1d58a9a115af': finished (progress 100%)\n"
]
},
{
"data": {
"text/plain": [
"PosixPath('results/lst.tif')"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cube = connection.load_collection(\n",
" \"SENTINEL3_SLSTR_L2_LST\",\n",
" spatial_extent=spatial_extent,\n",
" temporal_extent=temporal_extent,\n",
" bands=[\"LST\"]\n",
")\n",
"\n",
"\n",
"cube = cube.mean_time()\n",
"\n",
"lst = cube.save_result(format=\"GTIFF\")\n",
"job = lst.create_job(title=\"LST\")\n",
"job.start_and_wait().download_result('results/lst.tif')"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "c840c746-b6f3-4baa-b198-905387509990",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2565447ee8f44fbfb5f467641971172e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Map(center=[53.1173035, 8.740687], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title',…"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import leafmap\n",
"\n",
"m = leafmap.Map()\n",
"\n",
"m.add_raster(\n",
" 'results/lst.tif',\n",
" cmap=\"coolwarm\",\n",
" layer_name=\"Land Surface Temperature\"\n",
")\n",
"\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "e1849544-030e-4b5b-8402-dad9f9911c6e",
"metadata": {},
"outputs": [],
"source": [
"import rasterio as rio\n",
"\n",
"src = rio.open('results/lst.tif')"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "1ad30415-08eb-4c28-8e05-86a6dd605157",
"metadata": {},
"outputs": [],
"source": [
"# Temperatur von Kelvin in Celsius umrechnen\n",
"lst = src.read() - 272.15"
]
},
{
"cell_type": "code",
"execution_count": 38,
"id": "f95d4a2d-0060-43c0-9cd8-2f5e9e2c4ec2",
"metadata": {},
"outputs": [
{
"ename": "ValueError",
"evalue": "Mime type rendering requires nbformat>=4.2.0 but it is not installed",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mValueError\u001b[39m Traceback (most recent call last)",
"\u001b[36mFile \u001b[39m\u001b[32m~/cdec-hackathon/game/.venv/lib/python3.12/site-packages/IPython/core/formatters.py:984\u001b[39m, in \u001b[36mIPythonDisplayFormatter.__call__\u001b[39m\u001b[34m(self, obj)\u001b[39m\n\u001b[32m 982\u001b[39m method = get_real_method(obj, \u001b[38;5;28mself\u001b[39m.print_method)\n\u001b[32m 983\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m method \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m984\u001b[39m \u001b[43mmethod\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 985\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/cdec-hackathon/game/.venv/lib/python3.12/site-packages/plotly/basedatatypes.py:850\u001b[39m, in \u001b[36mBaseFigure._ipython_display_\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 847\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mplotly\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mio\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpio\u001b[39;00m\n\u001b[32m 849\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m pio.renderers.render_on_display \u001b[38;5;129;01mand\u001b[39;00m pio.renderers.default:\n\u001b[32m--> \u001b[39m\u001b[32m850\u001b[39m \u001b[43mpio\u001b[49m\u001b[43m.\u001b[49m\u001b[43mshow\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m 851\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 852\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28mrepr\u001b[39m(\u001b[38;5;28mself\u001b[39m))\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/cdec-hackathon/game/.venv/lib/python3.12/site-packages/plotly/io/_renderers.py:415\u001b[39m, in \u001b[36mshow\u001b[39m\u001b[34m(fig, renderer, validate, **kwargs)\u001b[39m\n\u001b[32m 410\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[32m 411\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mMime type rendering requires ipython but it is not installed\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 412\u001b[39m )\n\u001b[32m 414\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m nbformat \u001b[38;5;129;01mor\u001b[39;00m Version(nbformat.__version__) < Version(\u001b[33m\"\u001b[39m\u001b[33m4.2.0\u001b[39m\u001b[33m\"\u001b[39m):\n\u001b[32m--> \u001b[39m\u001b[32m415\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[32m 416\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mMime type rendering requires nbformat>=4.2.0 but it is not installed\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 417\u001b[39m )\n\u001b[32m 419\u001b[39m display_jupyter_version_warnings()\n\u001b[32m 421\u001b[39m ipython_display.display(bundle, raw=\u001b[38;5;28;01mTrue\u001b[39;00m)\n",
"\u001b[31mValueError\u001b[39m: Mime type rendering requires nbformat>=4.2.0 but it is not installed"
]
},
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"coloraxis": "coloraxis",
"hovertemplate": "x: %{x}
y: %{y}
color: %{z}