api

Plotting tools for visualizing rioxarray variables on ipyleaflet maps

Source code

General Attributes and Methods

class IS2view.api.Leaflet(projection, **kwargs)[source]

Create interactive leaflet maps for visualizing ATL14/15 data

Parameters:
mapobj or NoneType, default None

ipyleaflet.Map

basemapobj or NoneType

Basemap for the ipyleaflet.Map

layoutobj, default ipywidgets.Layout(width='70%', height='600px')

Layout for the ipyleaflet.Map

attributionbool, default False

Include layer attributes on leaflet map

scale_controlbool, default False

Include spatial scale bar to map

cursor_controlbool, default True

Include display for cursor location

full_screen_control: bool, default False

Include control for full screen map view

layer_controlbool, default True

Include control for added map layers

draw_controlbool, default False

Include control for interactively drawing on map

draw_toolslist, default [‘marker’, ‘polyline’, ‘rectangle’, ‘polygon’]

Interactive drawing tools to include with control

colorstr, default ‘blue’

Color of drawn or included GeoJSON objects

centertuple, default (0, 0)

Map center at (latitude, longitude)

zoomint, default 1

Initial map zoom level

Attributes:
mapobj

ipyleaflet.Map

crsstr

Coordinate Reference System of map

layer_controlobj

ipyleaflet.LayersControl

scale_controlobj

ipyleaflet.ScaleControl

cursorobj

ipywidgets.Label with cursor location

geometriesdict

GeoJSON formatted geometries

handle_interaction(**kwargs)[source]

callback for handling mouse motion and setting location label

handle_draw(obj, action, geo_json)[source]

callback for handling draw events

wrap_longitudes(lon)[source]

Fix longitudes to be within -180 and 180

add_geodataframe(gdf, **kwargs)[source]

Add a GeoDataFrame to map and append to list of geometries

Parameters:
gdfobj

geopandas GeoDataFrame

kwargsdict, default {}

Keyword arguments for GeoJSON

to_geojson(filename, **kwargs)[source]

Output geometries to a GeoJSON file

Parameters:
filenamestr

Output GeoJSON filename

kwargsdict, default {}

Additional attributes for the GeoJSON file

add(obj)[source]

wrapper function for adding layers and controls to leaflet maps

remove(obj)[source]

wrapper function for removing layers and controls to leaflet maps

plot_basemap(ax=None, **kwargs)[source]

Plot the current basemap

Parameters:
ax: obj, default None

Figure axis

kwargs: dict, default {}

Additional keyword arguments for owslib.wms.getmap

plot_geometries(ax=None, **kwargs)[source]

Plot the current geometries in the coordinate reference system (crs) of the map

Parameters:
ax: obj, default None

Figure axis

kwargs: dict, default {}

Additional keyword arguments for plot

property layers

get the map layers

property controls

get the map controls

IS2view.api.image_service_layer(name, raster='hillshade')[source]

Creates image service layers with optional raster functions

Parameters:
namestr

Name of the image service layer

  • ArcticDEM

  • REMA

rasterstr, default ‘hillshade’

Name of the raster function for image service layer

  • aspect: Slope Aspect Map

  • contour: Elevation Contours Map

  • ellipsoidal: Ellipsoidal Elevation Map

  • hillshade: Gray Hillshade Map

  • orthometric: Orthometric Elevation Map

  • slope: Slope Map

  • smoothed: Smoothed Contours Map

  • tinted: Tinted Hillshade Map

class IS2view.api.LeafletMap(**kwargs: Any)[source]

A xarray.DataArray extension for interactive map plotting, based on ipyleaflet

Parameters:
dsobj

xarray.Dataset

Attributes:
_dsobj

xarray.Dataset

_ds_selectedobj

xarray.Dataset for selected variable

_variablestr

Selected variable

mapobj

ipyleaflet.Map

crsstr

Coordinate Reference System of map

left, top, right, bottomfloat

Map bounds in image coordinates

swdict

Location of lower-left corner in projected coordinates

nedict

Location of upper-right corner in projected coordinates

boundstuple

Location of map bounds in geographical coordinates

imageobj

ipyleaflet.ImageService layer for variable

cmapobj

Matplotlib colormap object

normobj

Matplotlib normalization object

opacityfloat

Transparency of image service layer

colorbarobj

ipyleaflet.WidgetControl with Matplotlib colorbar

