API

Geoplot

centred_map(feature_collection[, …]) Create a folium map centred on a GeoJSON FeatureCollection.
single_colour(folium_map, …[, …]) Plot GeoJSON features on a folium map.
choropleth(folium_map, feature_collection, …) Plot a choropleth on a folium map.
sherlockml_extras.geoplot.centred_map(feature_collection, feature_selection=None, feature_index_property='id', ignore_missing_features=False, **kwargs)

Create a folium map centred on a GeoJSON FeatureCollection.

Parameters:
feature_collection : dict

A GeoJSON FeatureCollection

feature_selection : array-like, optional

A set of keys to select a slice from feature_collection (default: use whole feature_collection)

feature_index_property : str, optional

The property of features in feature_collection to use when extracting a selection (default: ‘id’)

ignore_missing_features : bool, optional

When True, quitely ignore features in feature_selection missing from feature_collection (default: False)

**kwargs

Additional keyword arguments to pass to folium.Map

Returns:
folium.Map

A map centred on feature_collection

sherlockml_extras.geoplot.single_colour(folium_map, feature_collection, fill_colour, feature_selection=None, feature_index_property='id', ignore_missing_features=False, **kwargs)

Plot GeoJSON features on a folium map.

Parameters:
folium_map : folium.Map

The folium map to plot on

feature_collection : dict

A GeoJSON FeatureCollection

fill_colour : str

A colour name or hex code

feature_selection : array-like, optional

A selection to slice the feature collection with

feature_index_property : str, optional

The property of features in feature_collection to use when extracting a selection (default: ‘id’)

ignore_missing_features : bool, optional

When True, quitely ignore features in feature_selection missing from feature_collection (default: False)

**kwargs

Additional keyword arguments to pass to the folium choropleth method

sherlockml_extras.geoplot.choropleth(folium_map, feature_collection, feature_index, feature_data, feature_index_property='id', bins=5, colourmap='viridis', ignore_missing_features=False, **kwargs)

Plot a choropleth on a folium map.

Parameters:
folium_map : folium.Map

The folium map object to plot on

feature_collection : dict

A GeoJSON FeatureCollection

feature_index : array-like

A sequence of feature identifiers corresponding to the feature_data column

feature_data : array-like

Scalar values to plot on the map for each feature in feature_index

feature_index_property : str, optional

The property of features in feature_collection containing the feature_index (default: ‘id’)

bins : int or array-like, optional

The number of bins, or, the edges of the bins (default: 5)

colourmap : str, optional

The matplotlib colourmap to use (http://matplotlib.org/users/colormaps.html, default: ‘viridis’)

ignore_missing_features : bool, optional

When True, quitely ignore features missing from feature_collection (default: False)

ignore_missing_features : bool, optional

When True, quitely ignore features in feature_index missing from feature_collection (default: False)

**kwargs

Additional keyword arguments to pass to the folium choropleth method

Geojson

slice(feature_collection, feature_selection, …) Extract a slice from a GeoJSON FeatureCollection.
centre(geojson_object) Calculate the centre of a GeoJSON object.
bounding_box(geojson_object) Calculate the bounding box of a GeoJSON object.
sherlockml_extras.geoplot.geojson.slice(feature_collection, feature_selection, feature_index_property, ignore_missing_features=False)

Extract a slice from a GeoJSON FeatureCollection.

Parameters:
feature_collection : dict

A GeoJSON FeatureCollection

feature_selection : array-like, optional

A set of keys to select a slice from feature_collection (default: use whole feature_collection)

feature_index_property : str, optional

The property of features in feature_collection to use when extracting a selection (default: ‘id’)

ignore_missing_features : bool, optional

When True, quitely ignore features in feature_selection missing from feature_collection (default: False)

sherlockml_extras.geoplot.geojson.centre(geojson_object)

Calculate the centre of a GeoJSON object.

The midpoint of the bounding box is evaluated, not the centroid.

Parameters:
geojson_object : dict

The GeoJSON object to calculate the centre of

Returns:
float

The longitude of the centre

float

The latitude of the centre

sherlockml_extras.geoplot.geojson.bounding_box(geojson_object)

Calculate the bounding box of a GeoJSON object.

Parameters:
geojson_object : dict

The GeoJSON object to calculate the bounding box of

Returns:
numpy.ndarray

[min_longitude, min_latitude, max_longitude, max_latitude]