Edit

Real-Time Intelligence tutorial part 8: Create a map using geospatial data

Note

This tutorial is part of a series. For the previous section, see: Tutorial part 7: Detect anomalies on an Eventhouse table.

In this part of the tutorial, you learn how to create a map using geospatial data.

Create a function in KQL database

In this step, you create a function in the KQL database that points to the geospatial data in the Eventhouse table. This function allows you to easily query the geospatial data and use it in the map.

  1. Open the Tutorial eventhouse that you created in the previous part of the tutorial.

  2. Select the Tutorial_queryset.

  3. Select the + button on the ribbon to create a new tab.

  4. Select the pencil icon on the tab and rename the query tab Show on map.

  5. Copy/paste and run the following query.

    .create-or-alter function funcForMap() {
        TransformedData
        | where ingestion_time() > ago(30d)
        | project Street, Neighbourhood, toreal(Latitude), toreal(Longitude), No_Bikes, No_Empty_Docks
        | summarize sum(No_Bikes), sum(No_Empty_Docks) by Street, Neighbourhood, Latitude, Longitude
    }
    

    Screenshot of kql query for map.

Create a Lakehouse and upload GeoJson files

  1. Browse to your workspace and in upper left corner select the + New item button. Then search for and select Lakehouse.

    Screenshot of lakehouse creation.

  2. Enter TutorialLakehouse as name.

  3. Select the workspace in which you created your resources.

  4. Right-click the File node and under Upload, and select Upload files.

  5. Download the following two GeoJSON files from the following links and upload them to the Lakehouse.

    Screenshot of files upload to lakehouse.

Create a map

  1. Browse to your workspace and in upper left corner select the + New item button. Then search for and select Map.

    Screenshot of map item creation.

  2. Enter TutorialMap in Name, and select Create

Add Eventhouse data to the map

  1. In the Explorer pane, select + Add, and select KQL Database.

  2. Choose the Tutorial eventhouse.

  3. Select Connect.

  4. Under Tutorial, expand Functions and select the funcForMap function.

  5. Select the more menu (...) next to funcForMap and select Show on map.

    Screenshot of eventhouse queryset tab selection.

  6. A new window showing data preview of the query opens. Select Next .

    Screenshot of Preview tab page of the wizard.

  7. On the Set geometry and data refresh interval page of the wizard, follow these steps:

    1. Enter BikeLatLong as Name.
    2. For Geometry column location, select Latitude and longitude in separate columns.
    3. For Latitude column, select Latitude.
    4. For Longitude column, select Longitude.
    5. Under Data refresh interval select 5 minutes. Select Next.

    Screenshot of map latitude and longitude selection.

  8. On the Review and add page of the wizard, select Add to map.

    Screenshot of Review and Add to Map page of the wizard.

  9. Hover the mouse over BikeLatLong in the Data layers section, select ..., and then select Zoom to fit to zoom into a London area showing bike stations on the map.

    Screenshot of map zoomed into London area.

  10. Select BikeLatLong under Data layers, and follow these steps:

    1. Expand General settings, and add Street and Neighborhood under for Tooltips.

    2. Select Enable data-driven styling.

    3. Change Size to By data and select sum_No_Empty_Docks.

      This setting should immediately take effect on the map with bubble sizes representing the number of empty docks and colors representing different neighborhoods.

      Screenshot of bubble map.

Add GeoJSON files from Lakehouse to the map

  1. In the Explorer pane, select + Add, and select Lakehouse.

  2. Choose the TutorialLakehouse lakehouse and select Connect.

  3. Expand TutorialLakehouse, expand Files, and then select the london-boroughs.geojson file and right-click on the file and select Show on map. Repeat the step for buckingham-palace-road.json file.

    Screenshot of geojson selection.

  4. The borough boundaries and Buckingham Palace road appear on the map. You can toggle visibility of each layer by selecting the eye icon next to each layer under Data layers.

    Screenshot of three data layers in map.

  5. In the Data layers section, hover the mouse over buckingham-palace-road, select ..., and select Zoom to fit to zoom into Buckingham Palace road area on the map.

    Screenshot of three data layers.

  6. From the menu bar, select the Save icon.

For more information about tasks performed in this tutorial, see:

Next step