{ "cells": [ { "cell_type": "markdown", "id": "ce804b47-f7b6-4571-aeef-4c485da24548", "metadata": { "date": "2022-01-07", "tags": [ "solar", "open", "science" ] }, "source": [ "# How to add an inset map with Cartopy in Python\n", "\n", "```{post} 06 Jan 2022\n", ":tags: open science, python\n", ":author: Adam R. Jensen\n", ":image: 1\n", "```\n", "\n", "You know that small map that shows a zoomed-in view of a part of a bigger map? Well, it's called an inset map, and according to [Wikipedia](https://en.wikipedia.org/wiki/Map_layout#Inset_map):\n", "> Inset maps are smaller maps that are included on the same page as the main map. They can show additional information related to the main map." ] }, { "cell_type": "markdown", "id": "a701ad2e-9199-419a-8a23-755d8b0a4dc1", "metadata": { "date": "2022-01-07", "tags": [ "solar", "open", "science" ] }, "source": [ "There are four common types of inset maps:\n", "* **Locator map:** used to show the position of the map in a larger context\n", "* **Detail inset:** (significantly larger scale (aka. zoomed-in) to show more details in part of the map)\n", "* **Thematic inset:** depicts the same area as the main map, but in a different theme, for example showing the solar resource\n", "* **Extension inset:** shows a non-contiguous area related to the map, typically of an island or territory\n", "\n", "In this tutorial, I'll show you have you can add a detailed inset, which can be a cool and informative addition to your map.\n", "\n", "Import necessary libraries:" ] }, { "cell_type": "code", "execution_count": 1, "id": "c77a3336-9b3f-442f-a907-507fd0e4af6f", "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import cartopy\n", "import cartopy.crs as ccrs" ] }, { "cell_type": "markdown", "id": "0bf5c4a2-0fe2-4e4d-8dfd-0201e940f50c", "metadata": {}, "source": [ "In order to have some example data to plot, we'll import coordinates of solar radiation monitoring stations from [SolarStations.org](https://SolarStations.org):" ] }, { "cell_type": "code", "execution_count": 2, "id": "97e1cce9-5cc5-4785-8e6b-9ff43adfe60e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Station full name | \n", "Abbreviation | \n", "State | \n", "Country | \n", "Latitude | \n", "Longitude | \n", "Elevation | \n", "
---|---|---|---|---|---|---|---|
0 | \n", "Abashiri | \n", "ABS | \n", "\n", " | Japan | \n", "44.0178 | \n", "144.2797 | \n", "38.0 | \n", "
1 | \n", "Alert | \n", "ALE | \n", "Lincoln Sea | \n", "Canada | \n", "82.4900 | \n", "-62.4200 | \n", "127.0 | \n", "
2 | \n", "Alice Springs | \n", "ASP | \n", "Northern Territory | \n", "Australia | \n", "-23.7980 | \n", "133.8880 | \n", "547.0 | \n", "