|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [], |
| 8 | + "source": [ |
| 9 | + "%load_ext autoreload\n", |
| 10 | + "%autoreload 2" |
| 11 | + ] |
| 12 | + }, |
| 13 | + { |
| 14 | + "cell_type": "code", |
| 15 | + "execution_count": 3, |
| 16 | + "metadata": {}, |
| 17 | + "outputs": [ |
| 18 | + { |
| 19 | + "data": { |
| 20 | + "text/plain": [ |
| 21 | + "'2024.11.07'" |
| 22 | + ] |
| 23 | + }, |
| 24 | + "execution_count": 3, |
| 25 | + "metadata": {}, |
| 26 | + "output_type": "execute_result" |
| 27 | + } |
| 28 | + ], |
| 29 | + "source": [ |
| 30 | + "import eotdl\n", |
| 31 | + "\n", |
| 32 | + "eotdl.__version__" |
| 33 | + ] |
| 34 | + }, |
| 35 | + { |
| 36 | + "cell_type": "markdown", |
| 37 | + "metadata": {}, |
| 38 | + "source": [ |
| 39 | + "In this notebook we generate the dataset for the use case\n", |
| 40 | + "\n", |
| 41 | + "1. Generate list of Satellogic images to be used (containing bb and acquisition time)\n", |
| 42 | + "2. Explore available S1/S2 images with different criteria\n", |
| 43 | + "\t- bounding box overlap\n", |
| 44 | + "\t- acquisition time overlap\n", |
| 45 | + "3. Download matching S1/S2 at given resolution\n", |
| 46 | + "4. Generate metadata and ingest to EOTDL " |
| 47 | + ] |
| 48 | + }, |
| 49 | + { |
| 50 | + "cell_type": "code", |
| 51 | + "execution_count": 16, |
| 52 | + "metadata": {}, |
| 53 | + "outputs": [ |
| 54 | + { |
| 55 | + "ename": "ImportError", |
| 56 | + "evalue": "Missing optional dependency 'pyarrow.parquet'. pyarrow is required for Parquet support. \"\n \"Use pip or conda to install pyarrow.parquet.", |
| 57 | + "output_type": "error", |
| 58 | + "traceback": [ |
| 59 | + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 60 | + "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", |
| 61 | + "Cell \u001b[0;32mIn[16], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mgeopandas\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mgpd\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m gdf \u001b[38;5;241m=\u001b[39m \u001b[43mgpd\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_parquet\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43msatellogic-earthview-items.parquet\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 5\u001b[0m gdf\u001b[38;5;241m.\u001b[39mhead()\n", |
| 62 | + "File \u001b[0;32m~/miniconda3/envs/eotdl/lib/python3.8/site-packages/geopandas/io/arrow.py:586\u001b[0m, in \u001b[0;36m_read_parquet\u001b[0;34m(path, columns, storage_options, **kwargs)\u001b[0m\n\u001b[1;32m 523\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_read_parquet\u001b[39m(path, columns\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, storage_options\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 524\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 525\u001b[0m \u001b[38;5;124;03m Load a Parquet object from the file path, returning a GeoDataFrame.\u001b[39;00m\n\u001b[1;32m 526\u001b[0m \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 583\u001b[0m \u001b[38;5;124;03m ... ) # doctest: +SKIP\u001b[39;00m\n\u001b[1;32m 584\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 586\u001b[0m parquet \u001b[38;5;241m=\u001b[39m \u001b[43mimport_optional_dependency\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 587\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpyarrow.parquet\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mextra\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpyarrow is required for Parquet support.\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m 588\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 589\u001b[0m \u001b[38;5;66;03m# TODO(https://github.com/pandas-dev/pandas/pull/41194): see if pandas\u001b[39;00m\n\u001b[1;32m 590\u001b[0m \u001b[38;5;66;03m# adds filesystem as a keyword and match that.\u001b[39;00m\n\u001b[1;32m 591\u001b[0m filesystem \u001b[38;5;241m=\u001b[39m kwargs\u001b[38;5;241m.\u001b[39mpop(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfilesystem\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n", |
| 63 | + "File \u001b[0;32m~/miniconda3/envs/eotdl/lib/python3.8/site-packages/geopandas/_compat.py:239\u001b[0m, in \u001b[0;36mimport_optional_dependency\u001b[0;34m(name, extra)\u001b[0m\n\u001b[1;32m 236\u001b[0m module \u001b[38;5;241m=\u001b[39m importlib\u001b[38;5;241m.\u001b[39mimport_module(name)\n\u001b[1;32m 238\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mImportError\u001b[39;00m:\n\u001b[0;32m--> 239\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mImportError\u001b[39;00m(msg) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 241\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m module\n", |
| 64 | + "\u001b[0;31mImportError\u001b[0m: Missing optional dependency 'pyarrow.parquet'. pyarrow is required for Parquet support. \"\n \"Use pip or conda to install pyarrow.parquet." |
| 65 | + ] |
| 66 | + } |
| 67 | + ], |
| 68 | + "source": [ |
| 69 | + "import geopandas as gpd\n", |
| 70 | + "\n", |
| 71 | + "gdf = gpd.read_parquet('satellogic-earthview-items.parquet')\n", |
| 72 | + "\n", |
| 73 | + "gdf.head()" |
| 74 | + ] |
| 75 | + }, |
| 76 | + { |
| 77 | + "cell_type": "code", |
| 78 | + "execution_count": 14, |
| 79 | + "metadata": {}, |
| 80 | + "outputs": [ |
| 81 | + { |
| 82 | + "data": { |
| 83 | + "text/html": [ |
| 84 | + "<div>\n", |
| 85 | + "<style scoped>\n", |
| 86 | + " .dataframe tbody tr th:only-of-type {\n", |
| 87 | + " vertical-align: middle;\n", |
| 88 | + " }\n", |
| 89 | + "\n", |
| 90 | + " .dataframe tbody tr th {\n", |
| 91 | + " vertical-align: top;\n", |
| 92 | + " }\n", |
| 93 | + "\n", |
| 94 | + " .dataframe thead th {\n", |
| 95 | + " text-align: right;\n", |
| 96 | + " }\n", |
| 97 | + "</style>\n", |
| 98 | + "<table border=\"1\" class=\"dataframe\">\n", |
| 99 | + " <thead>\n", |
| 100 | + " <tr style=\"text-align: right;\">\n", |
| 101 | + " <th></th>\n", |
| 102 | + " <th>json_path</th>\n", |
| 103 | + " <th>zone</th>\n", |
| 104 | + " <th>region</th>\n", |
| 105 | + " <th>date</th>\n", |
| 106 | + " <th>geometry</th>\n", |
| 107 | + " </tr>\n", |
| 108 | + " </thead>\n", |
| 109 | + " <tbody>\n", |
| 110 | + " <tr>\n", |
| 111 | + " <th>6359888</th>\n", |
| 112 | + " <td>data/json/zone=52N/region=459797_5663847/date=...</td>\n", |
| 113 | + " <td>52N</td>\n", |
| 114 | + " <td>459797_5663847</td>\n", |
| 115 | + " <td>2022-08-17</td>\n", |
| 116 | + " <td>POLYGON ((128.43105 51.12126, 128.431 51.12471...</td>\n", |
| 117 | + " </tr>\n", |
| 118 | + " <tr>\n", |
| 119 | + " <th>215988</th>\n", |
| 120 | + " <td>data/json/zone=11N/region=382331_3724370/date=...</td>\n", |
| 121 | + " <td>11N</td>\n", |
| 122 | + " <td>382331_3724370</td>\n", |
| 123 | + " <td>2022-08-19</td>\n", |
| 124 | + " <td>POLYGON ((-118.26482 33.64927, -118.26487 33.6...</td>\n", |
| 125 | + " </tr>\n", |
| 126 | + " <tr>\n", |
| 127 | + " <th>2974338</th>\n", |
| 128 | + " <td>data/json/zone=33N/region=513218_5942952/date=...</td>\n", |
| 129 | + " <td>33N</td>\n", |
| 130 | + " <td>513218_5942952</td>\n", |
| 131 | + " <td>2022-07-20</td>\n", |
| 132 | + " <td>POLYGON ((15.2057 53.63172, 15.20571 53.63518,...</td>\n", |
| 133 | + " </tr>\n", |
| 134 | + " <tr>\n", |
| 135 | + " <th>1772806</th>\n", |
| 136 | + " <td>data/json/zone=21S/region=318055_6186838/date=...</td>\n", |
| 137 | + " <td>21S</td>\n", |
| 138 | + " <td>318055_6186838</td>\n", |
| 139 | + " <td>2022-10-04</td>\n", |
| 140 | + " <td>POLYGON ((-58.97634 -34.44749, -58.97626 -34.4...</td>\n", |
| 141 | + " </tr>\n", |
| 142 | + " <tr>\n", |
| 143 | + " <th>1568382</th>\n", |
| 144 | + " <td>data/json/zone=19S/region=548665_3929270/date=...</td>\n", |
| 145 | + " <td>19S</td>\n", |
| 146 | + " <td>548665_3929270</td>\n", |
| 147 | + " <td>2022-09-22</td>\n", |
| 148 | + " <td>POLYGON ((-68.2373 -54.78482, -68.23737 -54.78...</td>\n", |
| 149 | + " </tr>\n", |
| 150 | + " <tr>\n", |
| 151 | + " <th>2659472</th>\n", |
| 152 | + " <td>data/json/zone=31N/region=323352_4603510/date=...</td>\n", |
| 153 | + " <td>31N</td>\n", |
| 154 | + " <td>323352_4603510</td>\n", |
| 155 | + " <td>2022-07-03</td>\n", |
| 156 | + " <td>POLYGON ((0.88621 41.56039, 0.88609 41.56384, ...</td>\n", |
| 157 | + " </tr>\n", |
| 158 | + " <tr>\n", |
| 159 | + " <th>5831807</th>\n", |
| 160 | + " <td>data/json/zone=46N/region=381011_2484734/date=...</td>\n", |
| 161 | + " <td>46N</td>\n", |
| 162 | + " <td>381011_2484734</td>\n", |
| 163 | + " <td>2022-12-27</td>\n", |
| 164 | + " <td>POLYGON ((91.84725 22.46136, 91.84722 22.46482...</td>\n", |
| 165 | + " </tr>\n", |
| 166 | + " <tr>\n", |
| 167 | + " <th>4175206</th>\n", |
| 168 | + " <td>data/json/zone=39N/region=476124_2742046/date=...</td>\n", |
| 169 | + " <td>39N</td>\n", |
| 170 | + " <td>476124_2742046</td>\n", |
| 171 | + " <td>2022-10-10</td>\n", |
| 172 | + " <td>POLYGON ((50.76759 24.78952, 50.76759 24.79299...</td>\n", |
| 173 | + " </tr>\n", |
| 174 | + " <tr>\n", |
| 175 | + " <th>2495235</th>\n", |
| 176 | + " <td>data/json/zone=30N/region=344790_4527000/date=...</td>\n", |
| 177 | + " <td>30N</td>\n", |
| 178 | + " <td>344790_4527000</td>\n", |
| 179 | + " <td>2022-08-22</td>\n", |
| 180 | + " <td>POLYGON ((-4.83746 40.87599, -4.83755 40.87945...</td>\n", |
| 181 | + " </tr>\n", |
| 182 | + " <tr>\n", |
| 183 | + " <th>2362734</th>\n", |
| 184 | + " <td>data/json/zone=29N/region=796457_1461650/date=...</td>\n", |
| 185 | + " <td>29N</td>\n", |
| 186 | + " <td>796457_1461650</td>\n", |
| 187 | + " <td>2022-11-02</td>\n", |
| 188 | + " <td>POLYGON ((-6.26135 13.20354, -6.26131 13.20701...</td>\n", |
| 189 | + " </tr>\n", |
| 190 | + " </tbody>\n", |
| 191 | + "</table>\n", |
| 192 | + "</div>" |
| 193 | + ], |
| 194 | + "text/plain": [ |
| 195 | + " json_path zone \\\n", |
| 196 | + "6359888 data/json/zone=52N/region=459797_5663847/date=... 52N \n", |
| 197 | + "215988 data/json/zone=11N/region=382331_3724370/date=... 11N \n", |
| 198 | + "2974338 data/json/zone=33N/region=513218_5942952/date=... 33N \n", |
| 199 | + "1772806 data/json/zone=21S/region=318055_6186838/date=... 21S \n", |
| 200 | + "1568382 data/json/zone=19S/region=548665_3929270/date=... 19S \n", |
| 201 | + "2659472 data/json/zone=31N/region=323352_4603510/date=... 31N \n", |
| 202 | + "5831807 data/json/zone=46N/region=381011_2484734/date=... 46N \n", |
| 203 | + "4175206 data/json/zone=39N/region=476124_2742046/date=... 39N \n", |
| 204 | + "2495235 data/json/zone=30N/region=344790_4527000/date=... 30N \n", |
| 205 | + "2362734 data/json/zone=29N/region=796457_1461650/date=... 29N \n", |
| 206 | + "\n", |
| 207 | + " region date \\\n", |
| 208 | + "6359888 459797_5663847 2022-08-17 \n", |
| 209 | + "215988 382331_3724370 2022-08-19 \n", |
| 210 | + "2974338 513218_5942952 2022-07-20 \n", |
| 211 | + "1772806 318055_6186838 2022-10-04 \n", |
| 212 | + "1568382 548665_3929270 2022-09-22 \n", |
| 213 | + "2659472 323352_4603510 2022-07-03 \n", |
| 214 | + "5831807 381011_2484734 2022-12-27 \n", |
| 215 | + "4175206 476124_2742046 2022-10-10 \n", |
| 216 | + "2495235 344790_4527000 2022-08-22 \n", |
| 217 | + "2362734 796457_1461650 2022-11-02 \n", |
| 218 | + "\n", |
| 219 | + " geometry \n", |
| 220 | + "6359888 POLYGON ((128.43105 51.12126, 128.431 51.12471... \n", |
| 221 | + "215988 POLYGON ((-118.26482 33.64927, -118.26487 33.6... \n", |
| 222 | + "2974338 POLYGON ((15.2057 53.63172, 15.20571 53.63518,... \n", |
| 223 | + "1772806 POLYGON ((-58.97634 -34.44749, -58.97626 -34.4... \n", |
| 224 | + "1568382 POLYGON ((-68.2373 -54.78482, -68.23737 -54.78... \n", |
| 225 | + "2659472 POLYGON ((0.88621 41.56039, 0.88609 41.56384, ... \n", |
| 226 | + "5831807 POLYGON ((91.84725 22.46136, 91.84722 22.46482... \n", |
| 227 | + "4175206 POLYGON ((50.76759 24.78952, 50.76759 24.79299... \n", |
| 228 | + "2495235 POLYGON ((-4.83746 40.87599, -4.83755 40.87945... \n", |
| 229 | + "2362734 POLYGON ((-6.26135 13.20354, -6.26131 13.20701... " |
| 230 | + ] |
| 231 | + }, |
| 232 | + "execution_count": 14, |
| 233 | + "metadata": {}, |
| 234 | + "output_type": "execute_result" |
| 235 | + } |
| 236 | + ], |
| 237 | + "source": [ |
| 238 | + "sample = gdf.sample(10)\n", |
| 239 | + "sample" |
| 240 | + ] |
| 241 | + }, |
| 242 | + { |
| 243 | + "cell_type": "code", |
| 244 | + "execution_count": 13, |
| 245 | + "metadata": {}, |
| 246 | + "outputs": [ |
| 247 | + { |
| 248 | + "data": { |
| 249 | + "text/plain": [ |
| 250 | + "('sentinel-1-grd', 'sentinel-2-l1c', 'sentinel-2-l2a', 'dem')" |
| 251 | + ] |
| 252 | + }, |
| 253 | + "execution_count": 13, |
| 254 | + "metadata": {}, |
| 255 | + "output_type": "execute_result" |
| 256 | + } |
| 257 | + ], |
| 258 | + "source": [ |
| 259 | + "from eotdl.access import SUPPORTED_SENSORS\n", |
| 260 | + "\n", |
| 261 | + "SUPPORTED_SENSORS" |
| 262 | + ] |
| 263 | + }, |
| 264 | + { |
| 265 | + "cell_type": "code", |
| 266 | + "execution_count": 15, |
| 267 | + "metadata": {}, |
| 268 | + "outputs": [ |
| 269 | + { |
| 270 | + "ename": "NameError", |
| 271 | + "evalue": "name 'sample' is not defined", |
| 272 | + "output_type": "error", |
| 273 | + "traceback": [ |
| 274 | + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 275 | + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", |
| 276 | + "Cell \u001b[0;32mIn[15], line 4\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01meotdl\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01maccess\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m search_sentinel_imagery\n\u001b[1;32m 3\u001b[0m matches \u001b[38;5;241m=\u001b[39m []\n\u001b[0;32m----> 4\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m item \u001b[38;5;129;01min\u001b[39;00m \u001b[43msample\u001b[49m:\n\u001b[1;32m 5\u001b[0m \tdates \u001b[38;5;241m=\u001b[39m item\u001b[38;5;241m.\u001b[39mdate\n\u001b[1;32m 6\u001b[0m \tbb \u001b[38;5;241m=\u001b[39m item\u001b[38;5;241m.\u001b[39mgeometry\n", |
| 277 | + "\u001b[0;31mNameError\u001b[0m: name 'sample' is not defined" |
| 278 | + ] |
| 279 | + } |
| 280 | + ], |
| 281 | + "source": [ |
| 282 | + "from eotdl.access import search_sentinel_imagery\n", |
| 283 | + "\n", |
| 284 | + "matches = []\n", |
| 285 | + "for item in sample:\n", |
| 286 | + "\tdates = item.date\n", |
| 287 | + "\tbb = item.geometry\n", |
| 288 | + "\tr = search_sentinel_imagery(dates, bb, 'sentinel-2-l2a')\n", |
| 289 | + "\tlist(r)" |
| 290 | + ] |
| 291 | + }, |
| 292 | + { |
| 293 | + "cell_type": "code", |
| 294 | + "execution_count": null, |
| 295 | + "metadata": {}, |
| 296 | + "outputs": [], |
| 297 | + "source": [] |
| 298 | + } |
| 299 | + ], |
| 300 | + "metadata": { |
| 301 | + "kernelspec": { |
| 302 | + "display_name": ".venv", |
| 303 | + "language": "python", |
| 304 | + "name": "python3" |
| 305 | + }, |
| 306 | + "language_info": { |
| 307 | + "codemirror_mode": { |
| 308 | + "name": "ipython", |
| 309 | + "version": 3 |
| 310 | + }, |
| 311 | + "file_extension": ".py", |
| 312 | + "mimetype": "text/x-python", |
| 313 | + "name": "python", |
| 314 | + "nbconvert_exporter": "python", |
| 315 | + "pygments_lexer": "ipython3", |
| 316 | + "version": "3.12.7" |
| 317 | + } |
| 318 | + }, |
| 319 | + "nbformat": 4, |
| 320 | + "nbformat_minor": 2 |
| 321 | +} |
0 commit comments