{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "fa0d6cb6-b52d-0249-cd63-269ce0790efb"
      },
      "source": [
        "Let's try to stitch one of these 16 channel images together"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "cf3f0d7b-9623-97b1-1e14-4ee4fa3fa0e1"
      },
      "outputs": [],
      "source": [
        "# This R environment comes with all of CRAN preinstalled, as well as many other helpful packages\n",
        "# The environment is defined by the kaggle/rstats docker image: https://github.com/kaggle/docker-rstats\n",
        "# For example, here's several helpful packages to load in \n",
        "\n",
        "library(ggplot2) # Data visualization\n",
        "library(readr) # CSV file I/O, e.g. the read_csv function\n",
        "library(raster) # read and manipulate raster images\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "b2ac1cd4-a52b-5839-fde8-cf2bfe0eedf5"
      },
      "outputs": [],
      "source": [
        "## Plot composite 16 channel tiles\n",
        "\n",
        "files16 <- list.files(path=\"../input/sixteen_band/\", pattern=\"6120_\", full.names=T, recursive=FALSE)\n",
        "tokeep <- files16[grep(\"_P.tif\", files16)]\n",
        "tokeep\n",
        "\n",
        "par(mfrow = c(5,5))\n",
        "par(mar = c(0.1,0.1,0.1,0.1))\n",
        "for(i in tokeep){\n",
        "    thisfile <- i\n",
        "    img <- stack(thisfile)\n",
        "    plot(img, axes = FALSE, legend = FALSE)\n",
        "}"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "0102fd40-f094-f2ec-45ea-8b93afc0346a"
      },
      "outputs": [],
      "source": [
        "## Plot composite RGB tiles\n",
        "\n",
        "files3 <- list.files(path=\"../input/three_band/\", pattern=\"6120_\", full.names=T, recursive=FALSE)\n",
        "files3\n",
        "\n",
        "par(mfrow = c(5,5))\n",
        "par(mar = c(0.1,0.1,0.1,0.1))\n",
        "for(i in files3){\n",
        "  thisfile <- i\n",
        "  img <- stack(thisfile)\n",
        "  plotRGB(img, stretch = \"lin\", axes = FALSE)\n",
        "}"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "55b4e33b-be1a-e2a8-bdcb-817e89526cf1"
      },
      "outputs": [],
      "source": [
        "## Close up of image 6120_2_4\n",
        "\n",
        "imgs <- stack(\"../input/three_band/6120_2_4.tif\")\n",
        "plotRGB(imgs, stretch = \"lin\")\n",
        "plot(imgs)\n",
        "\n",
        "imgs16 <- stack(\"../input/sixteen_band/6120_2_4_P.tif\")\n",
        "plot(imgs16)"
      ]
    }
  ],
  "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
}