1637 lines
847 KiB
Plaintext
1637 lines
847 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import shutil\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import numpy as np\n",
|
||
|
"import pandas as pd\n",
|
||
|
"from pandas_path import path # noqa\n",
|
||
|
"from pathlib import Path\n",
|
||
|
"from PIL import Image\n",
|
||
|
"import pytorch_lightning as pl\n",
|
||
|
"import torch"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"tags": []
|
||
|
},
|
||
|
"source": [
|
||
|
"<a id=\"explore-the-data\"></a>\n",
|
||
|
"\n",
|
||
|
"### Explore the data"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"DATA_DIR = Path(\"data\")\n",
|
||
|
"TRAIN_FEATURES = DATA_DIR / \"train_features\"\n",
|
||
|
"TRAIN_LABELS = DATA_DIR / \"train_labels\"\n",
|
||
|
"\n",
|
||
|
"assert TRAIN_FEATURES.exists()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"The training data consists of 11,748 \"chips\". Each chip is imagery of a specific area captured at a specific point in time. There are four images associated with each chip in the competition data. Each image within a chip captures light from a different range of wavelengths, or \"band\". For example, the B02 band for each chip shows the strengh of visible blue light, which has a wavelength around 492 nanometers (nm). The bands provided are:\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"<table border=\"1\" class=\"table\" style=\"width:70%; margin-left:auto; margin-right:auto\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th>Band</th>\n",
|
||
|
" <th>Description</th>\n",
|
||
|
" <th>Center wavelength</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <td>B02</td>\n",
|
||
|
" <td>Blue visible light</td>\n",
|
||
|
" <td>497 nm</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <td>B03</td>\n",
|
||
|
" <td>Green visible light</td>\n",
|
||
|
" <td>560 nm</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <td>B04</td>\n",
|
||
|
" <td>Red visible light</td>\n",
|
||
|
" <td>665 nm</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <td>B08</td>\n",
|
||
|
" <td>Near infrared light</td>\n",
|
||
|
" <td>835 nm</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"BANDS = [\"B02\", \"B03\", \"B04\", \"B08\"]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"#### Metadata"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Let's start by looking at the metadata for the train and test sets, to understand what the images in this competition capture."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>chip_id</th>\n",
|
||
|
" <th>location</th>\n",
|
||
|
" <th>datetime</th>\n",
|
||
|
" <th>cloudpath</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>adwp</td>\n",
|
||
|
" <td>Chifunfu</td>\n",
|
||
|
" <td>2020-04-29T08:20:47Z</td>\n",
|
||
|
" <td>az://./train_features/adwp</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>adwu</td>\n",
|
||
|
" <td>Chifunfu</td>\n",
|
||
|
" <td>2020-04-29T08:20:47Z</td>\n",
|
||
|
" <td>az://./train_features/adwu</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>adwz</td>\n",
|
||
|
" <td>Chifunfu</td>\n",
|
||
|
" <td>2020-04-29T08:20:47Z</td>\n",
|
||
|
" <td>az://./train_features/adwz</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>adxp</td>\n",
|
||
|
" <td>Chifunfu</td>\n",
|
||
|
" <td>2020-04-29T08:20:47Z</td>\n",
|
||
|
" <td>az://./train_features/adxp</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>aeaj</td>\n",
|
||
|
" <td>Chifunfu</td>\n",
|
||
|
" <td>2020-04-29T08:20:47Z</td>\n",
|
||
|
" <td>az://./train_features/aeaj</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" chip_id location datetime cloudpath\n",
|
||
|
"0 adwp Chifunfu 2020-04-29T08:20:47Z az://./train_features/adwp\n",
|
||
|
"1 adwu Chifunfu 2020-04-29T08:20:47Z az://./train_features/adwu\n",
|
||
|
"2 adwz Chifunfu 2020-04-29T08:20:47Z az://./train_features/adwz\n",
|
||
|
"3 adxp Chifunfu 2020-04-29T08:20:47Z az://./train_features/adxp\n",
|
||
|
"4 aeaj Chifunfu 2020-04-29T08:20:47Z az://./train_features/aeaj"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"train_meta = pd.read_csv(DATA_DIR / \"On_Cloud_N_Cloud_Cover_Detection_Challenge_-_train_metadata.csv.csv\")\n",
|
||
|
"train_meta.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"chip_id 11748\n",
|
||
|
"location 81\n",
|
||
|
"datetime 91\n",
|
||
|
"dtype: int64"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# how many different chip ids, locations, and datetimes are there?\n",
|
||
|
"train_meta[[\"chip_id\", \"location\", \"datetime\"]].nunique()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"train_location_counts = (\n",
|
||
|
" train_meta.groupby(\"location\")[\"chip_id\"].nunique().sort_values(ascending=False)\n",
|
||
|
")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABJIAAAJpCAYAAAD2aBj/AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAACV3ElEQVR4nOzdd3xkVf3/8fd76R2RFZGqgAVXii5FQQUUFWk2sIAooqCiYu9KU1GxfcWCICIggigWRESQDgpIZwH5gRQBaUoXQYHP749zZnMzO0lu5p6bTLKv5+Oxj2Ruks+cnUxm7v2cz/kcR4QAAAAAAACAscyY7AEAAAAAAABgaiCRBAAAAAAAgFpIJAEAAAAAAKAWEkkAAAAAAACohUQSAAAAAAAAaiGRBAAAAAAAgFpIJAEAME3Z/rHtL0zSfdv24bbvtX1hi/fzYtvXthg/bK85wtd2sn1K4ftbPd/ngiXjTgbbq9p+yPYCLcU/xvZr2ohdku11bP9psscBAEApJJIAAJggtm+yfZftJSrH3mn7zEkcVls2lbSlpJUjYsPqF2x/OicYHrL9iO3HK7evGs+dRMQ5EfGsfgdpe0Xbh9m+3faDtv9qe9/q72iU+z46Il7R7323zfY+tn8ygfd3k+2Xd25HxN8jYsmIeLyF+1pH0rqSflPy+TTK/XUSfA9V/n2u8vVFbP/I9gO277D94c7XIuIKSffZ3rbEWAAAmGwkkgAAmFgLSNprsgcxXn1Ulawm6aaI+Hf3FyLiSznBsKSkd0v6c+d2RDy3cp+23dq5iu3lJP1Z0mKSXhgRSyklv5aVtEZb94si9pB0dCS1nk+FLFuJvX/l+D6S1lJ63m8u6eO2X1X5+tF5zAAATHkkkgAAmFgHSvqo7WW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|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"n = 50\n",
|
||
|
"plt.figure(figsize=(20, 8))\n",
|
||
|
"train_location_counts.head(n).plot(kind=\"bar\", color=\"lightgray\")\n",
|
||
|
"plt.xticks(rotation=90)\n",
|
||
|
"plt.xlabel(\"Location\")\n",
|
||
|
"plt.ylabel(\"Number of Chips\")\n",
|
||
|
"plt.title(f\"Number of Train Chips by Location (Top {n})\")\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"The train and test images are from all over the world! Location names can be countries (eg. Eswatini), cities (eg. Lusaka), or broader regions of a country (eg. Australia - Central). [Sentinel-2](https://sentinel.esa.int/web/sentinel/missions/sentinel-2/observation-scenario) flies over the part of the Earth between 56° South and 82.8° North, between Cape Horn and slightly north of Greenland, so our observations are all between these two latitudes. The chips are mostly in Africa and South America, with some in Australia too.\n",
|
||
|
"\n",
|
||
|
"We also have a timestamp for each chip. What is the time range in the data?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>chip_count</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>year-month</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>April-2019</th>\n",
|
||
|
" <td>220</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>April-2020</th>\n",
|
||
|
" <td>995</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>August-2019</th>\n",
|
||
|
" <td>9</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>August-2020</th>\n",
|
||
|
" <td>1576</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>December-2019</th>\n",
|
||
|
" <td>159</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>February-2019</th>\n",
|
||
|
" <td>335</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>January-2020</th>\n",
|
||
|
" <td>6</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>July-2020</th>\n",
|
||
|
" <td>690</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>June-2020</th>\n",
|
||
|
" <td>555</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>March-2018</th>\n",
|
||
|
" <td>24</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>March-2020</th>\n",
|
||
|
" <td>334</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>May-2020</th>\n",
|
||
|
" <td>491</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>November-2018</th>\n",
|
||
|
" <td>143</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>November-2019</th>\n",
|
||
|
" <td>150</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>October-2018</th>\n",
|
||
|
" <td>159</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>September-2019</th>\n",
|
||
|
" <td>142</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>September-2020</th>\n",
|
||
|
" <td>5760</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" chip_count\n",
|
||
|
"year-month \n",
|
||
|
"April-2019 220\n",
|
||
|
"April-2020 995\n",
|
||
|
"August-2019 9\n",
|
||
|
"August-2020 1576\n",
|
||
|
"December-2019 159\n",
|
||
|
"February-2019 335\n",
|
||
|
"January-2020 6\n",
|
||
|
"July-2020 690\n",
|
||
|
"June-2020 555\n",
|
||
|
"March-2018 24\n",
|
||
|
"March-2020 334\n",
|
||
|
"May-2020 491\n",
|
||
|
"November-2018 143\n",
|
||
|
"November-2019 150\n",
|
||
|
"October-2018 159\n",
|
||
|
"September-2019 142\n",
|
||
|
"September-2020 5760"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"train_meta[\"datetime\"] = pd.to_datetime(train_meta[\"datetime\"])\n",
|
||
|
"train_meta[\"year\"] = train_meta.datetime.dt.year\n",
|
||
|
"train_meta[\"year-month\"] = train_meta.datetime.dt.strftime('%B-%Y')\n",
|
||
|
"\n",
|
||
|
"train_meta.groupby(\"year-month\")[[\"chip_id\"]].nunique().sort_index().rename(\n",
|
||
|
" columns={\"chip_id\": \"chip_count\"}\n",
|
||
|
")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"(Timestamp('2018-03-07 08:46:02+0000', tz='UTC'),\n",
|
||
|
" Timestamp('2020-09-14 08:28:49+0000', tz='UTC'))"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 9,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"train_meta[\"datetime\"].min(), train_meta[\"datetime\"].max()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>chip_count</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>location</th>\n",
|
||
|
" <th>datetime</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>South America - Brazil</th>\n",
|
||
|
" <th>2020-09-06 15:02:37+00:00</th>\n",
|
||
|
" <td>261</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Port Gentil</th>\n",
|
||
|
" <th>2020-09-08 09:50:58+00:00</th>\n",
|
||
|
" <td>223</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Uganda</th>\n",
|
||
|
" <th>2019-04-25 08:29:37+00:00</th>\n",
|
||
|
" <td>220</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Australia - Central</th>\n",
|
||
|
" <th>2020-08-11 01:24:00+00:00</th>\n",
|
||
|
" <td>209</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Malabo</th>\n",
|
||
|
" <th>2020-09-06 10:00:03+00:00</th>\n",
|
||
|
" <td>206</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Jimma</th>\n",
|
||
|
" <th>2020-05-31 08:07:58+00:00</th>\n",
|
||
|
" <td>201</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Chifunfu</th>\n",
|
||
|
" <th>2020-04-29 08:20:47+00:00</th>\n",
|
||
|
" <td>197</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>South America - Suriname</th>\n",
|
||
|
" <th>2020-06-03 14:11:18+00:00</th>\n",
|
||
|
" <td>197</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Isiro</th>\n",
|
||
|
" <th>2020-08-28 08:39:29+00:00</th>\n",
|
||
|
" <td>197</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Pibor</th>\n",
|
||
|
" <th>2020-08-17 08:18:22+00:00</th>\n",
|
||
|
" <td>197</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" chip_count\n",
|
||
|
"location datetime \n",
|
||
|
"South America - Brazil 2020-09-06 15:02:37+00:00 261\n",
|
||
|
"Port Gentil 2020-09-08 09:50:58+00:00 223\n",
|
||
|
"Uganda 2019-04-25 08:29:37+00:00 220\n",
|
||
|
"Australia - Central 2020-08-11 01:24:00+00:00 209\n",
|
||
|
"Malabo 2020-09-06 10:00:03+00:00 206\n",
|
||
|
"Jimma 2020-05-31 08:07:58+00:00 201\n",
|
||
|
"Chifunfu 2020-04-29 08:20:47+00:00 197\n",
|
||
|
"South America - Suriname 2020-06-03 14:11:18+00:00 197\n",
|
||
|
"Isiro 2020-08-28 08:39:29+00:00 197\n",
|
||
|
"Pibor 2020-08-17 08:18:22+00:00 197"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 10,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"chips_per_locationtime = (\n",
|
||
|
" train_meta.groupby([\"location\", \"datetime\"])[[\"chip_id\"]]\n",
|
||
|
" .nunique()\n",
|
||
|
" .sort_values(by=\"chip_id\", ascending=False)\n",
|
||
|
" .rename(columns={\"chip_id\": \"chip_count\"})\n",
|
||
|
")\n",
|
||
|
"chips_per_locationtime.head(10)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>chip_id</th>\n",
|
||
|
" <th>location</th>\n",
|
||
|
" <th>datetime</th>\n",
|
||
|
" <th>cloudpath</th>\n",
|
||
|
" <th>year</th>\n",
|
||
|
" <th>year-month</th>\n",
|
||
|
" <th>B02_path</th>\n",
|
||
|
" <th>B03_path</th>\n",
|
||
|
" <th>B04_path</th>\n",
|
||
|
" <th>B08_path</th>\n",
|
||
|
" <th>label_path</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>adwp</td>\n",
|
||
|
" <td>Chifunfu</td>\n",
|
||
|
" <td>2020-04-29 08:20:47+00:00</td>\n",
|
||
|
" <td>az://./train_features/adwp</td>\n",
|
||
|
" <td>2020</td>\n",
|
||
|
" <td>April-2020</td>\n",
|
||
|
" <td>data\\train_features\\adwp\\B02.tif</td>\n",
|
||
|
" <td>data\\train_features\\adwp\\B03.tif</td>\n",
|
||
|
" <td>data\\train_features\\adwp\\B04.tif</td>\n",
|
||
|
" <td>data\\train_features\\adwp\\B08.tif</td>\n",
|
||
|
" <td>data\\train_labels\\adwp.tif</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>adwu</td>\n",
|
||
|
" <td>Chifunfu</td>\n",
|
||
|
" <td>2020-04-29 08:20:47+00:00</td>\n",
|
||
|
" <td>az://./train_features/adwu</td>\n",
|
||
|
" <td>2020</td>\n",
|
||
|
" <td>April-2020</td>\n",
|
||
|
" <td>data\\train_features\\adwu\\B02.tif</td>\n",
|
||
|
" <td>data\\train_features\\adwu\\B03.tif</td>\n",
|
||
|
" <td>data\\train_features\\adwu\\B04.tif</td>\n",
|
||
|
" <td>data\\train_features\\adwu\\B08.tif</td>\n",
|
||
|
" <td>data\\train_labels\\adwu.tif</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>adwz</td>\n",
|
||
|
" <td>Chifunfu</td>\n",
|
||
|
" <td>2020-04-29 08:20:47+00:00</td>\n",
|
||
|
" <td>az://./train_features/adwz</td>\n",
|
||
|
" <td>2020</td>\n",
|
||
|
" <td>April-2020</td>\n",
|
||
|
" <td>data\\train_features\\adwz\\B02.tif</td>\n",
|
||
|
" <td>data\\train_features\\adwz\\B03.tif</td>\n",
|
||
|
" <td>data\\train_features\\adwz\\B04.tif</td>\n",
|
||
|
" <td>data\\train_features\\adwz\\B08.tif</td>\n",
|
||
|
" <td>data\\train_labels\\adwz.tif</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>adxp</td>\n",
|
||
|
" <td>Chifunfu</td>\n",
|
||
|
" <td>2020-04-29 08:20:47+00:00</td>\n",
|
||
|
" <td>az://./train_features/adxp</td>\n",
|
||
|
" <td>2020</td>\n",
|
||
|
" <td>April-2020</td>\n",
|
||
|
" <td>data\\train_features\\adxp\\B02.tif</td>\n",
|
||
|
" <td>data\\train_features\\adxp\\B03.tif</td>\n",
|
||
|
" <td>data\\train_features\\adxp\\B04.tif</td>\n",
|
||
|
" <td>data\\train_features\\adxp\\B08.tif</td>\n",
|
||
|
" <td>data\\train_labels\\adxp.tif</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>aeaj</td>\n",
|
||
|
" <td>Chifunfu</td>\n",
|
||
|
" <td>2020-04-29 08:20:47+00:00</td>\n",
|
||
|
" <td>az://./train_features/aeaj</td>\n",
|
||
|
" <td>2020</td>\n",
|
||
|
" <td>April-2020</td>\n",
|
||
|
" <td>data\\train_features\\aeaj\\B02.tif</td>\n",
|
||
|
" <td>data\\train_features\\aeaj\\B03.tif</td>\n",
|
||
|
" <td>data\\train_features\\aeaj\\B04.tif</td>\n",
|
||
|
" <td>data\\train_features\\aeaj\\B08.tif</td>\n",
|
||
|
" <td>data\\train_labels\\aeaj.tif</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" chip_id location datetime cloudpath \\\n",
|
||
|
"0 adwp Chifunfu 2020-04-29 08:20:47+00:00 az://./train_features/adwp \n",
|
||
|
"1 adwu Chifunfu 2020-04-29 08:20:47+00:00 az://./train_features/adwu \n",
|
||
|
"2 adwz Chifunfu 2020-04-29 08:20:47+00:00 az://./train_features/adwz \n",
|
||
|
"3 adxp Chifunfu 2020-04-29 08:20:47+00:00 az://./train_features/adxp \n",
|
||
|
"4 aeaj Chifunfu 2020-04-29 08:20:47+00:00 az://./train_features/aeaj \n",
|
||
|
"\n",
|
||
|
" year year-month B02_path \\\n",
|
||
|
"0 2020 April-2020 data\\train_features\\adwp\\B02.tif \n",
|
||
|
"1 2020 April-2020 data\\train_features\\adwu\\B02.tif \n",
|
||
|
"2 2020 April-2020 data\\train_features\\adwz\\B02.tif \n",
|
||
|
"3 2020 April-2020 data\\train_features\\adxp\\B02.tif \n",
|
||
|
"4 2020 April-2020 data\\train_features\\aeaj\\B02.tif \n",
|
||
|
"\n",
|
||
|
" B03_path B04_path \\\n",
|
||
|
"0 data\\train_features\\adwp\\B03.tif data\\train_features\\adwp\\B04.tif \n",
|
||
|
"1 data\\train_features\\adwu\\B03.tif data\\train_features\\adwu\\B04.tif \n",
|
||
|
"2 data\\train_features\\adwz\\B03.tif data\\train_features\\adwz\\B04.tif \n",
|
||
|
"3 data\\train_features\\adxp\\B03.tif data\\train_features\\adxp\\B04.tif \n",
|
||
|
"4 data\\train_features\\aeaj\\B03.tif data\\train_features\\aeaj\\B04.tif \n",
|
||
|
"\n",
|
||
|
" B08_path label_path \n",
|
||
|
"0 data\\train_features\\adwp\\B08.tif data\\train_labels\\adwp.tif \n",
|
||
|
"1 data\\train_features\\adwu\\B08.tif data\\train_labels\\adwu.tif \n",
|
||
|
"2 data\\train_features\\adwz\\B08.tif data\\train_labels\\adwz.tif \n",
|
||
|
"3 data\\train_features\\adxp\\B08.tif data\\train_labels\\adxp.tif \n",
|
||
|
"4 data\\train_features\\aeaj\\B08.tif data\\train_labels\\aeaj.tif "
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 11,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"def add_paths(df, feature_dir, label_dir=None, bands=BANDS):\n",
|
||
|
" \"\"\"\n",
|
||
|
" Given dataframe with a column for chip_id, returns a dataframe with a column\n",
|
||
|
" added indicating the path to each band's TIF image as \"{band}_path\", eg \"B02_path\".\n",
|
||
|
" A column is also added to the dataframe with paths to the label TIF, if the\n",
|
||
|
" path to the labels directory is provided.\n",
|
||
|
" \"\"\"\n",
|
||
|
" for band in bands:\n",
|
||
|
" df[f\"{band}_path\"] = feature_dir / df[\"chip_id\"] / f\"{band}.tif\"\n",
|
||
|
" # make sure a random sample of paths exist\n",
|
||
|
" assert df.sample(n=40, random_state=5)[f\"{band}_path\"].path.exists().all()\n",
|
||
|
" if label_dir is not None:\n",
|
||
|
" df[\"label_path\"] = label_dir / (df[\"chip_id\"] + \".tif\")\n",
|
||
|
" # make sure a random sample of paths exist\n",
|
||
|
" assert df.sample(n=40, random_state=5)[\"label_path\"].path.exists().all()\n",
|
||
|
"\n",
|
||
|
" return df\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"train_meta = add_paths(train_meta, TRAIN_FEATURES, TRAIN_LABELS)\n",
|
||
|
"train_meta.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"<class 'pandas.core.frame.DataFrame'>\n",
|
||
|
"RangeIndex: 11748 entries, 0 to 11747\n",
|
||
|
"Data columns (total 11 columns):\n",
|
||
|
" # Column Non-Null Count Dtype \n",
|
||
|
"--- ------ -------------- ----- \n",
|
||
|
" 0 chip_id 11748 non-null object \n",
|
||
|
" 1 location 11748 non-null object \n",
|
||
|
" 2 datetime 11748 non-null datetime64[ns, UTC]\n",
|
||
|
" 3 cloudpath 11748 non-null object \n",
|
||
|
" 4 year 11748 non-null int64 \n",
|
||
|
" 5 year-month 11748 non-null object \n",
|
||
|
" 6 B02_path 11748 non-null object \n",
|
||
|
" 7 B03_path 11748 non-null object \n",
|
||
|
" 8 B04_path 11748 non-null object \n",
|
||
|
" 9 B08_path 11748 non-null object \n",
|
||
|
" 10 label_path 11748 non-null object \n",
|
||
|
"dtypes: datetime64[ns, UTC](1), int64(1), object(9)\n",
|
||
|
"memory usage: 1009.7+ KB\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"train_meta.info()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import rasterio"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"chip_id pbyl\n",
|
||
|
"location Lodwar\n",
|
||
|
"datetime 2020-09-08 08:09:15+00:00\n",
|
||
|
"cloudpath az://./train_features/pbyl\n",
|
||
|
"year 2020\n",
|
||
|
"year-month September-2020\n",
|
||
|
"B02_path data\\train_features\\pbyl\\B02.tif\n",
|
||
|
"B03_path data\\train_features\\pbyl\\B03.tif\n",
|
||
|
"B04_path data\\train_features\\pbyl\\B04.tif\n",
|
||
|
"B08_path data\\train_features\\pbyl\\B08.tif\n",
|
||
|
"label_path data\\train_labels\\pbyl.tif\n",
|
||
|
"Name: 6571, dtype: object"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"example_chip = train_meta[train_meta[\"chip_id\"] == \"pbyl\"].iloc[0]\n",
|
||
|
"example_chip"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 15,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"{'driver': 'GTiff',\n",
|
||
|
" 'dtype': 'uint16',\n",
|
||
|
" 'nodata': 0.0,\n",
|
||
|
" 'width': 512,\n",
|
||
|
" 'height': 512,\n",
|
||
|
" 'count': 1,\n",
|
||
|
" 'crs': CRS.from_epsg(32636),\n",
|
||
|
" 'transform': Affine(10.0, 0.0, 771935.0,\n",
|
||
|
" 0.0, -10.0, 331300.0)}"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 15,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"img = rasterio.open(example_chip[\"B04_path\"])\n",
|
||
|
"chip_metadata = img.meta\n",
|
||
|
"img_array = img.read(1)\n",
|
||
|
"\n",
|
||
|
"chip_metadata"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"We can see that the features are single-band images, with a shape of 512 x 512. The pixel values for each image measure the strength of light reflected back to the satellite for the specific set of wavelengths in that band. The array below shows the strength of red visible light, with wavelengts around 665 nm.\n",
|
||
|
"\n",
|
||
|
"We can also see that there are no missing values in the image. This should be the case for all of the provided competition feature data."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 16,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Image array shape: (512, 512)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"array([[ 519, 532, 556, ..., 3662, 3564, 3544],\n",
|
||
|
" [ 549, 539, 562, ..., 3604, 3520, 3518],\n",
|
||
|
" [ 572, 524, 506, ..., 3514, 3488, 3518],\n",
|
||
|
" ...,\n",
|
||
|
" [1216, 2062, 2898, ..., 4050, 3610, 3328],\n",
|
||
|
" [1632, 1932, 2588, ..., 4108, 3918, 3736],\n",
|
||
|
" [1766, 2040, 2272, ..., 4152, 4028, 3824]], dtype=uint16)"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 16,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# what does the image array look like?\n",
|
||
|
"print(\"Image array shape:\", img_array.shape)\n",
|
||
|
"img_array"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 17,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAQYAAAEICAYAAAC9P1pMAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9a6xlW3Yehn1jPtZae+/zqKp7u5tNssmWZSYRbUeKE0hyoiiEJQG2YINOkAiWo4hW5DBBJNhxBMSKEkNxnnQAGbGdwDHhB0lLtiJbdiTDBAJFCC3YiWQbgWBHD0e0RYrdZLO7762qc85+rLXmnCM/xhhzzr1P1b1VFFusq9QE6t599mO955hjfOMb3yBmxvvxfrwf70c/3C/1Abwf78f78e6N94bh/Xg/3o9H471heD/ej/fj0XhvGN6P9+P9eDTeG4b34/14Px6N94bh/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eDIRSAnmfDetwkNALmAfHdM9lDm3IyVHa4ZIu+r8eg/Pzu/TzCOr8Of6nmtqxizEHT7vt6bsh3ku46QtwFuLbJqrxklOuQpIL48yXXJBe6kBmKKbYEgAk8DeDMgX08okVC2AetNQNhnuFUMgluyroziLbkMrKOs1MRyDOwZJRL4JAbJrRluXttJLSvotMjxB9+MwqP7xSDv5BrY58EjXQ1Yr70cYyCsW8JyTUg7IG0Y3M00m/RUgHAC/NE8HqDE5kVBJzllwC1ACWKQKMtr2RjgVqpeBBWI9+DktUsMt749jvitMAz/PoDvIaJfBjEIfy+EcPL6YXPGDICFAq8b/WrXbyYEcM7gZZE3cgYvK+jmCggeVIL8PxdwyeJ9dauA7LtNvrqC6uSpXot9x3sAMokpxnbMNtl
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.imshow(img_array)\n",
|
||
|
"plt.title(f\"B04 band for chip id {example_chip.chip_id}\")\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"tags": []
|
||
|
},
|
||
|
"source": [
|
||
|
"#### Coordinates\n",
|
||
|
"\n",
|
||
|
"Using the metadata returned by `rasterio`, we can also get longitude and latitude coordinates."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 18,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Longitude: 35.46935026347422, latitude: 2.9714117132510944\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# longitude/latitude of image's center\n",
|
||
|
"lon, lat = img.lnglat()\n",
|
||
|
"bounds = img.bounds\n",
|
||
|
"print(f\"Longitude: {lon}, latitude: {lat}\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 19,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"BoundingBox(left=771935.0, bottom=326180.0, right=777055.0, top=331300.0)"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 19,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"bounds"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"We have the longitude and latitude of the center of the image, but the bounding box values look very different. That's because the bounding box is given in whatever coordinate reference system the image is projected in, rather than traditional longitude and latiude. We can see which system with the `crs` value from the metadata.\n",
|
||
|
"\n",
|
||
|
"We can convert the bounding box to longitude and latitude using `pyproj`."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 20,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import pyproj"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 21,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def lat_long_bounds(filepath):\n",
|
||
|
" \"\"\"Given the path to a GeoTIFF, returns the image bounds in latitude and\n",
|
||
|
" longitude coordinates.\n",
|
||
|
"\n",
|
||
|
" Returns points as a tuple of (left, bottom, right, top)\n",
|
||
|
" \"\"\"\n",
|
||
|
" with rasterio.open(filepath) as im:\n",
|
||
|
" bounds = im.bounds\n",
|
||
|
" meta = im.meta\n",
|
||
|
" # create a converter starting with the current projection\n",
|
||
|
" current_crs = pyproj.CRS(meta[\"crs\"])\n",
|
||
|
" crs_transform = pyproj.Transformer.from_crs(current_crs, current_crs.geodetic_crs)\n",
|
||
|
"\n",
|
||
|
" # returns left, bottom, right, top\n",
|
||
|
" return crs_transform.transform_bounds(*bounds)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 22,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Image coordinates (lat, long):\n",
|
||
|
"Start: (2.948221298028172, 35.44628398518643)\n",
|
||
|
"End: (2.9946024439490517, 35.492417498478574)\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"left, bottom, right, top = lat_long_bounds(example_chip[\"B04_path\"])\n",
|
||
|
"print(\n",
|
||
|
" f\"Image coordinates (lat, long):\\nStart: ({left}, {bottom})\"\n",
|
||
|
" f\"\\nEnd: ({right}, {top})\"\n",
|
||
|
")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 23,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<Derived Projected CRS: EPSG:32636>\n",
|
||
|
"Name: WGS 84 / UTM zone 36N\n",
|
||
|
"Axis Info [cartesian]:\n",
|
||
|
"- [east]: Easting (metre)\n",
|
||
|
"- [north]: Northing (metre)\n",
|
||
|
"Area of Use:\n",
|
||
|
"- undefined\n",
|
||
|
"Coordinate Operation:\n",
|
||
|
"- name: UTM zone 36N\n",
|
||
|
"- method: Transverse Mercator\n",
|
||
|
"Datum: World Geodetic System 1984\n",
|
||
|
"- Ellipsoid: WGS 84\n",
|
||
|
"- Prime Meridian: Greenwich"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 23,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"current_crs = pyproj.CRS(img.meta[\"crs\"])\n",
|
||
|
"current_crs"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"#### True color image"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"We can make a composite image from the three visible bands (blue, green, and red) to visualize a high-quality, true color image. To show the true color image, we'll use the `rioxarray` and `xrspatial` packages designed for Sentinel-2 satellite data."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 28,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import rioxarray\n",
|
||
|
"import xrspatial.multispectral as ms"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 25,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def true_color_img(chip_id, data_dir=TRAIN_FEATURES):\n",
|
||
|
" \"\"\"Given the path to the directory of Sentinel-2 chip feature images,\n",
|
||
|
" plots the true color image\"\"\"\n",
|
||
|
" chip_dir = data_dir / chip_id\n",
|
||
|
" red = rioxarray.open_rasterio(chip_dir / \"B04.tif\").squeeze()\n",
|
||
|
" green = rioxarray.open_rasterio(chip_dir / \"B03.tif\").squeeze()\n",
|
||
|
" blue = rioxarray.open_rasterio(chip_dir / \"B02.tif\").squeeze()\n",
|
||
|
"\n",
|
||
|
" return ms.true_color(r=red, g=green, b=blue)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 29,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
|
||
|
"<defs>\n",
|
||
|
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
|
||
|
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
|
||
|
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
|
||
|
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
|
||
|
"</symbol>\n",
|
||
|
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
|
||
|
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
|
||
|
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
|
||
|
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
|
||
|
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
|
||
|
"</symbol>\n",
|
||
|
"</defs>\n",
|
||
|
"</svg>\n",
|
||
|
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
|
||
|
" *\n",
|
||
|
" */\n",
|
||
|
"\n",
|
||
|
":root {\n",
|
||
|
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
|
||
|
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
|
||
|
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
|
||
|
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
|
||
|
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
|
||
|
" --xr-background-color: var(--jp-layout-color0, white);\n",
|
||
|
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
|
||
|
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
"html[theme=dark],\n",
|
||
|
"body.vscode-dark {\n",
|
||
|
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
|
||
|
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
|
||
|
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
|
||
|
" --xr-border-color: #1F1F1F;\n",
|
||
|
" --xr-disabled-color: #515151;\n",
|
||
|
" --xr-background-color: #111111;\n",
|
||
|
" --xr-background-color-row-even: #111111;\n",
|
||
|
" --xr-background-color-row-odd: #313131;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-wrap {\n",
|
||
|
" display: block !important;\n",
|
||
|
" min-width: 300px;\n",
|
||
|
" max-width: 700px;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-text-repr-fallback {\n",
|
||
|
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
|
||
|
" display: none;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-header {\n",
|
||
|
" padding-top: 6px;\n",
|
||
|
" padding-bottom: 6px;\n",
|
||
|
" margin-bottom: 4px;\n",
|
||
|
" border-bottom: solid 1px var(--xr-border-color);\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-header > div,\n",
|
||
|
".xr-header > ul {\n",
|
||
|
" display: inline;\n",
|
||
|
" margin-top: 0;\n",
|
||
|
" margin-bottom: 0;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-obj-type,\n",
|
||
|
".xr-array-name {\n",
|
||
|
" margin-left: 2px;\n",
|
||
|
" margin-right: 10px;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-obj-type {\n",
|
||
|
" color: var(--xr-font-color2);\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-sections {\n",
|
||
|
" padding-left: 0 !important;\n",
|
||
|
" display: grid;\n",
|
||
|
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-item {\n",
|
||
|
" display: contents;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-item input {\n",
|
||
|
" display: none;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-item input + label {\n",
|
||
|
" color: var(--xr-disabled-color);\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-item input:enabled + label {\n",
|
||
|
" cursor: pointer;\n",
|
||
|
" color: var(--xr-font-color2);\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-item input:enabled + label:hover {\n",
|
||
|
" color: var(--xr-font-color0);\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-summary {\n",
|
||
|
" grid-column: 1;\n",
|
||
|
" color: var(--xr-font-color2);\n",
|
||
|
" font-weight: 500;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-summary > span {\n",
|
||
|
" display: inline-block;\n",
|
||
|
" padding-left: 0.5em;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-summary-in:disabled + label {\n",
|
||
|
" color: var(--xr-font-color2);\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-summary-in + label:before {\n",
|
||
|
" display: inline-block;\n",
|
||
|
" content: '►';\n",
|
||
|
" font-size: 11px;\n",
|
||
|
" width: 15px;\n",
|
||
|
" text-align: center;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-summary-in:disabled + label:before {\n",
|
||
|
" color: var(--xr-disabled-color);\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-summary-in:checked + label:before {\n",
|
||
|
" content: '▼';\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-summary-in:checked + label > span {\n",
|
||
|
" display: none;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-summary,\n",
|
||
|
".xr-section-inline-details {\n",
|
||
|
" padding-top: 4px;\n",
|
||
|
" padding-bottom: 4px;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-inline-details {\n",
|
||
|
" grid-column: 2 / -1;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-details {\n",
|
||
|
" display: none;\n",
|
||
|
" grid-column: 1 / -1;\n",
|
||
|
" margin-bottom: 5px;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-section-summary-in:checked ~ .xr-section-details {\n",
|
||
|
" display: contents;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-array-wrap {\n",
|
||
|
" grid-column: 1 / -1;\n",
|
||
|
" display: grid;\n",
|
||
|
" grid-template-columns: 20px auto;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-array-wrap > label {\n",
|
||
|
" grid-column: 1;\n",
|
||
|
" vertical-align: top;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-preview {\n",
|
||
|
" color: var(--xr-font-color3);\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-array-preview,\n",
|
||
|
".xr-array-data {\n",
|
||
|
" padding: 0 5px !important;\n",
|
||
|
" grid-column: 2;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-array-data,\n",
|
||
|
".xr-array-in:checked ~ .xr-array-preview {\n",
|
||
|
" display: none;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-array-in:checked ~ .xr-array-data,\n",
|
||
|
".xr-array-preview {\n",
|
||
|
" display: inline-block;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-dim-list {\n",
|
||
|
" display: inline-block !important;\n",
|
||
|
" list-style: none;\n",
|
||
|
" padding: 0 !important;\n",
|
||
|
" margin: 0;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-dim-list li {\n",
|
||
|
" display: inline-block;\n",
|
||
|
" padding: 0;\n",
|
||
|
" margin: 0;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-dim-list:before {\n",
|
||
|
" content: '(';\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-dim-list:after {\n",
|
||
|
" content: ')';\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-dim-list li:not(:last-child):after {\n",
|
||
|
" content: ',';\n",
|
||
|
" padding-right: 5px;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-has-index {\n",
|
||
|
" font-weight: bold;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-list,\n",
|
||
|
".xr-var-item {\n",
|
||
|
" display: contents;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-item > div,\n",
|
||
|
".xr-var-item label,\n",
|
||
|
".xr-var-item > .xr-var-name span {\n",
|
||
|
" background-color: var(--xr-background-color-row-even);\n",
|
||
|
" margin-bottom: 0;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-item > .xr-var-name:hover span {\n",
|
||
|
" padding-right: 5px;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-list > li:nth-child(odd) > div,\n",
|
||
|
".xr-var-list > li:nth-child(odd) > label,\n",
|
||
|
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
|
||
|
" background-color: var(--xr-background-color-row-odd);\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-name {\n",
|
||
|
" grid-column: 1;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-dims {\n",
|
||
|
" grid-column: 2;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-dtype {\n",
|
||
|
" grid-column: 3;\n",
|
||
|
" text-align: right;\n",
|
||
|
" color: var(--xr-font-color2);\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-preview {\n",
|
||
|
" grid-column: 4;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-name,\n",
|
||
|
".xr-var-dims,\n",
|
||
|
".xr-var-dtype,\n",
|
||
|
".xr-preview,\n",
|
||
|
".xr-attrs dt {\n",
|
||
|
" white-space: nowrap;\n",
|
||
|
" overflow: hidden;\n",
|
||
|
" text-overflow: ellipsis;\n",
|
||
|
" padding-right: 10px;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-name:hover,\n",
|
||
|
".xr-var-dims:hover,\n",
|
||
|
".xr-var-dtype:hover,\n",
|
||
|
".xr-attrs dt:hover {\n",
|
||
|
" overflow: visible;\n",
|
||
|
" width: auto;\n",
|
||
|
" z-index: 1;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-attrs,\n",
|
||
|
".xr-var-data {\n",
|
||
|
" display: none;\n",
|
||
|
" background-color: var(--xr-background-color) !important;\n",
|
||
|
" padding-bottom: 5px !important;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
|
||
|
".xr-var-data-in:checked ~ .xr-var-data {\n",
|
||
|
" display: block;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-data > table {\n",
|
||
|
" float: right;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-var-name span,\n",
|
||
|
".xr-var-data,\n",
|
||
|
".xr-attrs {\n",
|
||
|
" padding-left: 25px !important;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-attrs,\n",
|
||
|
".xr-var-attrs,\n",
|
||
|
".xr-var-data {\n",
|
||
|
" grid-column: 1 / -1;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
"dl.xr-attrs {\n",
|
||
|
" padding: 0;\n",
|
||
|
" margin: 0;\n",
|
||
|
" display: grid;\n",
|
||
|
" grid-template-columns: 125px auto;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-attrs dt,\n",
|
||
|
".xr-attrs dd {\n",
|
||
|
" padding: 0;\n",
|
||
|
" margin: 0;\n",
|
||
|
" float: left;\n",
|
||
|
" padding-right: 10px;\n",
|
||
|
" width: auto;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-attrs dt {\n",
|
||
|
" font-weight: normal;\n",
|
||
|
" grid-column: 1;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-attrs dt:hover span {\n",
|
||
|
" display: inline-block;\n",
|
||
|
" background: var(--xr-background-color);\n",
|
||
|
" padding-right: 10px;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-attrs dd {\n",
|
||
|
" grid-column: 2;\n",
|
||
|
" white-space: pre-wrap;\n",
|
||
|
" word-break: break-all;\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
".xr-icon-database,\n",
|
||
|
".xr-icon-file-text2 {\n",
|
||
|
" display: inline-block;\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" width: 1em;\n",
|
||
|
" height: 1.5em !important;\n",
|
||
|
" stroke-width: 0;\n",
|
||
|
" stroke: currentColor;\n",
|
||
|
" fill: currentColor;\n",
|
||
|
"}\n",
|
||
|
"</style><pre class='xr-text-repr-fallback'><xarray.DataArray (y: 512, x: 512)>\n",
|
||
|
"[262144 values with dtype=uint16]\n",
|
||
|
"Coordinates:\n",
|
||
|
" band int32 1\n",
|
||
|
" * x (x) float64 7.719e+05 7.72e+05 7.72e+05 ... 7.77e+05 7.77e+05\n",
|
||
|
" * y (y) float64 3.313e+05 3.313e+05 ... 3.262e+05 3.262e+05\n",
|
||
|
" spatial_ref int32 0\n",
|
||
|
"Attributes:\n",
|
||
|
" _FillValue: 0.0\n",
|
||
|
" scale_factor: 1.0\n",
|
||
|
" add_offset: 0.0</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'></div><ul class='xr-dim-list'><li><span class='xr-has-index'>y</span>: 512</li><li><span class='xr-has-index'>x</span>: 512</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-bb5d9dc7-e5d2-4f26-bc1d-5b594776cde6' class='xr-array-in' type='checkbox' checked><label for='section-bb5d9dc7-e5d2-4f26-bc1d-5b594776cde6' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>...</span></div><div class='xr-array-data'><pre>[262144 values with dtype=uint16]</pre></div></div></li><li class='xr-section-item'><input id='section-c73f619d-20e5-4fce-a585-dd7d69f880a9' class='xr-section-summary-in' type='checkbox' checked><label for='section-c73f619d-20e5-4fce-a585-dd7d69f880a9' class='xr-section-summary' >Coordinates: <span>(4)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>band</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>int32</div><div class='xr-var-preview xr-preview'>1</div><input id='attrs-f907bfcf-6624-4f53-ac4e-52f5fc1fbafa' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-f907bfcf-6624-4f53-ac4e-52f5fc1fbafa' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-09172001-cb97-4c06-ba75-bf6293339774' class='xr-var-data-in' type='checkbox'><label for='data-09172001-cb97-4c06-ba75-bf6293339774' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array(1)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>x</span></div><div class='xr-var-dims'>(x)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>7.719e+05 7.72e+05 ... 7.77e+05</div><input id='attrs-435a778c-f70e-45ec-b36e-f7e65c1e0fe3' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-435a778c-f70e-45ec-b36e-f7e65c1e0fe3' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-d4371807-8662-4639-b493-f64b88fd30ad' class='xr-var-data-in' type='checkbox'><label for='data-d4371807-8662-4639-b493-f64b88fd30ad' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([771940., 771950., 771960., ..., 777030., 777040., 777050.])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>y</span></div><div class='xr-var-dims'>(y)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>3.313e+05 3.313e+05 ... 3.262e+05</div><input id='attrs-384ce37b-e8f8-4c9d-98a6-e9283ddff206' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-384ce37b-e8f8-4c9d-98a6-e9283ddff206' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-1ca78b2c-135a-4ed8-af2d-6f99cf7bf009' class='xr-var-data-in' type='checkbox'><label for='data-1ca78b2c-135a-4ed8-af2d-6f99cf7bf009' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([331295., 331285., 331275., ..., 326205., 326195., 326185.])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>spatial_ref</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>int32</div><div
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"<xarray.DataArray (y: 512, x: 512)>\n",
|
||
|
"[262144 values with dtype=uint16]\n",
|
||
|
"Coordinates:\n",
|
||
|
" band int32 1\n",
|
||
|
" * x (x) float64 7.719e+05 7.72e+05 7.72e+05 ... 7.77e+05 7.77e+05\n",
|
||
|
" * y (y) float64 3.313e+05 3.313e+05 ... 3.262e+05 3.262e+05\n",
|
||
|
" spatial_ref int32 0\n",
|
||
|
"Attributes:\n",
|
||
|
" _FillValue: 0.0\n",
|
||
|
" scale_factor: 1.0\n",
|
||
|
" add_offset: 0.0"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 29,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"data_dir = TRAIN_FEATURES\n",
|
||
|
"chip_id = example_chip.chip_id\n",
|
||
|
"chip_dir = data_dir / chip_id\n",
|
||
|
"red = rioxarray.open_rasterio(chip_dir / \"B04.tif\").squeeze()\n",
|
||
|
"green = rioxarray.open_rasterio(chip_dir / \"B03.tif\").squeeze()\n",
|
||
|
"blue = rioxarray.open_rasterio(chip_dir / \"B02.tif\").squeeze()\n",
|
||
|
"red"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 30,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"Text(0.5, 1.0, 'True color image for chip id pbyl')"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 30,
|
||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34834ixjfCs/ubwB+XFX/QgNa/y3g138L9vNmvBlvxpvx2uNbYew+x4ezbl/m4wmvb8ab8Wa8GX/JxrdN9UREfgvwWwC89796f2HcWlXFqJHy4R/oz3/r/FELxX/eV0RAFSeCd0KpigLO3kZE2mtFFcrHhPQP35GPvC/r53q/u4/u++OP//zLB7/XT6C5ys87dxFwIh/eJ3ZO0M6p/UjaOTsRtO1OHx6HrtfQro9+6OTau3q/bXlwKmsZh+1N2hY+fM5aP+HcRO5P78G5qCri2v4UHGKHpPbPe4f3ghOHDwFUqaUizv52DmpVclaqVtCKE8GFYMff7nspBRHBe4/3HhRyKYhArZVSCrVWQOmjB/H40OOcI+eFOWX6GOiix3uHqlKLUmshxI4QO9suDlDEOUCotdo9qoWcF0pOaCkoavut2q63UqvinVCrMqVsz26712tFl4hQ70u8Htw7u+9VFe8cIoJ4j3cBHzyKHbMTwYdAjIEuRpz39/da5Hx/1r/bTTo/G0Yjvb+B98/MfUmqOIdrx8C6dS3UqiDt2M6f6f1zvJa1rtdMq12/WlDgz//ojz9T1a9XiXQe3wpj9xU+zNb+PB/D7lfVf5mW/bl8dKm/5tf9Grx3bYKYodCq99dPwXlHqRUrHrCHuFZF6/1cWi+yxwxBQdl0nkOMHFOh947ghC4ErjYdWSvLknl2mslVWYpd0FLvZ/xDUyoi9ze4Kk7Wh84m5/qsee/sJj54+Jyz7znnECDVSlWFCjUVatHzQ+W8w3l39r0FqEVtGw5cm+jBCV10qNp7IdgPcrYnzYlQS6HUikMI3ts2nRCaPZ5TparY9QRKroiDmiuI7Ve8ENxqONt21c5BAVFpV0iprAZV0aJoKtSk4FaDpVDb30FYLawIqADO/uuig6JQhU6FQbx
|
||
|
"text/plain": [
|
||
|
"<Figure size 360x360 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"fig, ax = plt.subplots(figsize=(5, 5))\n",
|
||
|
"im = true_color_img(example_chip.chip_id)\n",
|
||
|
"ax.imshow(im)\n",
|
||
|
"plt.title(f\"True color image for chip id {example_chip.chip_id}\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 31,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def display_random_chip(random_state):\n",
|
||
|
" fig, ax = plt.subplots(1, 2, figsize=(8, 4))\n",
|
||
|
" random_chip = train_meta.sample(random_state=random_state).iloc[0]\n",
|
||
|
"\n",
|
||
|
" ax[0].imshow(true_color_img(random_chip.chip_id))\n",
|
||
|
" ax[0].set_title(f\"Chip {random_chip.chip_id}\\n(Location: {random_chip.location})\")\n",
|
||
|
" label_im = Image.open(random_chip.label_path)\n",
|
||
|
" ax[1].imshow(label_im)\n",
|
||
|
" ax[1].set_title(f\"Chip {random_chip.chip_id} label\")\n",
|
||
|
"\n",
|
||
|
" plt.tight_layout()\n",
|
||
|
" plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 32,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjAAAAEnCAYAAAC3ynnRAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9d6BtS1bXi39GVc200k4n3Nw5Ak2UJAoKShCaFn+vJQuCqA2igqDvicITHgoCEn2KZAGhm0dqbFBEQZugTbeETnS8fcPJO64wU1WN3x9zrh1OuufevuH0vet7795nrTlrzqq59lxV3znGd4whqsoKK6ywwgorrLDCBxLMUz2AFVZYYYUVVlhhhUeLFYFZYYUVVlhhhRU+4LAiMCussMIKK6ywwgccVgRmh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3TujkfCOeDepdaix33Aw3TWi4rO9XE1Pp/OVPspdK6eZ/fbpf/3kXy85+i+ZMf7PHcL431UUNU/Br6FzgUl12lyYhx9m3vprn+Je28wzq+lswp9jKpOgD+7PM37MeQb9fWtdJ/ph/R9feF1+nkJ8IfvR98rrPBk43fpiqa+4nE85+F3qJ/X7uHxmVvOc/JB6N7rtPl3wK8Br+vdOMtxvAj4ceCVqno94nM9PNIce2IMIjKic5udoyM2v6Wq68d+Rqq6yjD+OGJFYJ44vI5rXQyISH78B/hfdE80Xy8iiXT5FD4L+Jn+6eVHgO8Skbv6J4KPk05sO6abeLaBAd0CexwXgefeZHz/AfgGETktIqeAf0pnVXgi8ON00Q0vv86+VwN/SUQ+ufeTfy3ddf3OsTZfKSL
|
||
|
"text/plain": [
|
||
|
"<Figure size 576x288 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"display_random_chip(1)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 33,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjAAAAEnCAYAAAC3ynnRAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9ebBteXbXB37W+v32Pufe+97LoapUmpkkGowJui2CwcZhEWCDsAVqIgwtwAymgwgD3aZpwJimjcCAbRpo2QHYTYcJoBkFwegGN6A2dhCAbcBuzGQhhGSVSjXl8N67955z9u/3W6v/WGufeytVVZklZWXeSu2V8SLvcIY9nLt/a3/XdxB3Z6utttpqq6222urzqfTd3oCtttpqq6222mqrz7a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So5wfmzyX//2buhR8m/gDvv+eH38L2vuVy91tizPVv8amDGP9T4B8BX+nuT4Bfx932fyfwgz/NS3+m5631Zfe+vr9vv5U4Nj8yn/vzPsVzfzjw//uMO7fVVp8/9TeIVPmvextf8/z3ldeuL+VtuH7ka/0R4L/yGIWv9ZmuB9/N9/x7f6v1R4hx2Ze5+wvAf8Zbv5Z8J/A17v7ivX97d/+uz+L9t3qT2hqYd6f+AjEb/aQSkf39f8B/R9zt/BoRmSQkxl8L/LFEZX4f8DtF5ItFpIjIj0+y7WPiovQKgUL81je81Uf59H/wEKOdXy8iHxCR9wP/HvBpfSC+D/XrgH/J3b/9U/zuMfAMuBaRH0Y0Omv9F8AXicivkCAcP867pTd73lq/WkReEpEvA/5t4I/fe+418FREvgS
|
||
|
"text/plain": [
|
||
|
"<Figure size 576x288 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"display_random_chip(9)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 34,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjAAAAEnCAYAAAC3ynnRAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9d7htWXbWB//GnHOFnU4+N9e9FTtHtVoBCakFyFgYhB75ASwJ9ABOGGTAEhgef/qMwCIYGyw9SMSPJEAggowILcC2koWkbrUaqVHHylU333viTivMOcf3x1z7nHNvpVvV1d1VXft9qu7ZYe215lp77TXfNcY73iGqyhJLLLHEEkssscTrCeYLPYAlllhiiSWWWGKJl4slgVliiSW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cKJL4WrwH1dtGWBi8AV4Dap4eFDz/O5byWFZn8DKdVzf/e6dH9fypXwKukHdnKbV+9hvPcMVZ2R0lz/Hc9DYIC/AnwKeERVV4D/iePxvxT+DGkf39l99ne+yGc/m+1cAy6ceH7f4kEXCv5npDTfaVVdI3XTlhPLnAdy7iGduMQSrwH8PClK8E2v4jpP/mYM6ff0Qteanybd9LwX+MXu+W8kpbhPNn79h6Qo9SLl9ZN3refk9e/ayTGQrnX3inu5zty97sW+PQv8aVVdO/F/X1X/4cvY/hL3iCWBeXXxQZ4npSEi5cn/gQ+T7mD+x0649gHgtwD/qLtb+VvAXxSRc13U5Su7iXNEutDsAH3SD+0kbgAPvsj4/iHw3SKyLSJbwP9Murt4tfE/AV/bpW7uxgg4BCZdmum/exnrHZHSWgcdSfijL7H
|
||
|
"text/plain": [
|
||
|
"<Figure size 576x288 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"display_random_chip(40)"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"anaconda-cloud": {},
|
||
|
"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.9.0"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 4
|
||
|
}
|