{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "bfde80e1-5c0f-ff3b-4461-85a82f102366"
      },
      "source": [
        "Partly forked from https://www.kaggle.com/torrinos/dstl-satellite-imagery-feature-detection/exploration-and-plotting/discussion"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "837c13bf-6ff7-a8bc-5fee-12c2424ae02e"
      },
      "outputs": [],
      "source": [
        "import pandas as pd\n",
        "import numpy as np\n",
        "from shapely.wkt import loads\n",
        "from matplotlib.patches import Polygon\n",
        "import matplotlib.pyplot as plt\n",
        "\n",
        "df = pd.read_csv('../input/train_wkt.csv')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "291eef4b-8c2d-e0a7-48a7-5f51ed46dfab"
      },
      "outputs": [],
      "source": [
        "for ids in ['6100_1_3', '6010_4_2', '6010_4_4', '6140_3_1', '6170_2_4', '6040_1_3', '6040_2_2', '6170_4_1', '6110_4_0', '6120_2_2', '6100_2_3', '6120_2_0', '6150_2_3', '6110_1_2', '6170_0_4', '6160_2_1', '6090_2_0', '6140_1_2', '6060_2_3', '6110_3_1', '6040_1_0']:\n",
        "    polygonsList = {}\n",
        "    image = df[df.ImageId == ids]\n",
        "    for cType in image.ClassType.unique():\n",
        "        polygonsList[cType] = loads(image[image.ClassType == cType].MultipolygonWKT.values[0])\n",
        "    fig, ax = plt.subplots(figsize=(9, 9))\n",
        "    for p in polygonsList:\n",
        "        for polygon in polygonsList[p]:\n",
        "            mpl_poly = Polygon(np.array(polygon.exterior), color=plt.cm.Set1(p*10), lw=0, alpha=0.3)\n",
        "            ax.add_patch(mpl_poly)\n",
        "    ax.relim()\n",
        "    ax.autoscale_view()\n",
        "    plt.title(ids)"
      ]
    }
  ],
  "metadata": {
    "_change_revision": 0,
    "_is_fork": false,
    "kernelspec": {
      "display_name": "Python 3",
      "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.5.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}