# How to visualize data ## HERE Inspector You can visualize data in Jupyter notebooks using the HERE Inspector package. The inspector allows you to visualize data from various sources, including the HERE platform. It provides an interface designed to support multiple backends. Currently, supported backends are: * [ipyleaflet](https://ipyleaflet.readthedocs.io/en/latest/) * [Kepler Widget](https://docs.kepler.gl/docs/keplergl-jupyter) Note: The map widget used in this visualization is the default widget provided by the HERE map service. In order to use the widget, please ensure that you have set the environment variable "LS\_API\_KEY" with your HERE API key. Additionally, please note that custom styling options such as zoom, center, basemap, theme, and colors are not currently supported by the Kepler.gl library. Capabilities include: * Display interactive maps * Set basemap * Add layers * Center and zoom * Display interactive charts * Simple programmatic interface * Support for displaying heatmaps, choropleths, markers, clustering, and styling * UI controls for interactive applications Data formats supported: * [GeoJSON](https://geojson.org/) Features and FeatureCollections * [GeoPandas](https://geopandas.org/en/stable/docs.html) GeoSeries * [GeoPandas](https://geopandas.org/en/stable/docs.html) GeoDataFrame * [Shapely](https://shapely.readthedocs.io/en/latest/) BaseGeometry objects ### Basic visualization The simplest usage of Inspector is to call its `inspect` function for immediate one-line visualization of georeferenced data within a Jupyter notebook. #### Inspect single dataset Note: To use a specific map widget, you will need to specify the appropriate `inspector_class` and `api_key` options. For example, to use the Ipyleaflet map widget, you would set `options.inspector_class = IpyleafletInspector` and `options.api_key = None`. Similarly, to use the Kepler.gl map widgets, you would set `options.inspector_class = KeplerInspector` and set api\_key as per the requirement of widgets. ##### Ipyleaflet widget ```python import json from here.inspector import inspect # Dataset type = GeoJSON file # This file contains polygon features describing neighborhood boundaries in Chicago with open('sample_datasets/neighborhood_boundaries.geojson') as f: area_boundaries = json.load(f) from here.inspector import options,IpyleafletInspector options.inspector_class = IpyleafletInspector options.api_key = None inspect(area_boundaries) ``` ![Ipyleaflet Widget](https://files.readme.io/eabb76e16233a90eaac0ce9949c88f83e08f7e634c31976e604f17dffd9b0a20-chi1.png "Ipyleaflet Widget") ##### Kepler widget ```python import json from here.inspector import inspect # Dataset type = GeoJSON file # This file contains polygon features describing neighborhood boundaries in Chicago with open('sample_datasets/neighborhood_boundaries.geojson') as f: area_boundaries = json.load(f) from here.inspector import options,KeplerInspector options.inspector_class = KeplerInspector options.api_key = None inspect(area_boundaries) ``` ![Kepler Widget](https://files.readme.io/309b56f20ef8aa4b6ed91543ef20e6de2ee3443c8fed94739feeb167509251ab-kepler1.png "Kepler Widget") #### Inspect multiple datasets ```python import geopandas as gpd # Dataset type = GeoDataFrame # This dataframe contains all Chicago Transit Authority rail station entrance locations cta_df = gpd.read_file('sample_datasets/cta_entrances.geojson') cta_df.head() ``` | | name | agency | line | geometry | | -: | :------------ | :----- | :--------------------------------------- | :--------------------------- | | 0 | 18th | CTA | Pink Line | POINT (-87.669144 41.857849) | | 1 | 35th/Archer | CTA | Orange Line | POINT (-87.680632 41.829274) | | 2 | 95th-Dan Ryan | CTA | Red Line | POINT (-87.62441 41.722729) | | 3 | Adams/Wabash | CTA | Brown, Purple, Orange, Pink, Green Lines | POINT (-87.625997 41.879715) | | 4 | Addison | CTA | Blue Line | POINT (-87.718406 41.946604) | ##### Ipyleaflet widget ```python from here.inspector import options,IpyleafletInspector options.inspector_class = IpyleafletInspector options.api_key = None inspect(layers={'Neighborhoods': area_boundaries, 'Stations': cta_df}) ``` ![Ipyleaflet Map Widget](https://files.readme.io/82c90288d5b1b7082ab85c8d5aa5c2c592c88fc6c87d09115d7dd9965ef224b3-chi2.png "Ipyleaflet Map Widget") ##### Kepler widget ```python from here.inspector import options,KeplerInspector options.inspector_class = KeplerInspector options.api_key = None inspect(layers={'Neighborhoods': area_boundaries, 'Stations': cta_df}) ``` ![Kepler Map Widget](https://files.readme.io/466d344d69e926a6476f290788662cbf3f7c57d733f10cf7b86c359dace1df5c-kepler2.png "Kepler Map Widget") Custom styles can be specified by passing the additional `layers_style` parameter or by simply passing tuples. Note:- Custom styling feature is available only for HERE Map and Ipyleaflet widget. ```python from here.inspector import Color inspect(layers=[ ('Neighborhoods', area_boundaries, Color.AQUA), ('Stations', cta_df, Color.RED) ]) ``` ### Advanced styling The `Inspect` interface provides basic configuration options including: * Setting map [theme](https://developer.here.com/documentation/sdk-python-v2/api_reference/here.inspector.styles.html#here.inspector.styles.Theme) * Choosing a [basemap](https://developer.here.com/documentation/sdk-python-v2/api_reference/here.inspector.styles.html#here.inspector.base.Inspector.set_basemap) * Setting display [center point and zoom level](https://developer.here.com/documentation/sdk-python-v2/api_reference/here.inspector.base.html) * Custom [colors](https://developer.here.com/documentation/sdk-python-v2/api_reference/here.inspector.base.html#here.inspector.base.Inspector.set_colors) Advanced styling capabilities are available for supported rendering backends ([ipyleaflet](https://ipyleaflet.readthedocs.io/en/latest/) and [Kepler Widget](https://docs.kepler.gl/docs/keplergl-jupyter)). The `Inspector.backend` function provides access to all advanced functionalities of the rendering backend, allowing unlimited customization. Please see the [Tutorial Notebooks](https://docs.here.com/data-sdk/docs/notebooks) named `ExploreInspector_ipyleaflet.ipynb` and `ExploreInspector_kepler.ipynb` for comprehensive examples of all visualization options.