.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_02_geosetup.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_02_geosetup.py: Introduction to GeoSetup class =============================== .. GENERATED FROM PYTHON SOURCE LINES 8-12 .. code-block:: Python import matplotlib matplotlib.rcParams['savefig.dpi'] = 300 import geonum .. GENERATED FROM PYTHON SOURCE LINES 13-19 Define domain --------------- Create instance of Geosetup and specify domain by providing latitude and longitude of lower left (ll) and top right (tr) coordinates. Here, the summit region of the volcano Mt. Etna, Sicily, is used as an example. .. GENERATED FROM PYTHON SOURCE LINES 19-26 .. code-block:: Python from geonum.plot_helpers import plot_topo_contourf domain = geonum.GeoSetup(id='Etna region (Sicily)', lat_ll=37.5, lat_tr=38.0, lon_ll=14.8, lon_tr=15.30, topo_access_mode='srtm') .. GENERATED FROM PYTHON SOURCE LINES 27-31 Add 2 GeoPoints to domain ------------------------- Create GeoPoint at summit region of Mt. Etna and add to domain .. GENERATED FROM PYTHON SOURCE LINES 31-38 .. code-block:: Python etna = geonum.GeoPoint(latitude=37.751005, longitude=14.993435, altitude=3264.0, name="Etna summit region") domain.add_geo_point(etna) .. GENERATED FROM PYTHON SOURCE LINES 39-41 Create GeoPoint for location of volcanological observatory at Mt. Etna and add to domain .. GENERATED FROM PYTHON SOURCE LINES 42-49 .. code-block:: Python observatory = geonum.GeoPoint(latitude=37.765755, longitude=15.016696, auto_topo_access=True, name="Observatory") domain.add_geo_point(observatory) .. rst-class:: sphx-glr-script-out .. code-block:: none Retrieving SRTM data (this might take a while) ... 4 2884802 .. GENERATED FROM PYTHON SOURCE LINES 50-52 Load topographic data using SRTM database ----------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 53-55 .. code-block:: Python topo = domain.load_topo_data() .. rst-class:: sphx-glr-script-out .. code-block:: none Retrieving SRTM data (this might take a while) ... 4 2884802 4 2884802 4 2884802 .. GENERATED FROM PYTHON SOURCE LINES 56-64 Make a beautiful map of the GeoSetup ------------------------------------ .. note:: the plotting features of geonum currently undergo revision, and thus, parts of the geonum plot API (geonum.plot_helpers) shown below is not finalised yet and may change. For details and updates related to the revision, see here: https://github.com/jgliss/geonum/issues/4 .. GENERATED FROM PYTHON SOURCE LINES 65-114 .. code-block:: Python import matplotlib.pyplot as plt # Initiate figure and cartopy GeoAxes for map plot ax = geonum.plot_helpers.init_figure_with_geoaxes() # Set x and y limits based on domain ranges ax.set_xlim([domain.ll.longitude, domain.tr.longitude]) ax.set_ylim([domain.ll.latitude, domain.tr.latitude]) # Make a filled contour plot of the topography ax, pdata = plot_topo_contourf( ax, # GeoAxes topo, # geonum.TopoData oceans_separate=True, # plot oceans in light blue levels=50, # number of vertical levels cmap='Oranges' # color map ) # Add colorbar cb = ax.figure.colorbar(pdata, label='Altitude [m]') # Plot contour lines ax.contour( *topo.init_mesh(), topo.data, levels=10, linestyles='--', linewidths=0.1, colors='k') # Plot the 2 GeoPoints that were added to the GeoSetup geonum.plot_helpers.plot_geopoint_into_map(ax,etna, color='w', marker='o', facecolor='none', s=16, annot_kwargs={'xytext': (etna.longitude, etna.latitude-0.05)}) geonum.plot_helpers.plot_geopoint_into_map(ax,observatory, color='w', marker='o', facecolor='none', s=16) # Set title ax.set_title(domain.id) ax = geonum.plot_helpers.set_map_ticks(ax) plt.show() .. image-sg:: /auto_examples/images/sphx_glr_plot_02_geosetup_001.png :alt: Etna region (Sicily) :srcset: /auto_examples/images/sphx_glr_plot_02_geosetup_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.863 seconds) .. _sphx_glr_download_auto_examples_plot_02_geosetup.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_geosetup.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_geosetup.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_geosetup.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_