.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_03_elevationprofile.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_03_elevationprofile.py: Retrieval of elevation profiles =============================== This example shows how to compute and plot elevation profiles. Elevation profiles are computed between 2 locations which are specified by the user. In this example, the volcano Mt. Etna is used to compute the elevation profile between the Etna volcano observatory and the summit region with the active craters. This script guides through some of the core features of geonum, including: - GeoPoint class - GeoVector3D class - Topographic data access - Domain setup (GeoSetup class) - Computation and plotting of elevation profiles .. GENERATED FROM PYTHON SOURCE LINES 22-26 .. code-block:: Python import matplotlib matplotlib.rcParams['savefig.dpi'] = 300 import geonum .. GENERATED FROM PYTHON SOURCE LINES 27-30 Define 2 locations for retrieval of elevation profile ----------------------------------------------------- Summit region of Mt. Etna .. GENERATED FROM PYTHON SOURCE LINES 30-35 .. code-block:: Python etna = geonum.GeoPoint(latitude=37.751005, longitude=14.993435, altitude=3264.0, name="Etna summit region") .. GENERATED FROM PYTHON SOURCE LINES 36-37 Position of volcanological observatory of Mt. Etna .. GENERATED FROM PYTHON SOURCE LINES 37-42 .. code-block:: Python observatory = geonum.GeoPoint(latitude=37.765755, longitude=15.016696, auto_topo_access=True, name="Observatory") .. rst-class:: sphx-glr-script-out .. code-block:: none Retrieving SRTM data (this might take a while) ... .. GENERATED FROM PYTHON SOURCE LINES 43-47 Define regional domain that includes both locations ---------------------------------------------------- Regional domains can be specified using the GeoSetup class .. GENERATED FROM PYTHON SOURCE LINES 47-49 .. code-block:: Python domain = geonum.GeoSetup(points=[etna, observatory]) .. GENERATED FROM PYTHON SOURCE LINES 50-51 Get lower left and upper right corner coordinates of domain .. GENERATED FROM PYTHON SOURCE LINES 51-54 .. code-block:: Python pll = domain.ll ptr = domain.tr .. GENERATED FROM PYTHON SOURCE LINES 55-59 Access topographic data for domain -------------------------------------------------- Instantiate topo data access class for SRTM access .. GENERATED FROM PYTHON SOURCE LINES 59-61 .. code-block:: Python topo_access = geonum.TopoDataAccess(mode='srtm') .. GENERATED FROM PYTHON SOURCE LINES 62-63 Retrieve topographic data within domain ranges .. GENERATED FROM PYTHON SOURCE LINES 63-66 .. code-block:: Python topo_data = topo_access.get_data(lat0=pll.latitude, lon0=pll.longitude, lat1=ptr.latitude, lon1=ptr.longitude) .. rst-class:: sphx-glr-script-out .. code-block:: none Retrieving SRTM data (this might take a while) ... .. GENERATED FROM PYTHON SOURCE LINES 67-72 Retrieve elevation profile between 2 locations ----------------------------------------------- Instantiate class ElevationProfile with Etna Observatory as start point and Etna summit as end point and provide topographic data .. GENERATED FROM PYTHON SOURCE LINES 72-76 .. code-block:: Python eprof = geonum.ElevationProfile(observer=observatory, endpoint=etna, topo_data=topo_data) .. GENERATED FROM PYTHON SOURCE LINES 77-78 Calculate elevation profile .. GENERATED FROM PYTHON SOURCE LINES 78-80 .. code-block:: Python altitudes = eprof.det_profile(interpolate=False) .. GENERATED FROM PYTHON SOURCE LINES 81-82 Retrieved altitude values along profile .. GENERATED FROM PYTHON SOURCE LINES 82-84 .. code-block:: Python print(altitudes) .. rst-class:: sphx-glr-script-out .. code-block:: none [2820. 2803.38434985 2788.4426275 2786.07415648 2780.87029164 2779.4304659 2803.53717071 2845.40720928 2893.13123799 2931.05228895 2965.86139849 3000.92669324 3033.39393452 3066.25692462 3098.21839842 3138.07633286 3183.76697416 3238.69112989 3271.69199096 3297.02164997 3253.55858007 3240.22676008 3263.04325754 3264. ] .. GENERATED FROM PYTHON SOURCE LINES 85-86 Corresponding (horizontal) distances in km, to start point of profile .. GENERATED FROM PYTHON SOURCE LINES 86-88 .. code-block:: Python print(eprof.dists) .. rst-class:: sphx-glr-script-out .. code-block:: none [0. 0.11502853 0.23005706 0.34508558 0.46011411 0.57514264 0.69017117 0.8051997 0.92022822 1.03525675 1.15028528 1.26531381 1.38034234 1.49537086 1.61039939 1.72542792 1.84045645 1.95548498 2.0705135 2.18554203 2.30057056 2.41559909 2.53062762 2.64565614] .. GENERATED FROM PYTHON SOURCE LINES 89-94 Plot the profile ---------------- On the x-axis, the distances are plotted, and on the y-axis, the corresponding altitude values that were retrieved from the SRTM dataset. .. GENERATED FROM PYTHON SOURCE LINES 94-119 .. code-block:: Python ax = eprof.plot() # add title ax.set_title('Etna summit region') # Add name of the observatory location to the plot ax.annotate(observatory.name, xy=(0, observatory.altitude), # location of observatory in plot xytext=(0.05, observatory.altitude+50), # location of text arrowprops=dict(color='black', lw=1, arrowstyle='->', ), ha='left', size=11 ) # Get vector connecting the 2 locations diffvec = etna-observatory # Get horizontal distance of summit from observatory summit_dist = diffvec.dist_hor # Add name of summit region to the plot _ = ax.annotate(etna.name, xy=(summit_dist, etna.altitude), # location of observatory in plot xytext=(summit_dist-0.8, etna.altitude+50), arrowprops=dict(color='black', lw=1, arrowstyle='->', ), ha='left', size=11 ) .. image-sg:: /auto_examples/images/sphx_glr_plot_03_elevationprofile_001.png :alt: Etna summit region :srcset: /auto_examples/images/sphx_glr_plot_03_elevationprofile_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.186 seconds) .. _sphx_glr_download_auto_examples_plot_03_elevationprofile.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_elevationprofile.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_elevationprofile.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_03_elevationprofile.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_