... a collection of examples that show how to create beautiful interactive maps.
There are 3 basic steps required to visualize your data:
- Initialize a Maps-object with
m = Maps()
- Set the data and its specifications via
m.set_data
- Call
m.plot_map()
to generate the map!
.. literalinclude:: examples/example_basics.py
- use
m.set_plot_specs()
to set the general appearance of the plot - after creating the plot, you can access individual objects via
m.figure.<...>
… most importantly:f
: the matplotlib figureax
,ax_cb
,ax_cb_plot
: the axes used for plotting the map, colorbar and histogramgridspec
,cb_gridspec
: the matplotlib GridSpec instances for the plot and the colorbarcoll
: the collection representing the data on the map
.. literalinclude:: examples/example_customization.py
Create grids of maps via
MapsGrid
- Classify your data via
m.set_classify_specs(scheme, **kwargs)
(using classifiers provided by themapclassify
module) - Add individual callback functions to each subplot via
m.cb.click.attach
,m.cb.pick.attach
- Share events between Maps-objects of the MapsGrid via
mg.share_click_events()
andmg.share_pick_events()
.. literalinclude:: examples/example_multiple_maps.py
Callback functions can easily be attached to the plot to turn it into an interactive plot-widget!
- there’s a nice list of (customizable) pre-defined callbacks accessible via:
m.cb.click
,m.cb.pick
,m.cb.keypress
andm.cb.dynamic
- use
annotate
(andclear_annotations
) to create text-annotations - use
mark
(andclear_markers
) to add markers - use
peek_layer
(andswitch_layer
) to compare multiple layers of data - ... and many more:
plot
,print_to_console
,get_values
,load
...
- use
- ... but you can also define a custom one and connect it via
m.cb.click.attach(<my custom function>)
(works also withpick
andkeypress
)!
.. literalinclude:: examples/example_callbacks.py
(… plot-generation might take a bit longer since overlays need to be downloaded first!)
- add basic overlays with m.add_overlay
- add static annotations / markers with m.add_annotation and m.add_marker
- use “connected” Maps-objects to get multiple interactive data-layers!
.. literalinclude:: examples/example_overlays.py
- The data displayed in the above gif is taken from:
- NaturalEarth (https://www.naturalearthdata.com/)
- add WebMap services using
m.add_wms
andm.add_wmts
- compare different data-layers and WebMap services using
m.cb.click.peek_layer
andm.cb.keypress.switch_layer
.. literalinclude:: examples/example_webmaps.py
- The data displayed in the above gif is taken from:
- Sentinel-1 Global Backscatter Model (https://researchdata.tuwien.ac.at/records/n2d1v-gqb91)
- OpenStreetMap hosted by Mundialis (https://www.mundialis.de/en/ows-mundialis/)
EOmaps can be used to assign callbacks to vektor-data (e.g. geopandas.GeoDataFrames
).
to make a GeoDataFrame pickable, first use
m.add_gdf(picker_name="MyPicker")
- now you can assign callbacks via
m.cb.pick__MyPicker.attach...
just as you would do with the ordinarym.cb.click
orm.cb.pick
callbacks
- now you can assign callbacks via
Note
For large datasets that are visualized as simple rectangles, ellipses etc.
it is recommended to use EOmaps to visualize the data with m.plot_map()
since the generation of the plot and the identification of the picked pixels
will be much faster!
If the GeoDataFrame contains multiple different geometry types (e.g. Lines, Patches, etc.) a unique pick-collection will be assigned for each of the geometry types!
.. literalinclude:: examples/example_vector_data.py
- The data displayed in the above gif is taken from:
- NaturalEarth (https://www.naturalearthdata.com/)
- EOmaps has a nice customizable scalebar feature!
- use
s = m.add_scalebar(lon, lat, azim)
to attach a scalebar to the plot - once the scalebar is there, you can drag it around and change its
properties via
s.set_position
,s.set_scale_props()
,s.set_label_props()
ands.set_patch_props()
- use
Note
You can also simply drag the scalebar with the mouse!
- LEFT-click on it to make it interactive!
- RIGHT-click anywhere on the map to make it fixed again
There are also some useful keyboard shortcuts you can use while the scalebar is interactive
- use
+
/-
to rotate the scalebar - use
alt
++
/-
to set the text-offset - use the
arrow-keys
to increase the frame-widths - use
alt
+arrow-keys
to decrease the frame-widths - use
delete
to remove the scalebar from the plot
.. literalinclude:: examples/example_scalebars.py
- The data displayed in the above gif is taken from:
- NaturalEarth (https://www.naturalearthdata.com/)
Callback-functions can be used to trigger updates on other plots. This example shows how to use EOmaps to analyze a database that is associated with a map.
- create a grid of
Maps
objects and ordinary matplotlib axes viaMapsGrid
- define a custom callback to update the plots if you click on the map
.. literalinclude:: examples/example_timeseries.py
Use custom callback functions to perform arbitrary tasks on the data when clicking on the map.
- Identify clicked row/col in a 2D dataset
- Highlight the found row and column using a new layer
(requires EOmaps >= v3.1.4)
.. literalinclude:: examples/example_row_col_selector.py
Quickly create nice inset-maps to show details for specific regions.
- the location and extent of the inset can be defined in any given crs
- (or as a geodesic circle with a radius defined in meters)
- the inset-map can have a different crs than the "parent" map
(requires EOmaps >= v4.1)
.. literalinclude:: examples/example_inset_maps.py
Draw lines defined by a set of anchor-points and add some nice annotations.
Connect the anchor-points via:
- geodesic lines
- straight lines
- reprojected straight lines defined in a given projection
(requires EOmaps >= v4.3.1)
.. literalinclude:: examples/example_lines.py
Draw custom grids and add grid labels.
(requires EOmaps >= v6.5)
.. literalinclude:: examples/example_gridlines.py
Use the contour
-shape to draw contour-plots of regular (or irregular data)
or to indicate contour-levels on top of other plots.
(requires EOmaps >= v7.1)
.. literalinclude:: examples/example_contour.py