{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "fa0d6cb6-b52d-0249-cd63-269ce0790efb"
      },
      "source": [
        "This mod of JeffH's [notebook][1] just plots one composite 5x5 3-band image at a reduced resolution so that the plotting goes faster. You put the number of the image you want to look at in the IMG constant below.\n",
        "\n",
        "\n",
        "  [1]: https://www.kaggle.com/jeffhebert/dstl-satellite-imagery-feature-detection/stitch-a-16-channel-image-together/notebook"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "0ec4f6b7-9698-eade-0b50-81c5730cc878"
      },
      "outputs": [],
      "source": [
        "# The image number for the master image that you want stitched together.\n",
        "IMG <- 6110\n",
        "\n",
        "# Controls resolution, default is 500K, this speeds it up a little\n",
        "MAXPIXELS <- 100000"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "cf3f0d7b-9623-97b1-1e14-4ee4fa3fa0e1"
      },
      "outputs": [],
      "source": [
        "library(sp)\n",
        "library(raster) "
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "0102fd40-f094-f2ec-45ea-8b93afc0346a"
      },
      "outputs": [],
      "source": [
        "## Plot composite RGB tiles. Note that this takes a minute or two.\n",
        "pat <- paste0(IMG, '_')\n",
        "img.files <- list.files(path=\"../input/three_band/\", \n",
        "                        pattern=pat, full.names=T, recursive=FALSE)\n",
        "c(pat, img.files[1])            # Quick check that the pattern and paths are as-expected\n",
        "par(mfrow = c(5,5))\n",
        "par(mar = c(0.1,0.1,0.1,0.1))\n",
        "for(thisfile in img.files){\n",
        "  img <- brick(thisfile)\n",
        "  plotRGB(img, stretch = \"lin\", axes = FALSE, maxpixels=MAXPIXELS)\n",
        "}"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "922da24e-3a8f-48d0-d1dc-81ef20d8d2fe"
      },
      "outputs": [],
      "source": [
        " "
      ]
    }
  ],
  "metadata": {
    "_change_revision": 0,
    "_is_fork": false,
    "kernelspec": {
      "display_name": "R",
      "language": "R",
      "name": "ir"
    },
    "language_info": {
      "codemirror_mode": "r",
      "file_extension": ".r",
      "mimetype": "text/x-r-source",
      "name": "R",
      "pygments_lexer": "r",
      "version": "3.3.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}