{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n\n============================\nimshow() and map projections\n============================\n\nUsing rasterio's projection information for more accurate plots.\n\nThis example extends `recipes.rasterio` and plots the image in the\noriginal map projection instead of relying on pcolormesh and a map\ntransformation.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import os\nimport urllib.request\n\nimport cartopy.crs as ccrs\nimport matplotlib.pyplot as plt\n\nimport xarray as xr\n\n# Download the file from rasterio's repository\nurl = 'https://github.com/mapbox/rasterio/raw/master/tests/data/RGB.byte.tif'\nurllib.request.urlretrieve(url, 'RGB.byte.tif')\n\n# Read the data\nda = xr.open_rasterio('RGB.byte.tif')\n\n# The data is in UTM projection. We have to set it manually until\n# https://github.com/SciTools/cartopy/issues/813 is implemented\ncrs = ccrs.UTM('18N')\n\n# Plot on a map\nax = plt.subplot(projection=crs)\nda.plot.imshow(ax=ax, rgb='band', transform=crs)\nax.coastlines('10m', color='r')\nplt.show()\n\n# Delete the file\nos.remove('RGB.byte.tif')"
      ]
    }
  ],
  "metadata": {
    "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.7.3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}