OSGeoLive-Notebooks/Cartopy/cartopy-utm-zones.ipynb

103 lines
2.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Displaying all 60 zones of the UTM projection\n",
"---------------------------------------------\n",
"\n",
"This example displays all 60 zones of the Universal Transverse Mercator\n",
"projection next to each other in a figure.\n",
"\n",
"First we create a figure with 60 subplots in one row.\n",
"Next we set the projection of each axis in the figure to a specific UTM zone.\n",
"Then we add coastlines, gridlines and the number of the zone.\n",
"Finally we add a supertitle and display the figure."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import cartopy.crs as ccrs\n",
"import matplotlib.pyplot as plt\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"\n",
"def main():\n",
" # Create a list of integers from 1 - 60\n",
" zones = range(1, 61)\n",
"\n",
" # Create a figure\n",
" fig = plt.figure(figsize=(18, 6))\n",
"\n",
" # Loop through each zone in the list\n",
" for zone in zones:\n",
"\n",
" # Add GeoAxes object with specific UTM zone projection to the figure\n",
" ax = fig.add_subplot(1, len(zones), zone,\n",
" projection=ccrs.UTM(zone=zone,\n",
" southern_hemisphere=True))\n",
"\n",
" # Add coastlines, gridlines and zone number for the subplot\n",
" ax.coastlines(resolution='110m')\n",
" ax.gridlines()\n",
" ax.set_title(zone)\n",
"\n",
" # Add a supertitle for the figure\n",
" fig.suptitle(\"UTM Projection - Zones\")\n",
"\n",
" # Display the figure\n",
" plt.show()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"main()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}