popupobj

ipyleaflet.Popup with value at clicked location

_datafloat

Variable value at clicked location

_unitsstr

Units of selected variable

plot(m, **kwargs)[source]

Creates image plots on leaflet maps

Parameters:
mobj

leaflet map to add the layer

variablestr, default ‘delta_h’

xarray variable to plot

lagint, default 0

Time lag to plot if 3-dimensional

cmapstr, default ‘viridis’

matplotlib colormap

vminfloat or NoneType

Minimum value for normalization

vmaxfloat or NoneType

Maximum value for normalization

normobj or NoneType

Matplotlib color normalization object

opacityfloat, default 1.0

Opacity of image plot

enable_popupsbool, default False

Enable contextual popups

colorbarbool, decault True

Show colorbar for rendered variable

positionstr, default ‘topright’

Position of colorbar on leaflet map

add(obj)[source]

wrapper function for adding layers and controls to leaflet maps

remove(obj)[source]

wrapper function for removing layers and controls to leaflet maps

property z

get the map zoom level

property resolution

get the map resolution for a given zoom level

reset()[source]

remove features from leaflet map

get_bbox()[source]

get the bounding box of the leaflet map in projected coordinates

get_bounds()[source]

get the bounds of the leaflet map in geographical coordinates

get_crs()[source]

Attempt to get the coordinate reference system of the dataset

get_norm_bounds(**kwargs)[source]

Get the colorbar normalization bounds

Parameters:
vminfloat or NoneType

Minimum value for normalization

vmaxfloat or NoneType

Maximum value for normalization

validate_norm()[source]

Validate the colorbar normalization bounds

clip_image(ds)[source]

clip or warp xarray image to bounds of leaflet map

get_image_url()[source]

create the image url for the imageservice

set_image_url(*args, **kwargs)[source]

set the url for the imageservice

redraw(*args, **kwargs)[source]

Redraw the image on the map

redraw_colorbar(*args, **kwargs)[source]

Redraw the colorbar on the map

set_observables(widget, **kwargs)[source]

observe changes in widget parameters

set_dataset()[source]

Select the dataset for the selected variable and time lag

set_variable(sender)[source]

update the plotted variable

set_lag(sender)[source]

update the time lag for the selected variable

set_dynamic(sender)[source]

set dynamic normalization for the selected variable

set_norm(sender)[source]

update the normalization for the selected variable

set_colormap(sender)[source]

update the colormap for the selected variable

handle_click(**kwargs)[source]

callback for handling mouse clicks

add_colorbar(**kwargs)[source]

Creates colorbars on leaflet maps

Parameters:
cmapstr, matplotlib colormap
normobj, matplotlib color normalization object
opacityfloat, opacity of colormap
orientationstr, orientation of colorbar
labelstr, label for colorbar
positionstr, position of colorbar on leaflet map
widthfloat, width of colorbar
heightfloat, height of colorbar
imshow(ax=None, **kwargs)[source]

Save the current map as a static image

Parameters:
ax: obj, default None

Figure axis

kwargs: dict, default {}

Additional keyword arguments for imshow

class IS2view.api.TimeSeries(**kwargs: Any)[source]

A xarray.DataArray extension for extracting and plotting a time series

Parameters:
dsobj

xarray.Dataset

Attributes:
_dsobj

xarray.Dataset

_ds_selectedobj

xarray.Dataset for selected variable

_variablestr

Selected variable

geometrydict

GeoJSON geometry of feature

propertiesdict

GeoJSON properties of feature

crsstr

Coordinate Reference System of feature

_datafloat

Variable value at geometry

_areafloat

Area of geometry (Polygon, MultiPolygon)

_diststr

Eulerian distance from first point (LineString)

_timestr

Time coordinates in decimal-years

_unitsstr

Units of selected variable

_longnamestr

Unit longname of selected variable

_linestr

Matplotlib line object from plot

plot(feature, variable='delta_h', crs='epsg:4326', epoch=2018.0, ax=None, figsize=(6, 4), all_touched=False, conserve=False, **kwargs)[source]

Plot a time series for an extracted geometry

Parameters:
featureobj

GeoJSON feature to extract

variablestr, default ‘delta_h’

xarray variable to plot

crsstr, default ‘epsg:4326’

coordinate reference system of geometry

epochfloat, default 2018.0

Reference epoch for delta times

axobj or NoneType, default None

