mirror of
https://github.com/heyarne/earth-observation-for-journalism.git
synced 2026-05-06 19:13:40 +02:00
Further re-reading, more work on dNBR (e.g. Potsdam-Mittelmark size calculation)
This commit is contained in:
parent
6826f59879
commit
c128ed907c
7 changed files with 596 additions and 215 deletions
|
|
@ -1,5 +1,21 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 32,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import rasterio"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
|
@ -33,13 +33,13 @@
|
|||
"\n",
|
||||
"This can be done by running the Docker container like this:\n",
|
||||
"\n",
|
||||
"```\n",
|
||||
"``` bash\n",
|
||||
"docker run -it --name=eratosthenes --net=host -v \"$(pwd)\":/home/jovyan -e SCIHUB_USERNAME=YOUR_USERNAME_HERE -e SCIHUB_PASSWORD=YOUR_PASSWORD_HERE eratosthenes:latest\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"The important part is\n",
|
||||
"The environment variables are defined via the `-e` flags:\n",
|
||||
"\n",
|
||||
"```\n",
|
||||
"``` bash\n",
|
||||
"-e SCIHUB_USERNAME=YOUR_USERNAME_HERE -e SCIHUB_PASSWORD=YOUR_PASSWORD_HERE\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
@ -78,7 +78,6 @@
|
|||
"\u001b[0;32mdef\u001b[0m \u001b[0msearch_osm\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mplace\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
|
||||
"\u001b[0;34m\u001b[0m \u001b[0;34m'''\u001b[0m\n",
|
||||
"\u001b[0;34m Returns a GeoDataFrame with results from OpenStreetMap Nominatim for the given search string.\u001b[0m\n",
|
||||
"\u001b[0;34m This allows us to fetch detailed geometries for virtually any place on earth.\u001b[0m\n",
|
||||
"\u001b[0;34m '''\u001b[0m\u001b[0;34m\u001b[0m\n",
|
||||
"\u001b[0;34m\u001b[0m \u001b[0murlescaped_place\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0murllib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparse\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mquote\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mplace\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
|
||||
"\u001b[0;34m\u001b[0m \u001b[0msearch_url\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m'https://nominatim.openstreetmap.org/search/?q={}'\u001b[0m \u001b[0;34m+\u001b[0m\u001b[0;34m\u001b[0m\n",
|
||||
|
|
@ -99,7 +98,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
@ -242,7 +241,7 @@
|
|||
"4 LINESTRING (9.41929 54.40283, 9.42072 54.40343... "
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
|
@ -258,7 +257,7 @@
|
|||
"source": [
|
||||
"OpenStreetMap contains geoinformation at vastly different scales and of very different types.\n",
|
||||
"We can use it to query outlines of parks or entire countries.\n",
|
||||
"You can consult the [OpenStreetMap wiki](https://wiki.openstreetmap.org/wiki/Main_Page) for more detailed information about this.\n",
|
||||
"The [OpenStreetMap wiki](https://wiki.openstreetmap.org/wiki/Main_Page) contains exhaustive information about the architectural design of OpenStreetMap.\n",
|
||||
"Using the `search_osm` function we are very flexible in the type of query information we can retrieve.\n",
|
||||
"\n",
|
||||
"The first result is the city's centroid.\n",
|
||||
|
|
@ -267,7 +266,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
@ -276,7 +275,7 @@
|
|||
"<AxesSubplot:>"
|
||||
]
|
||||
},
|
||||
"execution_count": 7,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
|
|
@ -307,7 +306,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
|
@ -328,7 +327,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
|
@ -338,7 +337,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
|
@ -357,7 +356,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
@ -366,10 +365,10 @@
|
|||
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"100.0\" height=\"100.0\" viewBox=\"13.061432364 52.311332164 0.7266411720000008 0.39108917200000093\" preserveAspectRatio=\"xMinYMin meet\"><g transform=\"matrix(1,0,0,-1,0,105.0137535)\"><path fill-rule=\"evenodd\" fill=\"#66cc99\" stroke=\"#555555\" stroke-width=\"0.014532823440000016\" opacity=\"0.6\" d=\"M 13.6477328,52.3382448 L 13.6474433,52.338271 L 13.131305,52.3872254 L 13.1310825,52.3872512 L 13.1307559,52.3873763 L 13.1298482,52.3878739 L 13.1267317,52.3895836 L 13.0907635,52.4115602 L 13.090275,52.4122142 L 13.088345,52.4196325 L 13.1284297,52.5860175 L 13.1289619,52.5873048 L 13.2827678,52.6607411 L 13.4794873,52.6755087 L 13.4884252,52.6707899 L 13.523022,52.6450365 L 13.7564462,52.4461766 L 13.7611609,52.4377097 L 13.76095,52.4373221 L 13.7390343,52.4073353 L 13.7342706,52.4021367 L 13.7341193,52.4019835 L 13.6922028,52.3672074 L 13.6513711,52.3392255 L 13.6509462,52.3389451 L 13.6506935,52.3388565 L 13.6488471,52.3383381 L 13.6484243,52.3382725 L 13.6477328,52.3382448 z\" /></g></svg>"
|
||||
],
|
||||
"text/plain": [
|
||||
"<shapely.geometry.polygon.Polygon at 0x7f9f50db5850>"
|
||||
"<shapely.geometry.polygon.Polygon at 0x7eff2c992f70>"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
|
@ -381,14 +380,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
|
@ -408,7 +400,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
@ -437,7 +429,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
@ -463,7 +455,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
|
@ -473,7 +465,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
@ -482,7 +474,7 @@
|
|||
"Text(0.5, 1.0, 'Area of interest, its convex hull and products returned from the API')"
|
||||
]
|
||||
},
|
||||
"execution_count": 19,
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
|
|
@ -530,7 +522,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
|
@ -542,7 +534,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
@ -755,7 +747,7 @@
|
|||
"[4 rows x 46 columns]"
|
||||
]
|
||||
},
|
||||
"execution_count": 22,
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
|
@ -777,7 +769,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
@ -838,7 +830,7 @@
|
|||
"11 S2A_MSIL2A_20200531T102031_N0214_R065_T33UUU_2... 16.512980"
|
||||
]
|
||||
},
|
||||
"execution_count": 23,
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
|
@ -851,20 +843,20 @@
|
|||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Let's download all of these `input/raster/true_color_image`.\n",
|
||||
"These files will all be downloaded to `input/true_color_image`.\n",
|
||||
"Repeated calls to `download` or `download_all` will skip the download process if a product has previously been downloaded."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from pathlib import Path\n",
|
||||
"from tqdm.notebook import tqdm\n",
|
||||
"\n",
|
||||
"dst_path = Path('input/raster/true_color_image')\n",
|
||||
"dst_path = Path('input/true_color_image')\n",
|
||||
"\n",
|
||||
"# we make sure to create the directory at dst_path so the notebook can run\n",
|
||||
"# without interruptions\n",
|
||||
|
|
@ -873,18 +865,18 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "2712654894614633a4ed79966cc800bf",
|
||||
"model_id": "185edfc889314c75b4439ed206f841c2",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"HBox(children=(HTML(value='Downloading'), FloatProgress(value=0.0, max=1176239030.0), HTML(value='')))"
|
||||
"HBox(children=(HTML(value='Downloading'), FloatProgress(value=0.0, max=854267363.0), HTML(value='')))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
|
|
@ -893,12 +885,12 @@
|
|||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "4b28f505606244e48130c39189b9aa7d",
|
||||
"model_id": "6184e8ca8e9b497281772959aec36667",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"HBox(children=(HTML(value='Downloading'), FloatProgress(value=0.0, max=854267363.0), HTML(value='')))"
|
||||
"HBox(children=(HTML(value='Downloading'), FloatProgress(value=0.0, max=1176239030.0), HTML(value='')))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
|
|
@ -914,7 +906,7 @@
|
|||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "84ddb85d0d9d40b58ae6154e36073314",
|
||||
"model_id": "89708f8829444d2a97f4027bdb2ef89e",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -935,7 +927,7 @@
|
|||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "d70de65cc52a4557bec958255acd42b0",
|
||||
"model_id": "d77e8bd4d7974b69b11308d281c1ea7c",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -956,7 +948,7 @@
|
|||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "08d8507b248d4048a0b7990a615a0955",
|
||||
"model_id": "bbca54e173524579be0f8eef722e7836",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -977,7 +969,7 @@
|
|||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "ec9a2b1fef1d45b5b1e3c0b5d6284d54",
|
||||
"model_id": "690ede9f7e354594b1f2e4e9cb8125b7",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -998,7 +990,7 @@
|
|||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "539f9521e1c14922a147a71ae0efaa4d",
|
||||
"model_id": "d43be7875cda424695d8213d71c8fbeb",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -1020,7 +1012,7 @@
|
|||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "238249047d1544bd8253015d60f1bc65",
|
||||
"model_id": "aeac449b826c44d3864d180ad8b81858",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -1030,6 +1022,72 @@
|
|||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\n",
|
||||
"CPU times: user 39.4 s, sys: 18.8 s, total: 58.2 s\n",
|
||||
"Wall time: 11min 51s\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'958ef7fc-815e-47c6-b323-219de6a91339': {'id': '958ef7fc-815e-47c6-b323-219de6a91339',\n",
|
||||
" 'title': 'S2A_MSIL2A_20200617T101031_N0214_R022_T33UUU_20200617T161854',\n",
|
||||
" 'size': 854267363,\n",
|
||||
" 'md5': 'E8E78FEEBF25D95E50A7E5E0C971C061',\n",
|
||||
" 'date': datetime.datetime(2020, 6, 17, 10, 10, 31, 24000),\n",
|
||||
" 'footprint': 'POLYGON((12.352510548540328 52.23126993496904,12.408603762795623 52.36271559980042,12.470993716931147 52.50836314366547,12.533637922787934 52.653880456978825,12.596456783078388 52.79937966494399,12.659608391506955 52.944876790325615,12.72334134983589 53.09033052896263,12.783072077326212 53.2261774473976,13.648341514492438 53.24196354764364,13.678544065009483 52.25515074878083,12.352510548540328 52.23126993496904))',\n",
|
||||
" 'url': \"https://scihub.copernicus.eu/apihub/odata/v1/Products('958ef7fc-815e-47c6-b323-219de6a91339')/$value\",\n",
|
||||
" 'Online': True,\n",
|
||||
" 'Creation Date': datetime.datetime(2020, 6, 17, 21, 36, 46, 539000),\n",
|
||||
" 'Ingestion Date': datetime.datetime(2020, 6, 17, 21, 35, 56, 836000),\n",
|
||||
" 'path': 'input/true_color_image/S2A_MSIL2A_20200617T101031_N0214_R022_T33UUU_20200617T161854.zip',\n",
|
||||
" 'downloaded_bytes': 854267363},\n",
|
||||
" 'b64d4450-d999-41dc-9ecb-6d263f322dd3': {'id': 'b64d4450-d999-41dc-9ecb-6d263f322dd3',\n",
|
||||
" 'title': 'S2B_MSIL2A_20200615T101559_N0214_R065_T33UUU_20200615T141117',\n",
|
||||
" 'size': 1176239030,\n",
|
||||
" 'md5': '86D9DB1D0C6C087D66AE28E4A106EF04',\n",
|
||||
" 'date': datetime.datetime(2020, 6, 15, 10, 15, 59, 24000),\n",
|
||||
" 'footprint': 'POLYGON((12.004760925069467 53.21197782662703,13.648341514492438 53.24196354764364,13.678544065009483 52.25515074878083,12.071595116334858 52.22621087043558,12.004760925069467 53.21197782662703))',\n",
|
||||
" 'url': \"https://scihub.copernicus.eu/apihub/odata/v1/Products('b64d4450-d999-41dc-9ecb-6d263f322dd3')/$value\",\n",
|
||||
" 'Online': True,\n",
|
||||
" 'Creation Date': datetime.datetime(2020, 6, 16, 1, 22, 2, 573000),\n",
|
||||
" 'Ingestion Date': datetime.datetime(2020, 6, 16, 1, 21, 9, 378000),\n",
|
||||
" 'path': 'input/true_color_image/S2B_MSIL2A_20200615T101559_N0214_R065_T33UUU_20200615T141117.zip',\n",
|
||||
" 'downloaded_bytes': 1176239030},\n",
|
||||
" '10190cf1-5690-48a3-b71e-861629703a3f': {'id': '10190cf1-5690-48a3-b71e-861629703a3f',\n",
|
||||
" 'title': 'S2B_MSIL2A_20200602T100559_N0214_R022_T33UUU_20200602T135324',\n",
|
||||
" 'size': 862966648,\n",
|
||||
" 'md5': 'A93C8F7AA12C2396CF57CFD02ADF21A2',\n",
|
||||
" 'date': datetime.datetime(2020, 6, 2, 10, 5, 59, 24000),\n",
|
||||
" 'footprint': 'POLYGON((12.358321903656456 52.23137459287384,12.415699786858166 52.36633012201262,12.47808001229512 52.51194199175493,12.5407946185535 52.65754848189568,12.603698138951865 52.80313660845604,12.667166015291048 52.94869104851679,12.731188091140115 53.09422646557383,12.789415151489028 53.226293171356296,13.648341514492438 53.24196354764364,13.678544065009483 52.25515074878083,12.358321903656456 52.23137459287384))',\n",
|
||||
" 'url': \"https://scihub.copernicus.eu/apihub/odata/v1/Products('10190cf1-5690-48a3-b71e-861629703a3f')/$value\",\n",
|
||||
" 'Online': True,\n",
|
||||
" 'Creation Date': datetime.datetime(2020, 6, 2, 18, 42, 4, 900000),\n",
|
||||
" 'Ingestion Date': datetime.datetime(2020, 6, 2, 18, 40, 43, 331000),\n",
|
||||
" 'path': 'input/true_color_image/S2B_MSIL2A_20200602T100559_N0214_R022_T33UUU_20200602T135324.zip',\n",
|
||||
" 'downloaded_bytes': 862966648},\n",
|
||||
" 'e385d397-4d1b-4fa2-a1ce-917f420c86dd': {'id': 'e385d397-4d1b-4fa2-a1ce-917f420c86dd',\n",
|
||||
" 'title': 'S2A_MSIL2A_20200531T102031_N0214_R065_T33UUU_20200531T134031',\n",
|
||||
" 'size': 1162711104,\n",
|
||||
" 'md5': '7E74A83DA5EA1176CFB68517E53A343D',\n",
|
||||
" 'date': datetime.datetime(2020, 5, 31, 10, 20, 31, 24000),\n",
|
||||
" 'footprint': 'POLYGON((12.004760925069467 53.21197782662703,13.648341514492438 53.24196354764364,13.678544065009483 52.25515074878083,12.071595116334858 52.22621087043558,12.004760925069467 53.21197782662703))',\n",
|
||||
" 'url': \"https://scihub.copernicus.eu/apihub/odata/v1/Products('e385d397-4d1b-4fa2-a1ce-917f420c86dd')/$value\",\n",
|
||||
" 'Online': True,\n",
|
||||
" 'Creation Date': datetime.datetime(2020, 5, 31, 20, 22, 5, 475000),\n",
|
||||
" 'Ingestion Date': datetime.datetime(2020, 5, 31, 20, 21, 27, 279000),\n",
|
||||
" 'path': 'input/true_color_image/S2A_MSIL2A_20200531T102031_N0214_R065_T33UUU_20200531T134031.zip',\n",
|
||||
" 'downloaded_bytes': 1162711104}}"
|
||||
]
|
||||
},
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
|
|
@ -1041,14 +1099,14 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Downloaded 0.00GB\n"
|
||||
"Downloaded 3.78GB\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@
|
|||
"source": [
|
||||
"from pathlib import Path\n",
|
||||
"\n",
|
||||
"raster_files = Path('input/raster/true_color_image')\n",
|
||||
"raster_files = Path('input/true_color_image')\n",
|
||||
"product = list(raster_files.glob('S2B_MSIL2A_20200602T100559*.zip'))[0]\n",
|
||||
"product"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2396,7 +2396,11 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
"# we create the directory structure we need for downloading our mosaic tiles\n",
|
||||
"! mkdir -p input/raster/brandenburg_mosaic"
|
||||
"from pathlib import Path\n",
|
||||
"from tqdm.notebook import tqdm\n",
|
||||
"\n",
|
||||
"output_dir = Path('input/brandenburg_mosaic')\n",
|
||||
"output_dir.mkdir(exist_ok=True, parents=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -2423,7 +2427,8 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
"products_subset = {idx: products[idx] for idx in to_download.index}\n",
|
||||
"downloaded, _, _ = api.download_all(products_subset, 'input/raster/brandenburg_mosaic')\n",
|
||||
"api._tqdm = tqdm # ← monkey-patch for nicer progress bar\n",
|
||||
"downloaded, _, _ = api.download_all(products_subset, output_dir)\n",
|
||||
"downloaded_paths = [d['path'] for d in downloaded.values()]"
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
"- Instead of focusing on all fires in an entire year, we focus on several firest that were covered well\n",
|
||||
"- → Jueterbog / Luckenwalde\n",
|
||||
" - 2018/08/24: https://www.dw.com/en/forest-fires-near-berlin-could-burn-for-days/a-45203042\n",
|
||||
" - Article says \"fires began on thursday\", i.e. 2018/08/23\n",
|
||||
" - 2019\n",
|
||||
" - Fire in June (\"einer der größten Brände der letzten Jahrzehnte\") https://web.archive.org/web/20190622070809/https://www.rbb24.de/panorama/beitrag/2019/06/waldbrand-jueterbog-sonntag-lage-unter-kontrolle.html\n",
|
||||
" - Another fire in July https://web.archive.org/web/20190730000919/https://www.rbb24.de/panorama/beitrag/2019/07/loescharbeiten-jueterbog-truppenuebungsplatz-brandenburg.html"
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,3 +1,4 @@
|
|||
from dateutil.parser import parse as parse_datetime
|
||||
import urllib.parse
|
||||
from pathlib import Path
|
||||
|
||||
|
|
@ -22,7 +23,6 @@ import warnings
|
|||
def search_osm(place):
|
||||
'''
|
||||
Returns a GeoDataFrame with results from OpenStreetMap Nominatim for the given search string.
|
||||
This allows us to fetch detailed geometries for virtually any place on earth.
|
||||
'''
|
||||
urlescaped_place = urllib.parse.quote(place)
|
||||
search_url = ('https://nominatim.openstreetmap.org/search/?q={}' +
|
||||
|
|
@ -90,15 +90,15 @@ def scihub_band_paths(p, bands, resolution=None):
|
|||
rasters = p.glob('**/*.jp2')
|
||||
|
||||
# take only the paths that contain one of the given bands
|
||||
rasters = [raster for band in bands for raster in rasters if band in raster]
|
||||
rasters = [Path(raster) for band in bands for raster in rasters if band in raster]
|
||||
|
||||
# if a resolution is given, further discard the bands we don't need
|
||||
if resolution:
|
||||
rasters = [raster for raster in rasters if resolution in raster]
|
||||
rasters = [raster for raster in rasters if resolution in raster.name]
|
||||
|
||||
if p.suffix == '.zip':
|
||||
# we have to reformat the paths to
|
||||
rasters = [f'zip+file://{p}!/{r}' for r in rasters]
|
||||
rasters = [Path(f'zip+file://{p}!/{r.name}') for r in rasters]
|
||||
|
||||
return rasters
|
||||
|
||||
|
|
@ -179,6 +179,18 @@ def scihub_normalize_range(v):
|
|||
'''
|
||||
return np.clip(v, 0, 2000) / 2000
|
||||
|
||||
|
||||
def scihub_band_date(band):
|
||||
'''
|
||||
Given a string, `pathlib.Path` or `rasterio.DataSetReader`, returns the
|
||||
datetime encoded in the filename.
|
||||
'''
|
||||
if type(band) is r.DatasetReader:
|
||||
file_name = band.name
|
||||
else:
|
||||
file_name = Path(band).name
|
||||
return parse_datetime(file_name.split('_')[-3])
|
||||
|
||||
|
||||
# TODO: This is documented somewhere in the python docs, we should link to it here
|
||||
|
||||
|
|
@ -215,3 +227,4 @@ def geodataframe_on_map(geodataframe):
|
|||
folium.GeoJson(geodataframe.to_json()).add_to(m)
|
||||
m.fit_bounds([[miny, minx], [maxy, maxx]])
|
||||
return m
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue