{"cells":[{"cell_type":"markdown","metadata":{"_cell_guid":"87176732-d1b5-21bd-a7f6-34ee1e353f40"},"source":"Look at image 6120_2_2 in all it's forms"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"ce5e3d84-077c-e98a-44c3-a63f795d3131"},"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\nlibrary(ggplot2) # Data visualization\nlibrary(readr) # CSV file I/O, e.g. the read_csv function\nlibrary(raster) # Read and plot TIFF files\nlibrary(rgeos) # Read and plot WKT\n\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"456325ff-3f24-220f-89df-5868e0afd70a"},"outputs":[],"source":"# Start by looking at the RGB version\n\nimgs <- stack(\"../input/three_band/6120_2_2.tif\")\nplotRGB(imgs, stretch = \"lin\")\n"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"fa9ad4f8-7f40-d6a0-98df-2cca17c8da8a"},"outputs":[],"source":"# Let's look at the WKT shapes\n\n# Get WKT data and find rows related to our image\ndat <- read.csv(\"../input/train_wkt_v4.csv\", stringsAsFactors = FALSE)\nidx <- grep(\"6120_2_2\", dat$ImageId)\n\nnewplt <- TRUE\nfor(i in 1:length(idx)){\n  dat1 <- dat[idx[i],]\n  dat2 <- try(readWKT(dat1$MultipolygonWKT))\n  if(class(dat2) != \"try-error\"){\n    if(newplt){\n      plot(dat2, col = dat1$ClassType, main = paste(dat1$ImageId))\n      newplt = FALSE\n    } else {\n      plot(dat2, col = dat1$ClassType, add = TRUE)\n    }\n  } \n}"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"c6a52631-78b4-fc03-6a76-4e9464fcdc5c"},"outputs":[],"source":"# Let's look at the individual WKT maps\n\n## Plot individual maps - better\nfor(i in 1:length(idx)){\n  dat1 <- dat[idx[i],]\n  dat2 <- try(readWKT(dat1$MultipolygonWKT))\n  if(class(dat2) != \"try-error\") plot(dat2, col = dat1$ClassType, main = paste(dat1$ImageId, \"Class\", dat1$ClassType))\n}\n    \n# Note that these plots are not on the same scale"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"39bcc4fe-ee47-2ed5-1e00-84f27c274f61"},"outputs":[],"source":"# Let's look at the RGB images separately\nimgs <- stack(\"../input/three_band/6120_2_2.tif\")\nplot(imgs)"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"4cc05150-ffe3-836d-045a-bfd6bbaa8218"},"outputs":[],"source":"# Let's look at the A images\n\nimgs16 <- stack(\"../input/sixteen_band/6120_2_2_A.tif\")\nplot(imgs16)"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"bced2f40-454a-bc3e-14c4-a976997d38f0"},"outputs":[],"source":"# Let's look at the M images\n\nimgs16 <- stack(\"../input/sixteen_band/6120_2_2_M.tif\")\nplot(imgs16)"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"e7472508-f453-01c4-6843-2ebbdae0e0b4"},"outputs":[],"source":"# Finally, let's look at the P image\n\nimgs16 <- stack(\"../input/sixteen_band/6120_2_2_P.tif\")\nplot(imgs16)"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"292849bc-0307-9892-b645-09c06b16815f"},"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}