{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "3c51cd02-30bf-4451-acc1-df67c74b077d", "metadata": {}, "outputs": [], "source": [ "import geopandas as gpd\n", "import pandas as pd" ] }, { "cell_type": "markdown", "id": "450102c6-f83c-45b0-9a4c-367e74c64931", "metadata": {}, "source": [ "# Select background tiles" ] }, { "cell_type": "code", "execution_count": 2, "id": "3a48992e-c1a5-4b40-980a-2e90ebc87bdb", "metadata": {}, "outputs": [], "source": [ "# To use satellite imagery, the `xyzserives` must be installed\n", "try:\n", " import xyzservices\n", "\n", " tiles = xyzservices.providers[\"Esri\"][\"WorldImagery\"]\n", "except:\n", " # Use default\n", " tiles = None" ] }, { "cell_type": "markdown", "id": "44183ae7-fb8c-4487-a24e-7e68657b9fb6", "metadata": {}, "source": [ "# Loading data" ] }, { "cell_type": "code", "execution_count": 3, "id": "b60271f1-fe0e-4b01-8642-8477e6bc4f08", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
frame_idtotal_num_burstsburst_id_jplsensing_datenum_candidate_bursts
08315022t004_006641_iw12017-02-155298
18315022t004_006641_iw12017-02-275298
28315022t004_006641_iw12017-03-115298
\n", "
" ], "text/plain": [ " frame_id total_num_bursts burst_id_jpl sensing_date \\\n", "0 831 5022 t004_006641_iw1 2017-02-15 \n", "1 831 5022 t004_006641_iw1 2017-02-27 \n", "2 831 5022 t004_006641_iw1 2017-03-11 \n", "\n", " num_candidate_bursts \n", "0 5298 \n", "1 5298 \n", "2 5298 " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_selected_bursts = pd.read_csv(\n", " \"selected_bursts_option0.csv.zip\", parse_dates=[\"sensing_date\"]\n", ")\n", "df_selected_bursts.sensing_date = df_selected_bursts.sensing_date.dt.date\n", "\n", "\n", "df_selected_bursts.head(3)" ] }, { "cell_type": "code", "execution_count": 4, "id": "42c00025-a689-4767-ae33-d9ea0239e2dc", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
date_count
burst_id_jpl
t004_006641_iw1186
t004_006641_iw2186
t004_006641_iw3186
t004_006642_iw1186
t004_006642_iw2186
\n", "
" ], "text/plain": [ " date_count\n", "burst_id_jpl \n", "t004_006641_iw1 186\n", "t004_006641_iw2 186\n", "t004_006641_iw3 186\n", "t004_006642_iw1 186\n", "t004_006642_iw2 186" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_selected_bursts_grouped = (\n", " df_selected_bursts[[\"burst_id_jpl\", \"frame_id\"]]\n", " .groupby((\"burst_id_jpl\"))\n", " .count()\n", " .rename({\"frame_id\": \"date_count\"}, axis=1)\n", ")\n", "\n", "df_selected_bursts_grouped.head()" ] }, { "cell_type": "code", "execution_count": 5, "id": "d91d08f5-cc68-40ee-876e-445249e2757b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
frame_idburst_id_jplorbit_passgeometry
01653t007_013218_iw1ASCENDINGMULTIPOLYGON (((-157.82827 55.48763, -157.1283...
11653t007_013222_iw3ASCENDINGMULTIPOLYGON (((-155.37657 56.54824, -154.7210...
21653t007_013225_iw2ASCENDINGMULTIPOLYGON (((-156.93933 56.84940, -156.1855...
\n", "
" ], "text/plain": [ " frame_id burst_id_jpl orbit_pass \\\n", "0 1653 t007_013218_iw1 ASCENDING \n", "1 1653 t007_013222_iw3 ASCENDING \n", "2 1653 t007_013225_iw2 ASCENDING \n", "\n", " geometry \n", "0 MULTIPOLYGON (((-157.82827 55.48763, -157.1283... \n", "1 MULTIPOLYGON (((-155.37657 56.54824, -154.7210... \n", "2 MULTIPOLYGON (((-156.93933 56.84940, -156.1855... " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_burst_geoms = gpd.read_file(\"na_bursts_with_geom.geojson.zip\")\n", "df_burst_geoms.head(3)" ] }, { "cell_type": "code", "execution_count": 6, "id": "a02f2b4d-8fb0-4679-9bf9-1390448533d8", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
burst_id_jpldate_countframe_idorbit_passgeometry
0t004_006641_iw1186831ASCENDINGMULTIPOLYGON (((-77.59315 33.46137, -77.11728 ...
1t004_006641_iw2186831ASCENDINGMULTIPOLYGON (((-76.71825 33.66354, -76.22176 ...
2t004_006641_iw3186831ASCENDINGMULTIPOLYGON (((-75.79204 33.85517, -75.35592 ...
3t004_006642_iw1186831ASCENDINGMULTIPOLYGON (((-77.63169 33.62745, -77.15485 ...
4t004_006642_iw2186831ASCENDINGMULTIPOLYGON (((-76.75500 33.82960, -76.25752 ...
\n", "
" ], "text/plain": [ " burst_id_jpl date_count frame_id orbit_pass \\\n", "0 t004_006641_iw1 186 831 ASCENDING \n", "1 t004_006641_iw2 186 831 ASCENDING \n", "2 t004_006641_iw3 186 831 ASCENDING \n", "3 t004_006642_iw1 186 831 ASCENDING \n", "4 t004_006642_iw2 186 831 ASCENDING \n", "\n", " geometry \n", "0 MULTIPOLYGON (((-77.59315 33.46137, -77.11728 ... \n", "1 MULTIPOLYGON (((-76.71825 33.66354, -76.22176 ... \n", "2 MULTIPOLYGON (((-75.79204 33.85517, -75.35592 ... \n", "3 MULTIPOLYGON (((-77.63169 33.62745, -77.15485 ... \n", "4 MULTIPOLYGON (((-76.75500 33.82960, -76.25752 ... " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_burst_count = pd.merge(df_selected_bursts_grouped, df_burst_geoms, on=\"burst_id_jpl\")\n", "df_burst_count = gpd.GeoDataFrame(df_burst_count, geometry=\"geometry\")\n", "df_burst_count.head()" ] }, { "cell_type": "code", "execution_count": 7, "id": "de0c425f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
frame_idgeometrydate_countorbit_passpath_number
0831POLYGON ((-77.63462 33.64007, -77.67350 33.807...186ASCENDING4
1832POLYGON ((-77.94234 34.97052, -77.98167 35.136...387ASCENDING4
2833POLYGON ((-78.25450 36.29876, -78.29421 36.463...402ASCENDING4
3834POLYGON ((-78.57216 37.62689, -78.61245 37.791...399ASCENDING4
4835POLYGON ((-78.89565 38.95445, -78.93684 39.119...394ASCENDING4
..................
142846541POLYGON ((-134.76723 56.39017, -135.42777 56.4...284DESCENDING174
142946542POLYGON ((-135.18571 55.07265, -135.82487 55.1...271DESCENDING174
143046543POLYGON ((-135.58757 53.75420, -136.20699 53.8...264DESCENDING174
143146799MULTIPOLYGON (((-151.98765 70.03128, -153.1816...2DESCENDING175
143246800POLYGON ((-149.95093 69.73885, -150.09686 69.5...1DESCENDING175
\n", "

1433 rows × 5 columns

\n", "
" ], "text/plain": [ " frame_id geometry date_count \\\n", "0 831 POLYGON ((-77.63462 33.64007, -77.67350 33.807... 186 \n", "1 832 POLYGON ((-77.94234 34.97052, -77.98167 35.136... 387 \n", "2 833 POLYGON ((-78.25450 36.29876, -78.29421 36.463... 402 \n", "3 834 POLYGON ((-78.57216 37.62689, -78.61245 37.791... 399 \n", "4 835 POLYGON ((-78.89565 38.95445, -78.93684 39.119... 394 \n", "... ... ... ... \n", "1428 46541 POLYGON ((-134.76723 56.39017, -135.42777 56.4... 284 \n", "1429 46542 POLYGON ((-135.18571 55.07265, -135.82487 55.1... 271 \n", "1430 46543 POLYGON ((-135.58757 53.75420, -136.20699 53.8... 264 \n", "1431 46799 MULTIPOLYGON (((-151.98765 70.03128, -153.1816... 2 \n", "1432 46800 POLYGON ((-149.95093 69.73885, -150.09686 69.5... 1 \n", "\n", " orbit_pass path_number \n", "0 ASCENDING 4 \n", "1 ASCENDING 4 \n", "2 ASCENDING 4 \n", "3 ASCENDING 4 \n", "4 ASCENDING 4 \n", "... ... ... \n", "1428 DESCENDING 174 \n", "1429 DESCENDING 174 \n", "1430 DESCENDING 174 \n", "1431 DESCENDING 175 \n", "1432 DESCENDING 175 \n", "\n", "[1433 rows x 5 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Aggregate burst-wise polygons\n", "frame_based = df_burst_count.dissolve(by='frame_id').reset_index()\n", "frame_based[\"path_number\"] = frame_based.burst_id_jpl.str[1:4].astype(int)\n", "frame_based = frame_based.drop(columns='burst_id_jpl')\n", "frame_based" ] }, { "cell_type": "markdown", "id": "45f2dd42-3164-4ed8-98bf-f82ad28a51c7", "metadata": {}, "source": [ "# View Ascending Frames" ] }, { "cell_type": "code", "execution_count": 8, "id": "9bf12ea4-f24e-4fc3-b223-877e9a2bf357", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "frame_based[frame_based.orbit_pass == \"ASCENDING\"].explore(tiles=tiles, color='red')" ] }, { "cell_type": "markdown", "id": "bae98fee", "metadata": {}, "source": [ "# View Descending Frames" ] }, { "cell_type": "code", "execution_count": 9, "id": "f59090d5", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "frame_based[frame_based.orbit_pass == \"DESCENDING\"].explore(tiles=tiles)" ] }, { "cell_type": "code", "execution_count": null, "id": "0a96bf76", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 5 }