### Configure custom basemap Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/Migrate_from_HereMapInspector_to_IpyleafletInspector.ipynb Example of defining and setting a custom basemap using a dictionary configuration. ```python inspector = HEREMapInspector() basemap = { 'name': 'U.S. Geological Survey', 'url': 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x}', 'maxZoom': 20, 'attribution': 'Tiles courtesy of the U.S. Geological Survey' } inspector.set_basemap(basemap) inspector.show() ``` -------------------------------- ### Instantiate IpyleafletInspector Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/Migrate_from_HereMapInspector_to_IpyleafletInspector.ipynb Example of instantiating the inspector and setting basic map properties like basemap, zoom, and center. ```python # Instantiate IpyleafletInspector as if it were a HERE Map Widget for Jupyter based inspector from here.inspector import IpyleafletInspector as HEREMapInspector, __version__ from here.inspector import here_basemaps inspector = HEREMapInspector() inspector.set_basemap(basemap=here_basemaps.exploreDay) inspector.set_zoom(14) inspector.set_center(Point(13.4083, 52.5186)) inspector.show() ``` -------------------------------- ### Add features and styles Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/Migrate_from_HereMapInspector_to_IpyleafletInspector.ipynb Example of adding geometries with specific styles and hover effects, and changing the basemap. ```python inspector = HEREMapInspector() # Add features with HERE Map Widget for Jupyter specific styles inspector.add_features( fra, name="France", style={"fillColor": "rgba(245, 176, 65, 0.5)", "strokeColor": "black"}, hover_style={'fillColor': "rgb(0,255,255,0.5)"} ) inspector.add_features( [pt1, pt2, pt3, ls1, poly2], name="Some geometries", style={'strokeColor': 'magenta', 'fillColor': "rgba(245, 176, 65, 0.5)"}, hover_style={'fillColor': "rgb(255,255,0,0.8)"}, point_style={'radius': 8} ) # Set a different base map the same way as you do on HEREMapInspector inspector.set_basemap(external_basemaps.Esri.WorldImagery) inspector.show() ``` -------------------------------- ### Verify keplergl installation Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Prints version information and file path for the keplergl package. ```python import sys, keplergl from importlib.metadata import packages_distributions print(sys.version) print(packages_distributions().get("keplergl")) print(keplergl.__file__) ``` -------------------------------- ### Use external basemaps Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/Migrate_from_HereMapInspector_to_IpyleafletInspector.ipynb Example of using external basemaps such as OpenStreetMap with the inspector. ```python from here.inspector import external_basemaps inspector = HEREMapInspector() inspector.set_basemap(basemap=external_basemaps.OpenStreetMap.Mapnik) inspector.show() ``` -------------------------------- ### Example of a signed commit message Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/CONTRIBUTING.md This shows the expected format of a commit message after using the sign-off process, including the required Signed-off-by line. ```text README.md: Fix minor spelling mistake Signed-off-by: John Doe ``` -------------------------------- ### Get partition metadata Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Retrieves the metadata for the specified borders layer. ```python # Get the metadata of the sample layer mdata = borders_layer.get_partitions_metadata() ``` -------------------------------- ### Specify a bounding box and get tiles Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Calculate tile IDs within a specified bounding box using the ht.between_points method. ```python tile_ids = list(ht.between_points(Point(13.3, 52.5), Point(13.5, 52.6), level=14, fully_contained=False)) tile_ids[:10] ``` -------------------------------- ### Filter and Create GeoDataFrame Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Filters countries starting with 'po', converts them to Shapely geometries, and initializes a GeoDataFrame. ```python rows = [ { "id": feat["id"], "name": feat["properties"]["name"], "geometry": shape(feat["geometry"]) } for feat in data5["features"] if feat["properties"]["name"].lower().startswith("po") ] gdf1 = gpd.GeoDataFrame.from_records(rows, index="id").set_geometry("geometry") gs1 = gdf1.geometry gdf1 # This is a GeoDataFrame with Poland and Portugal ``` -------------------------------- ### Get and inspect the longest drive Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Identifies the drive with the most GPS points and visualizes the path. ```python msgs_by_count_sorted = dict( sorted(msgs_by_count.items(), key=operator.itemgetter(1),reverse=True)) frq_msg = list(msgs_by_count_sorted.keys())[0] lat_lon_list = list(messageId_lng_lat_dict[frq_msg]) points = [ Point(item.longitude_deg, item.latitude_deg) for item in lat_lon_list ] inspect(points, style=Color.BLUE) ``` -------------------------------- ### Get Features in Bounding Box Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Retrieve features within a specified bounding box and visualize the search area. ```python insp = new_inspector() bbox = (68.1766451354, 7.96553477623, 97.4025614766, 35.4940095078) bbox_features = countries_layer.get_features_in_bounding_box(bbox) insp.add_features(bbox_features, name="Features in bounding box") box_polygon = shapely.geometry.box(*bbox) insp.add_features(box_polygon, name="Search box", style=Color.GRAY) insp.show() ``` -------------------------------- ### Specify a bounding box for the data and get the corresponding tiles Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Calculates the tile IDs for a defined geographic bounding box at a specific zoom level. ```python tile_ids = list(ht.in_bounding_box( west=13.3, south=52.5, east=13.5, north=52.6, level=14, fully_contained=False)) tile_ids[:10] ``` -------------------------------- ### Get functional class attribute with segment reference Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/FunctionalClassCurvatureAnalysis_hmc.ipynb Retrieves functional class attributes for segments using the hmc.topology_attributes.get_referencing method. ```python # get functional_class attributes fc_df_seg = hmc.topology_attributes.get_referencing(tileIds, "functional_class", "segment") fc_df_seg ``` -------------------------------- ### Instantiate and Configure Inspector with Features Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Demonstrates how to initialize an inspector, add multiple feature layers with optional styling and naming, set the zoom level, and render the visualization. ```python # Instantiate the default inspector inspector = new_inspector() # Load some data, each creates a layer inspector.add_features(fra) # unnamed content inspector.add_features(ger, style=Color.YELLOW) # unnamed content with style inspector.add_features(gs2, name="Some mediterranean countries", style=Color.BLUE) # named and styled # Further configuration inspector.set_zoom(4) # Show the inspector once configuration is complete inspector.show() ``` -------------------------------- ### Initialize platform Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Initializes the platform connection. ```python platform = Platform() ``` -------------------------------- ### Import demonstration dependencies Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Import additional packages required for running the demonstration, including data handling and geometry libraries. ```python import json import geopandas as gpd import pandas as pd from shapely.geometry import shape, Point, MultiPoint, LineString, Polygon from here.inspector import external_basemaps from here.platform import Platform from here.geotiles.heretile import in_bounding_box, in_geometry from here.geopandas_adapter import GeoPandasAdapter ``` -------------------------------- ### Import Dependencies and Initialize Platform Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Import necessary libraries and initialize the HERE platform and inspector options with the provided API key. ```python from datetime import datetime, timezone import json import os import shapely.geometry from shapely.geometry import Point from here.platform import Platform from here.inspector import inspect, new_inspector, options from here.inspector.styles import Color options.api_key = api_key ``` -------------------------------- ### Import Required Python SDK libraries Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Initializes the environment by importing necessary modules and setting the API key. ```python from here.platform import Platform from here.geotiles import heretile as ht from here.geopandas_adapter import GeoPandasAdapter from here.geopandas_adapter.utils.dataframe import unpack_columns from here.inspector import inspect, Color, options options.api_key = api_key ``` ```python platform = Platform(adapter=GeoPandasAdapter()) ``` -------------------------------- ### Initialize Inspector Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Open an inspector instance to begin visualizing data. ```python from here.inspector import inspect inspect() ``` -------------------------------- ### Initialize HERE Platform Catalog Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Connects to the HERE platform using a GeoPandas adapter and retrieves the country-borders layer. ```python platform = Platform(adapter=GeoPandasAdapter()) sample_catalog = platform.get_catalog("hrn:here:data::olp-here:here-geojson-samples") borders_layer = sample_catalog.get_layer("country-borders") ``` -------------------------------- ### Instantiate and configure default inspector Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Create a default inspector instance, add features with various styles, and display the map. ```python # Instantiate the default inspector from here.inspector import new_inspector inspector = new_inspector() # Load some data, each creates a layer inspector.add_features(fra) # unnamed content inspector.add_features(ger, style=Color.YELLOW) # unnamed content with style inspector.add_features(gs2, name="Some mediterranean countries", style=Color.BLUE) # named and styled # Further configuration inspector.set_zoom(4) # Show the inspector once configuration is complete inspector.show() ``` -------------------------------- ### List available themes Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Iterates through available themes and prints the current default theme. ```python from here.inspector.styles import Theme for theme in Theme: print(theme) print("Default:", options.default_theme) ``` -------------------------------- ### Basic inspect function call Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Opens the inspector with default settings. ```python inspect() ``` -------------------------------- ### Inspect sample datasets Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Loads GeoJSON files for countries and volcanoes and displays them using the inspector tool. ```python countries_path = "sample_datasets/countries.geo.json" volcanoes_path = "sample_datasets/stanford-gx245jm9245-geojson.json" countries = json.load(open(countries_path)) # print(countries) # print('-------------------------------------------------------------------------') volcanoes = json.load(open(volcanoes_path)) # print(volcanoes) # print('-------------------------------------------------------------------------') insp = new_inspector() insp.add_features(countries, name="Countries", style=Color.BLUE) insp.add_features(volcanoes, name="Volcanoes", style=Color.RED) insp.show() ``` -------------------------------- ### Create platform catalog Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Creates a new catalog on the platform using the generated ID. ```python cat = platform.create_catalog(id=f"{ts}", name="name", summary="summary", description="description", billing_tag="ODIN2823") ``` -------------------------------- ### Import HERE Python SDK libraries Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Import the Platform, inspector, and geotiles modules from the HERE SDK and initialize the API key. ```python from here.platform import Platform from here.inspector import inspect, Color, options import here.geotiles.heretile as ht from shapely.geometry import Point options.api_key = api_key ``` -------------------------------- ### Subscribe to a streaming layer Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Initialize a connection to a specific streaming layer and create a subscription. ```python LAYER_ID = "sample-streaming-layer" layer = catalog.get_layer(LAYER_ID) subscription = layer.subscribe() ``` -------------------------------- ### Print inspector options Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Displays the current configuration options for the inspector. ```python print(options) ``` -------------------------------- ### Import standard Python libraries Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Import matplotlib, numpy, and operator for data manipulation and visualization. ```python import matplotlib.pyplot as plt import numpy as np import operator ``` -------------------------------- ### Initialize HMC object Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/FunctionalClassCurvatureAnalysis_hmc.ipynb Sets up the HMC object using the Platform and GeoPandasAdapter to enable data extraction. ```python from here.platform import Platform from here.content.hmc2.hmc import HMC from here.geopandas_adapter import GeoPandasAdapter import pandas as pd import geopandas as gpd # create HMC object hmc = HMC(Platform(), adapter=GeoPandasAdapter()) ``` -------------------------------- ### Configure a custom base map with IpyleafletInspector Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Initializes the inspector and applies a custom base map configuration using a dictionary containing the name, URL, zoom level, and attribution. ```python inspector = IpyleafletInspector() basemap = { 'name': 'U.S. Geological Survey', 'url': 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x}', 'maxZoom': 20, 'attribution': 'Tiles courtesy of the U.S. Geological Survey' } inspector.set_basemap(basemap) inspector.show() ``` -------------------------------- ### Import HERE Platform Adapters Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Import the Platform and GeoPandasAdapter classes for HERE platform integration. ```python from here.platform import Platform from here.geopandas_adapter import GeoPandasAdapter ``` -------------------------------- ### Add Tiling Grids to Inspector Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Shows how to define tiling grids using bounding boxes or geometries and add them as distinct layers to the inspector interface. ```python # Instantiate a default inspector inspector = new_inspector() # Load some data, each creates a layer inspector.add_features(fra, name="France", style=Color.BLUE) # Define some tiles tiles1 = pd.Series(in_bounding_box(west=-10, south=30, east=5, north=40, level=6)) tiles2 = pd.Series(in_geometry(Point(10, 45).buffer(8), level=8, fully_contained=True)) # Add the two tiling grids inspector.add_tiles(tiles1, name="Tiling grid, level 6", style=Color.GREEN) inspector.add_tiles(tiles2, name="Tiling grid, level 8", style=Color.YELLOW) # Show the inspector once configuration is complete inspector.show() ``` -------------------------------- ### Read HERE Platform Partitions Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Reads specific partitions from the HERE platform layer and returns them as a GeoDataFrame. ```python gdf2 = borders_layer.read_partitions(partition_ids=[1419, 1422]) gs2 = gdf2.geometry gdf2 # This is a GeoDataFrame with some country polygons ``` -------------------------------- ### Import Python dependencies Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Import the necessary libraries for data manipulation and visualization. ```python import matplotlib.pyplot as plt from shapely.geometry import Point import geopandas as gpd ``` -------------------------------- ### Initialize inspector with external base map Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Initializes the IpyleafletInspector with an OpenStreetMap base map. ```python inspector = IpyleafletInspector() inspector.set_basemap(basemap=external_basemaps.OpenStreetMap.Mapnik) inspector.show() ``` -------------------------------- ### Initialize inspector with HERE base map Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Initializes the IpyleafletInspector with a specific HERE satellite base map if an API key is provided. ```python from IPython.display import display if options.api_key: inspector = IpyleafletInspector() inspector.set_basemap(basemap=here_basemaps.satelliteDay) inspector.set_zoom(14) inspector.set_center(Point(13.4083, 52.5186)) display(inspector.show()) ``` -------------------------------- ### Inspect with tiling grid Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Adds a tiling grid to the inspector based on a list of partition IDs. ```python # Selected tiles tiles = [5763, 5766, 5761] inspect(tiles=tiles) ``` -------------------------------- ### Use blank theme Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Configures the inspector to use a blank theme, which excludes the base map. ```python # Instantiate the default inspector inspector = new_inspector() # Load some data, each creates a layer inspector.add_features(fra, "France", Color.BLUE) inspector.add_features(ger, "Germany", Color.RED) inspector.add_features(irl, "Ireland", Color.GREEN) inspector.add_features(gs2, "Country mix", Color.GRAY) # Configure the theme inspector.set_theme(Theme.LIGHT_BLANK) # Show the inspector once configuration is complete inspector.show() ``` -------------------------------- ### Configure inspector options Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Configure the inspector class and API key to ensure the best experience. ```python options.inspector_class = KeplerInspector options.api_key = api_key ``` -------------------------------- ### Use dark theme Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Configures the inspector to use a dark theme for low-light environments. ```python # Instantiate the default inspector inspector = new_inspector() # Load some data, each creates a layer inspector.add_features(fra, "France", Color.BLUE) inspector.add_features(ger, "Germany", Color.RED) inspector.add_features(irl, "Ireland", Color.GREEN) inspector.add_features(gs2, "Country mix", Color.GRAY) # Configure the theme inspector.set_theme(Theme.DARK_MAP) # Show the inspector once configuration is complete inspector.show() ``` -------------------------------- ### Visualize bounding box and tile boundaries Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/FunctionalClassCurvatureAnalysis_hmc.ipynb Constructs a bounding box polygon and uses the inspect function to visualize it alongside tile boundaries on a map. ```python from here.inspector import inspect from here.inspector.styles import Color from shapely.geometry import Polygon # construct a bounding box geojson bb_polygon = Polygon([(west, south), (west, north), (east, north), (east, south), (west, south)]) # create inspect object with tile boundaries and the bounding box inspect(layers={"bounding_box": [bb_polygon]}, tiles=tileIds, center=center, zoom=11, layers_style={"bounding_box": Color.RED}, tiles_style=Color.GRAY) ``` -------------------------------- ### Load GeoJSON and Shapely geometries Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/Migrate_from_HereMapInspector_to_IpyleafletInspector.ipynb Initializes sample GeoJSON features and various Shapely geometry objects (Point, LineString, Polygon) for use in the inspector. ```python # First, load GeoJSON features and shapely geometries: import json from shapely.geometry import shape, Point, MultiPoint, LineString, Polygon with open("sample_datasets/FRA.geo.json") as f: fra = json.load(f)["features"][0] pt1 = Point(30, 50) pt2 = Point(32, 49) pt3 = Point(31, 52) ls1 = LineString([(29, 49), (30, 51), (31, 49), (32, 50), (33, 51)]) ls2 = LineString([(30, 47), (31, 48), (29, 49), (31, 50), (29, 51)]) poly1 = Polygon([(28, 46), (28, 52), (29, 53), (31, 53), (33, 48), (32, 47), (28, 46)]) poly2 = MultiPoint([(40, 51), (43, 49)]).buffer(3) ``` -------------------------------- ### Configure HERE API key Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/Migrate_from_HereMapInspector_to_IpyleafletInspector.ipynb Sets the HERE API key required for using HERE tile providers with the inspector. ```python # Configure your HERE API key # HERE API key is mandatory to use HERE tiles. import os from here.inspector import options options.api_key = os.getenv("LS_API_KEY") or "YOUR-ACTUAL-API-KEY" ``` -------------------------------- ### Visualize sign types with a pie chart Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Generates a pie chart showing the distribution of different sign types. ```python cmap = plt.get_cmap("tab20c") labels_signs = sign_by_type.index pie = plt.pie(sign_by_type['count'], shadow=False, startangle=140, pctdistance=0.85, colors=cmap.colors) plt.legend(pie[0], labels_signs, bbox_to_anchor=(1,0.5), loc="center right", fontsize=12, bbox_transform=plt.gcf().transFigure) plt.tight_layout() ``` -------------------------------- ### Sort partitions by data size Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Sorts the metadata by data size in descending order and selects the top 10 partitions. ```python mdata.sort_values(by="data_size", ascending=False)[:10] ``` -------------------------------- ### Configure Basemap Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Use IpyleafletInspector to set a specific HERE basemap. ```python # With different HERE tiles from here.inspector import here_basemaps, IpyleafletInspector here_inspector = IpyleafletInspector().set_basemap(here_basemaps.topoDay) here_inspector.show() ``` -------------------------------- ### Set HERE API Key Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/FunctionalClassCurvatureAnalysis_hmc.ipynb Configure the environment variable for the HERE API key required for data access. ```python import os os.environ["LS_API_KEY"] = "YOUR HERE API KEY" ``` -------------------------------- ### Visualize GPS points per drive Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Calculates bins and plots a histogram of GPS points recorded per drive. ```python msgs_by_count = messageId_count_dict max_obs = max(messageId_count_dict.values()) bins=list(range(1,max_obs+2, 5)) ``` ```python # Implementation of matplotlib function import matplotlib import numpy as np import matplotlib.pyplot as plt np.random.seed(10**7) mu = 1 sigma = 21 x = messageId_count_dict.values() num_bins = bins n, num_bins, patches = plt.hist(x, bins) y = ((1 / (np.sqrt(2 * np.pi) * sigma)) * np.exp(-1 * (1 / sigma * (num_bins - mu))**2)) plt.plot(bins, y) plt.title('Number of GPS points per message') plt.xlabel('Number of GPS points') plt.ylabel('Number of messages') plt.grid(True) plt.show() ``` -------------------------------- ### Download Countries Data Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Placeholder for downloading the world countries GeoJSON dataset. ```python # Download countries data from this source: # https://github.com/johan/world.geo.json # the file is public domain thus available from the sample_datasets folder ``` -------------------------------- ### List available colors Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Iterates through available colors and prints the current default color names. ```python for color in Color: print(color) print("Default:", [c.name for c in options.default_colors]) ``` -------------------------------- ### Iterate and Inspect All Features Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Convert all features in a layer to a list and inspect them. ```python features = list(countries_layer.iter_features()) inspect(features, name="All the features") ``` -------------------------------- ### Inspect features with tiling grid Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Displays features alongside a tiling grid within a bounding box. ```python # Display features along with the tiles existing inside bounding box features = [ Point(-100, 30).buffer(10), LineString([(-110, 30), (-100, 50)]).buffer(2) ] tiles = pd.Series(in_bounding_box(west=-110, south=35, east=-80, north=50, level=7)) inspect(features, tiles=tiles, tiles_style=Color.ORANGE) ``` -------------------------------- ### Inspect a single GeoSeries Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Visualizes a GeoSeries with a custom name. ```python # Inspect one single GeoSeries inspect(gs2, "An example GeoSeries") # content and name ``` -------------------------------- ### Clean up platform resources Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Removes resources generated by the notebook from the platform. ```python platform.delete_catalog(cat.hrn) ``` -------------------------------- ### Inspect Multiple Features Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Retrieve multiple features by their IDs and inspect them. ```python features = countries_layer.get_features(feature_ids=["IND", "CHN"]) inspect(features, name="Selected features") ``` -------------------------------- ### Display HERE base maps Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Lists the available HERE base maps. ```python here_basemaps ``` -------------------------------- ### Reset default theme Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Resets the default theme to light mode. ```python # This resets the default to `LIGHT_MAP` to not interfere with the cells below options.default_theme = Theme.LIGHT_MAP ``` -------------------------------- ### Import inspector functions Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Import the core inspector functions and support classes from the HERE Data SDK. ```python from here.inspector import inspect, new_inspector, options, KeplerInspector from here.inspector.styles import Color, Theme ``` -------------------------------- ### Inspect with center and zoom Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Opens the inspector centered on specific coordinates with a defined zoom level. ```python # Centered in Buenos Aires inspect(center=Point(-58.381667, -34.603333), zoom=10) ``` -------------------------------- ### Visualize statistics for sign types Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Creates a pie chart representing the distribution of different road sign types. ```python cmap = plt.get_cmap("tab20c") labels_signs = [str(h) for h in roadSignType_count_dict.keys()] pie = plt.pie(roadSignType_count_dict.values(), shadow=False, startangle=140, pctdistance=0.85, colors=cmap.colors) plt.legend(pie[0],labels_signs, bbox_to_anchor=(1,0.5), loc="center right", fontsize=12, bbox_transform=plt.gcf().transFigure) plt.tight_layout() ``` -------------------------------- ### Configure matplotlib plot parameters Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Sets global matplotlib configuration for figure size and label styling. ```python plt.rcParams['figure.figsize'] = (20, 6) plt.rcParams['axes.linewidth'] = 3 plt.rcParams['xtick.labelsize'] = 14 plt.rcParams['ytick.labelsize'] = 14 plt.rcParams['axes.titlesize'] = 20 plt.rcParams['axes.labelsize'] = 18 ``` -------------------------------- ### Read and parse SDII data Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Read partitions for the identified tiles and extract the decoded messages from the resulting blobs. ```python blobs = layer.read_partitions(tile_ids) # We select only the decoded messages, ignoring partition information parsed_blobs = [ blob for _, blob in blobs ] parsed_blobs[:10] ``` -------------------------------- ### Display external base maps Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Lists the available external base maps. ```python external_basemaps ``` -------------------------------- ### Retrieve Partition IDs from Bounding Box Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/FunctionalClassCurvatureAnalysis_hmc.ipynb Calculate tile IDs for a specified geographic bounding box and convert them to partition ID strings. ```python from here.geotiles.heretile import in_bounding_box from shapely.geometry import Point zoom_level = 12 west = 13.41 east = 13.49 south = 52.50 north = 52.54 center = Point(west, south) tileIds = list(in_bounding_box(west=west, south=south, east=east, north=north, level=zoom_level)) # partition ID's: string representation of tile IDs - this will be used for extracting attributes later partition_ids = [str(tile) for tile in tileIds] print("partition ids:", partition_ids) ``` -------------------------------- ### Import Data Processing Libraries Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Import necessary libraries for handling JSON, GeoPandas, and Shapely geometries. ```python import json import geopandas as gpd from shapely.geometry import shape ``` -------------------------------- ### Partition ID Output Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/FunctionalClassCurvatureAnalysis_hmc.ipynb The expected output after running the partition ID retrieval code. ```text Output: partition ids: ['23618402', '23618403'] ``` -------------------------------- ### Configure external base map authentication Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Checks if an external base map requires an authentication token and sets it if necessary. ```python if external_basemaps.MapBox.requires_token(): external_basemaps.MapBox["accessToken"] = "YOUR-PERSONAL-TOKEN" ``` -------------------------------- ### Update catalog with layers Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Updates the catalog configuration to include the defined interactive map layers. ```python platform.update_catalog( hrn=cat.hrn, id=f"c{ts}", name="Countries and volcanoes", summary="A catalog for countries and volcanoes.", description="A catalog for countries and volcanoes.", layers=[countries_layer_details, volcanoes_layer_details], ) ``` -------------------------------- ### Define interactive map layers Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Defines the configuration dictionaries for countries and volcanoes interactive map layers. ```python countries_layer_details = { "id": "countries", "name": "countries", "summary": "Borders of world countries.", "description": "Borders of world countries.", "layerType": "interactivemap", "billingTags": ["ODIN2823"] } ``` ```python volcanoes_layer_details = { "id": "volcanoes", "name": "volcanoes", "summary": "Volcanoes of the world", "description": "Volcanoes of the world", "layerType": "interactivemap", "billingTags": ["ODIN2823"] } ``` -------------------------------- ### Use ipyleaflet-specific styles and basemaps Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Utilize the IpyleafletInspector class to apply custom ipyleaflet styles and set a specific basemap. ```python # This example requires explicit use of the ipyleaflet-based implementation from here.inspector.ipyleaflet import IpyleafletInspector from here.inspector import external_basemaps # Instantiate the ipyleaflet-based inspector inspector = IpyleafletInspector() # Add features with ipyleaflet-specific styles inspector.add_features( fra, name="France", style={'color': 'cyan', 'radius': 8, 'fillColor': '#cc6633', 'opacity': 0.5, 'weight': 5, 'dashArray': '10', 'fillOpacity': 0.4}, hover_style={'fillColor': 'cyan', 'fillOpacity': 0.4} ) inspector.add_features( [pt1, pt2, pt3, ls1, poly2], name="Some geometries", style={'color': 'magenta', 'fillColor': 'white', 'opacity': 0.8, 'weight': 3, 'dashArray': '5', 'fillOpacity': 0.8}, hover_style={'fillColor': 'yellow', 'fillOpacity': 0.4}, point_style={'radius': 10} ) # Set a different base map inspector.set_basemap(external_basemaps.Esri.WorldImagery) # Show the inspector once configuration is complete inspector.show() ``` -------------------------------- ### Search Features by Properties Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Search for features matching specific property values. ```python searched_features = countries_layer.search_features( params={"p.name": ["India", "United States of America", "Australia", "Germany"]} ) inspect(searched_features, name="Searched features") ``` -------------------------------- ### Display number of signs by permanency Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Displays a table showing the count of road sign permanency values. ```python roadSignPermanency = set(roadSignPermanency_arr) fig, ax =plt.subplots(1,1) data=[[list(roadSignPermanency)[0],len(roadSignPermanency_arr)]] column_labels=["roadSignPermanency", "count"] ax.axis('tight') ax.axis('off') ax.table(cellText=data,colLabels=column_labels,loc="center") plt.show() ``` -------------------------------- ### Visualize speed limit signs by value Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Generates a bar chart showing the frequency of different speed limit sign values. ```python plt.bar(range(len(roadSignValue_count_dict)), list(roadSignValue_count_dict.values()), align='center') plt.xticks(range(len(roadSignValue_count_dict)), list(roadSignValue_count_dict.keys())) plt.xlabel('Speed sign value') plt.ylabel('Number of signs') plt.grid(True) plt.show() ``` -------------------------------- ### Calculate drives per archiving tile Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Groups messages by tile ID and visualizes the distribution using a bar chart. ```python def getMsgCountGroupByTileId(blobs): data = dict() for blob in blobs: data[blob.tileId] = len(blob.messages) return data ``` ```python parsed_data = getMsgCountGroupByTileId(parsed_blobs) df = parsed_data plt.bar(range(len(df)), list(df.values()), align='center') plt.xticks(range(len(df)), list(df.keys())) plt.xlabel('Tile ID') plt.ylabel('Number of messages') plt.grid(True) plt.show() ``` -------------------------------- ### Download Volcano Data Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Placeholder for downloading volcano dataset from the National Atlas of the United States. ```python # Download volcanoe data from this source: # volcanoes of the US [geojson]. # National Atlas of the United States # https://earthworks.stanford.edu/catalog/stanford-gx245jm9245 # the file is public domain thus available from the sample_datasets folder ``` -------------------------------- ### Write features to layers Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Retrieves the layers from the catalog and writes the feature data from the source files. ```python # Global GIS: volcanoes of the world; volcano basic data. [Shapefile]. # American Geological Institute. Retrieved from # https://earthworks.stanford.edu/catalog/harvard-glb-volc volcanoes_layer = cat.get_layer("volcanoes") volcanoes_layer.write_features(from_file=volcanoes_path) ``` ```python countries_layer = cat.get_layer("countries") countries_layer.write_features(from_file=countries_path) ``` -------------------------------- ### Specify data catalog and layer Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Defines the catalog HRN and layer ID to retrieve the specific layer from the platform. ```python CATALOG_HRN = 'hrn:here:data::olp-here:olp-sdii-sample-berlin-2' LAYER_ID = 'sample-versioned-layer' catalog = platform.get_catalog(CATALOG_HRN) layer = catalog.get_layer(LAYER_ID) ``` -------------------------------- ### Inspect Single Feature Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Retrieve a single feature by its ID and inspect it. ```python feature = countries_layer.get_feature(feature_id="IND") inspect(feature, name="Selected feature") ``` -------------------------------- ### Display clipped segments and tile boundaries Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/FunctionalClassCurvatureAnalysis_hmc.ipynb Visualizes the clipped road segments and the original tile boundaries using the inspect function. ```python # show the clipped segments and original tile boundaries inspect(features=segment_in_bb["geometry"], tiles=tileIds, tiles_style=Color.GRAY) ``` -------------------------------- ### Analyze GPS points per drive Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Explodes GPS position estimates, unpacks them, and visualizes the distribution of points per message. ```python exploded_gps = parsed_blobs[["messageId", "message.path.positionEstimate"]].explode("message.path.positionEstimate") exploded_gps ``` ```python gps = unpack_columns(exploded_gps, "message.path.positionEstimate", keep_prefix=False) gps ``` ```python grouped_data = gps.groupby('messageId').count() msgs_by_count = grouped_data.rename(columns = {'timeStampUTC_ms': 'count'}) max_obs = msgs_by_count['count'].max() msgs_by_count['count'].hist(bins=list(range(1,max_obs+2, 5))) plt.title('Number of GPS points per message') plt.xlabel('Number of GPS points') plt.ylabel('Number of messages') plt.grid(True) ``` -------------------------------- ### Inspect multiple layers Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Visualizes multiple GeoSeries and GeoDataFrames as independent layers with names. ```python # Inspect multiple GeoSeries and GeoDataFrames, as independent layers inspect(layers={"A": gdf1, "B": gs2}) # content with names, default-styled ``` -------------------------------- ### Visualize segments with color-coded functional classes Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/FunctionalClassCurvatureAnalysis_hmc.ipynb Groups segments by functional class and displays them on a map with distinct layers for each class. ```python fcs = {} for fc, gdf in segment_fc345_df.groupby("attribute.functional_class"): fcs[fc] = gdf["geometry"] inspect(layers=fcs) ``` -------------------------------- ### Fetch RoadSignFields values and occurrences Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Calculates frequency dictionaries for road sign types, values, and message IDs. ```python roadSignType_count_dict= dict(get_freq(roadSignType_arr2)) roadSignType_count_dict = dict(sorted(roadSignType_count_dict.items())) roadSignValue_count_dict = dict(get_freq(roadSignValue_arr)) messageId_arr= dict(get_freq(messageId_arr)) ``` -------------------------------- ### Inspect multiple layers of geometries Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Visualizes multiple layers containing shapely geometries. ```python # Inspect shapely geometries in multiple layer inspect(layers={ "Points and lines A": [pt1, ls1], "Points and lines B": [pt2, pt3, ls2], "Polygons": [poly1, poly2] }) # named, each layer default-styled ``` -------------------------------- ### Read SDII data from a versioned layer Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Reads partitions from a layer and selects specific columns for processing. ```python parsed_blobs = layer.read_partitions(tile_ids, record_path="messages", columns=["messageId", "message.pathEvents.signRecognition", "message.path.positionEstimate"]) parsed_blobs ``` -------------------------------- ### Override default theme Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_ipyleaflet.ipynb Sets the global default theme to dark mode for all subsequent inspector instances. ```python # From this moment on, all the inspector instances use dark theme options.default_theme = Theme.DARK_MAP inspect() ``` -------------------------------- ### Subscribe to and Read SDII Streaming Data Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Connects to a specified streaming layer, reads the stream, and extracts position estimate attributes into a list for visualization. ```python LAYER_ID = 'sample-streaming-layer' layer = catalog.get_layer(LAYER_ID) subscription = layer.subscribe() # get data formatted similar to a partition object parsed_msgs = layer.read_stream(subscription=subscription) parsed_data_list = [ msg.path.positionEstimate for _, msg in parsed_msgs ] result_data = [] for i in range(len(parsed_data_list[0])): result_data.append([]) result_data[i].append(parsed_data_list[0][i].timeStampUTC_ms) result_data[i].append(parsed_data_list[0][i].latitude_deg) result_data[i].append(parsed_data_list[0][i].longitude_deg) result_data[i].append(parsed_data_list[0][i].heading_deg) result_data[i].append(parsed_data_list[0][i].speed_mps) if i == 4: break fig, ax = plt.subplots(1,1) column_labels=["timeStampUTC_ms", "latitude_deg", "longitude_deg", "heading_deg", "speed_mps"] ax.axis('tight') ax.axis('off') ax.table(cellText=result_data,colLabels=column_labels,loc="center") plt.show() ``` -------------------------------- ### Load Global Countries GeoJSON Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Loads a comprehensive GeoJSON file containing country data for the world. ```python with open("sample_datasets/countries.geo.json") as f: data5 = json.load(f) # this is a GeoJSON FeatureCollection with all the countries of the world ``` -------------------------------- ### Visualize speed limit sign distribution Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Filters for speed limit signs and creates a bar chart of their values. ```python sign_count_by_value = signs[signs['roadSignType'] == "SPEED_LIMIT_START"].groupby('roadSignValue').count() sign_count_by_value = sign_count_by_value[["messageId"]].rename(columns = {'messageId': 'count'}) sign_count_by_value['speed'] = sign_count_by_value.index plt.bar(sign_count_by_value['speed'], sign_count_by_value['count']) plt.xlabel('Speed sign value') plt.ylabel('Number of signs') plt.grid(True) ``` -------------------------------- ### Count signs by permanency Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Groups sign data by permanency status and counts occurrences. ```python sign_count_by_permanency = signs.groupby('roadSignPermanency').count() sign_count_by_permanency = sign_count_by_permanency[["messageId"]].rename(columns = {'messageId': 'count'}) sign_count_by_permanency ``` -------------------------------- ### Inspect GeoJSON FeatureCollection Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Visualizes a GeoJSON FeatureCollection with a name and specific color style. ```python # Inspect one single GeoJSON FeatureCollection inspect(data4, "Central EU", Color.BLUE) # content, name and style ``` -------------------------------- ### Show Countries Layer Statistics Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Access the statistics property of the countries layer. ```python countries_layer.statistics ``` -------------------------------- ### Show Volcanoes Layer Statistics Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Access the statistics property of the volcanoes layer. ```python volcanoes_layer.statistics ``` -------------------------------- ### Inspect shapely geometries Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Visualizes a collection of shapely geometries in a single layer. ```python # Inspect more shapely geometries in one layer inspect([pt1, pt2, ls1, poly1]) # unnamed, default-styled ``` -------------------------------- ### Load Ireland GeoJSON Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Loads a GeoJSON FeatureCollection from a local file and extracts the first feature representing Ireland. ```python with open("sample_datasets/IRL.geo.json") as f: data3 = json.load(f) # this is a GeoJSON FeatureCollection with only Ireland irl = data3["features"][0] # this is the GeoJSON Feature of Ireland ``` -------------------------------- ### Visualize GeoDataFrame Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Use the inspect function to visualize the resulting GeoDataFrame. ```python inspect(pos_geo, style=Color.RED) ``` -------------------------------- ### Load Germany GeoJSON Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Loads a GeoJSON FeatureCollection from a local file and extracts the first feature representing Germany. ```python with open("sample_datasets/DEU.geo.json") as f: data1 = json.load(f) # this is a GeoJSON FeatureCollection with only Germany ger = data1["features"][0] # this is the GeoJSON Feature of Germany ``` -------------------------------- ### Inspect results with Kepler.gl Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Visualizes the resulting GeoDataFrame on a map using the inspect function with a specified title and color. ```python # Inspect the result inspect(gdf, "10 largest partitions", Color.PINK) ``` -------------------------------- ### Display Map Result Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/FunctionalClassCurvatureAnalysis_hmc.ipynb Displays the map visualization result. ```text Result: Map(center=[52.5146485, 13.4472655], controls=(LayersControl(options=['collapsed', 'position']), ZoomControl(o… ``` -------------------------------- ### Inspect mixed layer types Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Visualizes multiple layers of different types, including GeoDataFrames, GeoSeries, and shapely geometries, with custom styling for specific layers. ```python # Inspect more than one layer # each layer can be of different type, in this example # GeoDataFrame, GeoSeries, collection of shapely geometric data inspect(layers={ "Example GeoDataFrame": gdf1, "Example GeoSeries": gs2, "Example GeoJSON Feature": irl, "Example GeoJSON FeatureCollection": data4, "Example geometries": [pt1, pt2, ls1, ls2, poly2] }, layers_style={ "Example geometries": Color.GRAY }) # named, each layer default-styled, but geometries ``` -------------------------------- ### Count drives per archiving tile Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Calculates the number of drives associated with each tile based on the partition ID. ```python drives_per_tile = parsed_blobs['partition_id'].value_counts() drives_per_tile ``` -------------------------------- ### Sign a commit using the git -s flag Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/CONTRIBUTING.md Use the -s flag with the git commit command to automatically append your sign-off to the commit message. ```bash git commit -s -m 'README.md: Fix minor spelling mistake' ``` -------------------------------- ### Load France GeoJSON Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Loads a GeoJSON FeatureCollection from a local file and extracts the first feature representing France. ```python with open("sample_datasets/FRA.geo.json") as f: data2 = json.load(f) # this is a GeoJSON FeatureCollection with only France fra = data2["features"][0] # this is the GeoJSON Feature of France ``` -------------------------------- ### Assign data to RoadSignFields Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_platform.ipynb Iterates through parsed blobs to extract message IDs, GPS position estimates, and road sign recognition details. ```python roadSignType_arr2= [] roadSignPermanency_arr= [] roadSignValue_arr= [] messageId_arr= [] messageId_count_arr= [] messageId_count_dict= {} messageId_lng_lat_dict= {} for blob in parsed_blobs: for item in getattr(blob, 'messages'): messageId_arr.append(item.messageId) messageId_count_arr = list(item.message.path.positionEstimate) messageId_count_dict[item.messageId] = len(messageId_count_arr) messageId_lng_lat_dict[item.messageId] = messageId_count_arr for item2 in item.message.pathEvents.signRecognition: roadSignType_arr2.append(item2.roadSignType) roadSignPermanency_arr.append(item2.roadSignPermanency) if item2.HasField('roadSignValue'): roadSignValue_arr.append(item2.roadSignValue) ``` -------------------------------- ### Access backend for map inspectors Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/Migrate_from_HereMapInspector_to_IpyleafletInspector.ipynb Retrieves the backend type for IpyleafletInspector and the deprecated HEREMapInspector, provided the version is older than 2.30.0. ```python if __version__ >= '2.30.0' or not HEREMapInspector_is_defined: print("HEREMapInspector has been removed.") else: from here.inspector import HEREMapInspector as HEREMapInspectorDeprecated from here.inspector import IpyleafletInspector ipyleaflet_inspector = IpyleafletInspector() depecrated_heremap_inspector = HEREMapInspectorDeprecated() (type(ipyleaflet_inspector.backend()), type(depecrated_heremap_inspector.backend()) ) ``` -------------------------------- ### Explode and unpack sign recognition data Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Explodes the sign recognition list into rows and unpacks the resulting dictionaries into independent columns. ```python exploded_signs = parsed_blobs[["messageId", "message.pathEvents.signRecognition"]].explode("message.pathEvents.signRecognition") exploded_signs ``` ```python signs = unpack_columns(exploded_signs, "message.pathEvents.signRecognition", keep_prefix=False) signs ``` ```python sign_by_type = signs.groupby('roadSignType').count() sign_by_type = sign_by_type[["messageId"]].rename(columns={'messageId':'count'}) sign_by_type.head() ``` -------------------------------- ### Create Combined GeoJSON FeatureCollection Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Constructs a new GeoJSON FeatureCollection containing the previously extracted Germany and France features. ```python # This is a GeoJSON FeatureCollection with Germany and France data4 = { "type": "FeatureCollection", "features": [ger, fra] } ``` -------------------------------- ### Inspect a single GeoDataFrame Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Visualizes the content of a single GeoDataFrame. ```python # Inspect one single GeoDataFrame inspect(gdf1) # just the content ``` -------------------------------- ### Generate catalog ID Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/InteractiveMapLayersIntro.ipynb Creates a timestamp-based ID for the catalog. ```python # create a timestamp/hash-like ID for the catalog ID ts = datetime.now(timezone.utc).isoformat()[:19] ts = ts.replace("-", "").replace(":", "").replace("T", "").lower() print(ts) ``` -------------------------------- ### Inspect GeoJSON Feature Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ExploreInspector_kepler.ipynb Visualizes a single GeoJSON Feature with a specific color style. ```python # Inspect one single GeoJSON Feature inspect(fra, style=Color.RED) # unnamed, just style ``` -------------------------------- ### Replace import statement Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/Migrate_from_HereMapInspector_to_IpyleafletInspector.ipynb Update the import statement to use IpyleafletInspector as the HEREMapInspector class. ```python from here.inspector import HEREMapInspector ``` ```python from here.inspector import IpyleafletInspector as HEREMapInspector ``` -------------------------------- ### Visualize segments with FC 3, 4, or 5 Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/FunctionalClassCurvatureAnalysis_hmc.ipynb Uses the inspect function to display road segments with functional classes 3, 4, or 5 on a map. ```python inspect(segment_fc345_df["geometry"]) ``` -------------------------------- ### Convert DataFrame to GeoDataFrame Source: https://github.com/heremaps/here-data-sdk-examples-python/blob/main/tutorials/ProcessSDIIData_geopandas.ipynb Creates a GeoDataFrame using longitude and latitude columns to enable spatial operations. ```python gps_geo = gpd.GeoDataFrame(gps, geometry=gpd.points_from_xy(gps["longitude_deg"], gps["latitude_deg"])) gps_geo = gps_geo[["messageId", "geometry"]] gps_geo ```