Figure axis on which to plot

Mutually exclusive with figsize

figsizetuple, default (6,4)

Dimensions of figure to create

all_touchedbool, default False

Include all pixels touched by geometry

conservebool, default False

Conserve total value when averaging over area

kwargsdict, default {}

Keyword arguments for time series plot

extract(feature, variable='delta_h', crs='epsg:4326', epoch=2018.0, fields=[], all_touched=False, conserve=False, **kwargs)[source]

Extract a time series for a geometry

Parameters:
featureobj

GeoJSON feature to extract

variablestr, default ‘delta_h’

xarray variable to extract

crsstr, default ‘epsg:4326’

coordinate reference system of geometry

epochfloat, default 2018.0

Reference epoch for delta times

fieldslist, default []

Additional variables to extract from dataset

all_touchedbool, default False

Include all pixels touched by geometry

conservebool, default False

Conserve total value when averaging over area

get_crs()[source]

Attempt to get the coordinate reference system of the dataset

point(ax, fields=[], **kwargs)[source]

Extracts and plots a time series for a geolocation

Parameters:
axobj or NoneType

Figure axis on which to plot

Will only extract time series if None

legendbool, default False

Add legend

fieldslist, default []

Additional variables to extract from dataset

transect(ax, fields=[], all_touched=False, **kwargs)[source]

Extracts and plots a time series for a transect

Parameters:
axobj or NoneType

Figure axis on which to plot

Will only extract time series if None

cmapstr or NoneType, default None

matplotlib colormap

legendbool, default False

Add legend with time values

fieldslist, default []

Additional variables to extract from dataset

all_touchedbool, default False

Include all pixels touched by geometry

average(ax, fields=[], all_touched=False, conserve=False, **kwargs)[source]

Extracts and plots a time series for a regional average

Parameters:
axobj or NoneType

Figure axis on which to plot

Will only extract time series if None

legendbool, default False

Add legend

fieldslist, default []

Additional variables to extract from dataset

all_touchedbool, default False

Include all pixels touched by geometry

conservebool, default False

Update masks to conserve volume between calls

class IS2view.api.Transect(**kwargs: Any)[source]

A xarray.DataArray extension for extracting a transect

Parameters:
dsobj

xarray.Dataset

Attributes:
_dsobj

xarray.Dataset

_ds_selectedobj

xarray.Dataset for selected variable

_variablestr

Selected variable

geometrydict

GeoJSON geometry of feature

propertiesdict

GeoJSON properties of feature

crsstr

Coordinate Reference System of feature

_datafloat

Variable value at geometry

_diststr

Eulerian distance from first point (LineString)

_unitsstr

Units of selected variable

_longnamestr

Unit longname of selected variable

_linestr

Matplotlib line object from plot

plot(feature, variable='h', lag=0, crs='epsg:4326', ax=None, figsize=(6, 4), all_touched=False, **kwargs)[source]

Creates a plot for a transect

Parameters:
featureobj

GeoJSON feature to extract

variablestr, default ‘h’

xarray variable to plot

lagint, default 0

Time lag to plot if 3-dimensional

crsstr, default ‘epsg:4326’

coordinate reference system of geometry

axobj or NoneType, default None

Figure axis on which to plot

Mutually exclusive with figsize

figsizetuple, default (6,4)

Dimensions of figure to create

all_touchedbool, default False

Include all pixels touched by geometry

kwargsdict, default {}

Keyword arguments for transect plot

extract(feature, variable='h', lag=0, crs='epsg:4326', all_touched=False, **kwargs)[source]

Extract a transect for a geometry

Parameters:
featureobj

GeoJSON feature to extract

variablestr, default ‘h’

xarray variable to extract

lagint, default 0

Time lag to extract if 3-dimensional

crsstr, default ‘epsg:4326’

coordinate reference system of geometry

epochfloat, default 2018.0

Reference epoch for delta times

all_touchedbool, default False

Include all pixels touched by geometry

get_crs()[source]

Attempt to get the coordinate reference system of the dataset

transect(ax, fields=[], all_touched=False, **kwargs)[source]

Extracts and plots a transect

Parameters:
axobj or NoneType

Figure axis on which to plot

Will only extract transect if None

legendbool, default False

Add legend

fieldslist, default []

Additional variables to extract from dataset

all_touchedbool, default False

Include all pixels touched by geometry