4.5.10 Visualize Data in a Map

The map visualization of OML Notebooks plots data points on a geographical map. For visualizing your data in a map in OML Notebooks, your data must contain explicit latitude and longitude values of locations to correctly position data on the map.

When to use this chart: Use map charts to visualize your data with geographical implications
Data set: In this example, we create a table containing data about countries and related information with geographical coordinates.
To visualize data in a map:
  1. In a Python paragraph in a notebook, run the following statements to create a table with five columns—Country Name, Longitude, Latitude, Capital, and Population, and five entries for each:
    %python
    print('Country Name\tLongitude\tLatitude\tCapital\tPopulation')
    print('Morocco\t34.0218454\t-6.8408929\tRabat\t257000')
    print('USA\t38.89\t-77.036\tWashington\t67900000')
    print('India\t28.7041\t77.1025\tDelhi\t3380000')
    print('Australia\t-36.2048\t138.2529\tCanberra\t45700000')
    print('Japan\t35.6768601\t139.7638947\tTokyo\t3700000')
    A table is created with these columns—Country Name, Country Name, Longitude, Latitude, Capital, and Population.

  2. Click on the map icon.
    The data is displayed on a world map in OSM Positron style. This is a non-obtrusive light vector tile basemap based on OpenStreetMap (OSM) data. This is the default style.
  3. Under Settings, on the Setup tab, you can adjust the height of the map. You can also show and hide the zoom controls by clicking Show Zoom Control.
  4. Under Settings, in the Customizations tab, you can edit the following settings. Click on the arrow to change any entries for these columns.
    • Latitude column—Select the column from the dataset which can be considered as latitude value. The column must contain numeric values (float or integer) with valid geographic coordinates. Latitude values must be between -90 and 90.
    • Longitude column—Select the column from the dataset which can be considered as longitude value. The column must contain numeric values (float or integer) with valid geographic coordinates. Longitude values must be between -180 and 180.
    • Title Columns—Select one or more columns from the dataset to be displayed as a tooltip label and marker. If you select two columns, it will be concatenated with a dash and displayed in the marker dialog that opens when you click on any pushpin on the map.
    • Description Columns—Select one or more columns from the dataset to be displayed in the marker dialog that opens when you click on any pushpin on the map.
    As shown in the Map Settings screenshot above, the Title Columns have Country Name and Capital selected, and the Description Columns have Capital selected. On clicking the pushpin for USA on the map, the marker dialog displays USA - Washington and Capital: Washington displayed based on the selections in Settings—Customization.

    Figure 4-38 Map with the marker dialog



    • Map Type—By default, the OSM Positron type is selected. This is a map style built using the OpenStreetMap (OSM) data. The other map types you can choose are:
      • OSM Bright—This is a general purpose vector tile basemap based on OpenStreetMap (OSM) data. Use this basemap style to view detailed location context for your data.
      • OSM Dark Matter—This is a non-obtrusive dark vector tile basemap based on OpenStreetMap (OSM) data. Use this basemap style to accentuate visualizations of your data.
      • World Map—This is a 2D physical map, a type of map where the geographical information is displayed in color. Use this map style to visualize the geography of a region in terms of elevation, landforms and other geospatial information.
      • Customize Type—Here, you have the option to change the map source and map style.
This completes the task of visualizing data in a map.