landcover/Example of how to use our p...

201 строка
649 KiB
Plaintext
Исходник Обычный вид История

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "conceptual-petersburg",
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"import numpy as np\n",
"import matplotlib\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from web_tool.DataLoader import DataLoaderLCLayer, DataLoaderUSALayer\n",
"from web_tool.Utils import COLOR_MAP_LC4\n",
"CMAP_LC = matplotlib.colors.ListedColormap(COLOR_MAP_LC4)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "beginning-suggestion",
"metadata": {},
"outputs": [],
"source": [
"# Georgia Tech polygon -- created haphazardly on http://geojson.io/\n",
"geom = {\"type\":\"Polygon\",\"coordinates\":[[[-84.40798044204712,33.7709248470267],[-84.3883466720581,33.7709248470267],[-84.3883466720581,33.781876094145616],[-84.40798044204712,33.781876094145616],[-84.40798044204712,33.7709248470267]]]}"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "executive-rider",
"metadata": {},
"outputs": [],
"source": [
"lc_loader = DataLoaderLCLayer(padding=0)\n",
"naip_loader = DataLoaderUSALayer(padding=0)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "polish-midwest",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found 1 intersections, returning at 1_3_2019/data/v1/2010/states/ga/ga_1m_2010/33084/m_3308413_se_16_1_20100811_probs.tif\n",
"Found 10 intersections, returning at v002/ga/2019/ga_60cm_2019/33084/m_3308413_se_16_060_20190910.tif\n"
]
}
],
"source": [
"lc_data = lc_loader.get_data_from_geometry(geom)\n",
"naip_data = naip_loader.get_data_from_geometry(geom)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "victorian-southwest",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1262, 1851, 4)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lc_data.shape # this is height x width x per-class probabilities"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "fifty-family",
"metadata": {},
"outputs": [],
"source": [
"lc_data = lc_data.data.argmax(axis=2)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "actual-offset",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(2102, 3083, 4)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"naip_data.shape # this is height x width x channels -- the channels are R,G,B,NIR"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "protected-canada",
"metadata": {},
"outputs": [],
"source": [
"naip_data = naip_data.data[:,:,:3] # Keep the RGB channels"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "exclusive-saturday",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjwAAAGKCAYAAAAIdJtvAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9V5dlS5alh30mtzraZeiIK1NWZ3U2UMVqAiAG8E7+Nr7ygb+AL1QDHE0Jkt2NFlVZIsXNzCtCerg6fuTWZsYH2+4RWdWd6M4aTQA9fI1xw8Ovu584vrdts7XmmnMuEULgPu7jPu7jPu7jPu7jP+aQ/0O/gfu4j/u4j/u4j/u4j//QcZ/w3Md93Md93Md93Md/9HGf8NzHfdzHfdzHfdzHf/Rxn/Dcx33cx33cx33cx3/0cZ/w3Md93Md93Md93Md/9KF/3xeFEPcSrvu4j/u4j/u4j/8JhhDi3/o1qSRG/24KcPv91hjyPAMB3GYBIv6hleLgYI4Q8fud8zjn8SGw2jcsDg+w1pAYzdFsTAie1FpCCORFznQyoneBX788I01TpJR0vQMh+JOffMmLx48IIdA0DdZapFS0ruN/93/8v/J/+T/8n/97f+cQwr/1l/69Cc993Md93Md93Md9/DuGECgphsT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r4SYB+gLatMSSJQWiBVfbuUIlETrA2pXWCfbNHaI9JJcEFjFAUNqHsJMZYfvK9p1gleHm24d3minwCaZEzG2Vk1pIZjXSWr96eE1TL8j3kU83sMEXaQJYp5pOEEAQHmcFqw7vzmjfXFcKCTTTtLmASxXRu0cMh/aMHD/D7lP/bX33Fwy/gaJS
"text/plain": [
"<Figure size 720x720 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjwAAAGKCAYAAAAIdJtvAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAACWiklEQVR4nO1da5bjOqvV+dYdSGbWNZMkM0nNrGbS90dHLowBAUIPO9pr1TqnY1uW9UAINui/v3//poWFhYWFhYWFK+N/oyuwsLCwsLCwsNAaS+FZWFhYWFhYuDyWwrOwsLCwsLBweSyFZ2FhYWFhYeHyWArPwsLCwsLCwuXxf9LF//5LK4RrYWFhYWFhoR73/9L9cU/p6+f3t9ft33/hbwye36/iPX//pv+4a6LCs7CwsLCwsHBO3P980RcMSkYV8nveeD6Y+1rX442l8CwsLCwsLBC4//k6LNopJXqBft/3fDz/Pfvzp1W16hGlYLxufFlEu90f95j3OrEUnoWFhYWFacBaJQCet+8278bulqsh0rJDKYIKPB/PdE9IGexkcVoKz8LCwsIHQ6NgfAKirA9bOQ0W7+ftex7L0dePS+kZqVQuhWdhYWGhAmaFQbtIRC8Ktbto7L6A/+7FCXkjKxXZfRRVXhhatMPrltKjsgynkiKWdyIshWdhYeF02LgVhMDF7g73YtZq0bLeP9OiErlY1uDrJ8StdRgbAW39fDxTurXh8FzG5caNazy+gr91KTwLCwtF3P98qReY++MetvPeysSLRxaMGoVgpgXCWpfIult299hiU3quZRu/+ziat6NWhKOtIqPRaz5o2s1yPaDe/0m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720x720 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(10,10))\n",
"plt.imshow(naip_data)\n",
"plt.axis(\"off\")\n",
"plt.show()\n",
"plt.close()\n",
"\n",
"plt.figure(figsize=(10,10))\n",
"plt.imshow(lc_data, cmap=CMAP_LC, vmin=0, vmax=3, interpolation=\"none\")\n",
"plt.axis(\"off\")\n",
"plt.show()\n",
"plt.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "consolidated-spell",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "landcover",
"language": "python",
"name": "conda-env-landcover-py"
},
"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.8.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}