veroviz.createLeaflet module

addLeafletCircle(mapObject=None, mapFilename=None, mapBackground='CartoDB positron', mapBoundary=None, zoomStart=None, center=None, radius=None, text=None, fontSize=24, fontColor='orange', popupText=None, lineWeight=3, lineColor=None, lineOpacity=0.8, lineStyle='solid', fillColor='red', fillOpacity=0.3)[source]

Add a circle, with a radius specified in [meters], to a Leaflet map.

Note

This function differs from addLeafletMarker, in which the circle’s radius is specified in [pixels].

Parameters
  • mapObject (Folium object, Optional, default None) – A Folium map object. If provided, the circle will be added to an existing map. Otherwise, a new map will be created.

  • mapFilename (string, Optional, default as None) – This is the name of the map file that will be created (e.g., “../output/map.html” or “map.html”). The filename should have a .html extension. If mapFilename is not provided, no map file will be generated. The returned map object can be viewed within a Jupyter notebook.

  • mapBackground (string, Optional, default as 'CartoDB positron') – Sets the background tiles of the map. See Leaflet Style for the list of options.

  • mapBoundary (list of lists, Optional, default as None) – Allows customization of the zoom level. If a map boundary is provided, the zoom level will correspond to the rectangle defined by the two map boundary points. This feature is useful if you want to create multiple comparison maps, each with the same zoom level and centering. Must be in the form [[south lat, west lon], [north lat, east lon]].

  • zoomStart (int, Optional, default as None) – Specifies the default zoom level. 1 –> global view; 18 –> max zoom. Note that some map tiles have maximum zoom levels less than 18. The zoomStart will be overridden by a mapBoundary (if one is provided).

  • center (list, Required, default None) – Specifies the center point of the circle. Must be a list of the form [lat, lon] or [lat, lon, alt]. If provided, the altitude component will be ignored (as all locations on Leaflet maps are assumed to be at ground level).

  • radius (float, Required, default None) – The radius of the circle, in units of [meters].

  • text (string, Optional, default None) – Specifies the text to be displayed on the map, centered as the center location.

  • fontSize (float, Optional, default 24) – The size of the font, in units of [points]. The default is 24-point font.

  • fontColor (string, Optional, default 'orange') – The color of the text string. fontColor may be one of Leaflet’s pre-specified colors (see Leaflet Style), or it may be a hex value, such as #ff0000 (see https://www.w3schools.com/colors/colors_picker.asp).

  • popupText (string, Optional, default as None) – The circle will include this text as a popup label (you will need to click on the circle in the map to see this label).

  • lineWeight (int, Optional, default 3) – The width of the circle’s outline, in units of [pixels]. This value is ignored if lineColor = None.

  • lineColor (string, Optional, default None) – The color of the circle’s outline. lineColor may be one of Leaflet’s pre-specified colors (see Leaflet Style), or it may be a hex value, such as #ff0000 (see https://www.w3schools.com/colors/colors_picker.asp). No line will be drawn if lineColor = None.

  • lineOpacity (float in [0, 1], Optional, default 0.8) – Specifies the opacity of the circle’s outline. Valid values are in the range from 0 (invisible) to 1 (no transparency).

  • lineStyle (string, Optional, default 'solid') – The style of the circle’s outline. See Leaflet Style for a list of valid options.

  • fillColor (string, Optional, default 'red') – The color of the interior of the circle. fillColor may be one of Leaflet’s pre-specified colors (see Leaflet Style), or it may be a hex value, such as #ff0000 (see https://www.w3schools.com/colors/colors_picker.asp). The circle will not be filled if fillColor = None.

  • fillOpacity (float in [0, 1], Optional, default 0.3) – Specifies the opacity of the circle’s interior. Valid values are in the range from 0 (invisible) to 1 (no transparency).

Returns

A Folium map object containing a circle (and pre-existing items previously specified in mapObject).

Return type

Folium object

Example

>>> # Draw a circle of radius 10 meters, centered on the Univ. at Buffalo campus.
>>> # Save this as "a_circle.html".
>>> import veroviz as vrv
>>> myMap = vrv.addLeafletCircle(
...     zoomStart=18,
...     center=[43.00154, -78.7871],
...     radius=100,
...     mapFilename="a_circle.html")
>>> myMap
>>> # Draw a circle of radius 2000 meters, centered on the Univ. at Buffalo campus.
>>> # This example includes all of the available function arguments.
>>> import veroviz as vrv
>>> myMap = vrv.addLeafletCircle(
...     mapObject = None,
...     mapFilename = None,
...     mapBackground = 'OpenStreetMap',
...     mapBoundary = None,
...     zoomStart = 13,
...     center = [43.00154, -78.7871],
...     radius = 2000,
...     text = 'UB',
...     fontSize = 24,
...     fontColor = 'black',
...     popupText = 'Univ. at Buffalo',
...     lineWeight = 6,
...     lineColor = '#ff66ff',
...     lineOpacity = 0.7,
...     lineStyle = 'dotted',
...     fillColor = 'green',
...     fillOpacity = 0.4)
>>> myMap
addLeafletIcon(mapObject=None, mapFilename=None, mapBackground='CartoDB positron', mapBoundary=None, zoomStart=None, location=None, iconPrefix='glyphicon', iconType='info-sign', iconColor='blue', iconText=None, popupText=None)[source]

Add a single icon/pin to a Leaflet map.

Parameters
  • mapObject (Folium object, Optional, default None) – A Folium map object. If provided, the marker will be added to an existing map. Otherwise, a new map will be created.

  • mapFilename (string, Optional, default None) – If provided, the map will be saved to this file, which should have a .html extension. mapFilename can contain a filepath. If mapFilename is not provided, no file will be generated. The returned mapObject can be viewed within a Jupyter notebook.

  • mapBackground (string, Optional, default 'CartoDB positron') – The tiles of the map, default to be ‘CartoDB positron’, for options, see Leaflet Style, also see folium documentation (https://python-visualization.github.io/folium/modules.html) for more options

  • mapBoundary (list of lists, Optional, default None) – If provided, the mapBoundary coordinates are used to determine a zoom level such that these coordinates are contained within view when the map is opened. This feature is useful if you want to create multiple comparison maps, each with the same zoom level and centering. mapBoundary must be in the form [[south lat, west lon], [north lat, east lon]].

  • zoomStart (int, Optional, default as None) – Specifies the default zoom level. 1 –> global view; 18 –> max zoom. Note that some map tiles have maximum zoom levels less than 18. The zoomStart will be overridden by a mapBoundary (if one is provided).

  • location (list, Required, default as None) – Specifies the GPS coordinates of the icon/pin. Must be a list of the form [lat, lon] or [lat, lon, alt]. If provided, the altitude component will be ignored (as all locations on Leaflet maps are assumed to be at ground level).

  • iconPrefix (string, Optional, default as "glyphicon") – There are a large number of Leaflet icons available. The iconPrefix identifies one of three collections: “glyphicon”, “fa”, or “custom”. See Leaflet Style for more information.

  • iconType (string, Optional, default as "info-sign") – Specifies the particular icon to be used for the icon/pin. The list of available options depends on the choice of iconPrefix. See Leaflet Style for available options.

  • iconColor (string, Optional, default as "blue") – Defines the color of the icon/pin. See Leaflet Style for the list of available color options.

  • iconText (string, Optional, default as None) – Text that will be displayed within the node on a Leaflet map. This text will only be shown if iconPrefix is ‘custom’ and iconType includes a font color and font size. See Leaflet Style.

  • popupText (string, Optional, default as None) – The icon/pin will include this text as a popup label (you will need to click on the pin in the map to see this label).

Returns

A Folium map object containing an icon/pin (and pre-existing items previously specified in mapObject).

Return type

Folium object

Example

Import veroviz and check if the version is up-to-date:
>>> import veroviz as vrv
>>> vrv.checkVersion()
Define a location:
>>> whiteHouse = [38.8977, -77.0365]
A minimal example, using mostly default parameters:
>>> vrv.addLeafletIcon(location = whiteHouse)
An example showing all function parameters:
>>> vrv.addLeafletIcon(mapObject     = None,
...                    mapFilename   = None,
...                    mapBackground = 'arcgis aerial',
...                    mapBoundary   = None,
...                    zoomStart     = None,
...                    location      = whiteHouse,
...                    iconPrefix    = 'custom',
...                    iconType      = '18-yellow-12',
...                    iconColor     = 'purple',
...                    iconText      = 'WH',
...                    popupText     = '<nobr>click icon to see this single-line text</nobr>')
addLeafletIsochrones(mapObject=None, mapFilename=None, mapBackground='CartoDB positron', mapBoundary=None, zoomStart=None, iso=None, showBoundingRegion=False, iconPrefix='glyphicon', iconType='info-sign', iconColor='blue', iconText=None, popupText=None, lineWeight=3, lineOpacity=0.8, lineStyle='solid', fillOpacity=0.3)[source]

Easily draw isochrones on a Leaflet map. Be sure to run the isochrones() function first.

Parameters
  • mapObject (Folium object, Optional, default None) – A Folium map object. If provided, the marker will be added to an existing map. Otherwise, a new map will be created.

  • mapFilename (string, Optional, default None) – If provided, the map will be saved to this file, which should have a .html extension. mapFilename can contain a filepath. If mapFilename is not provided, no file will be generated. The returned mapObject can be viewed within a Jupyter notebook.

  • mapBackground (string, Optional, default 'CartoDB positron') – The tiles of the map, default to be ‘CartoDB positron’, for options, see Leaflet Style, also see folium documentation (https://python-visualization.github.io/folium/modules.html) for more options

  • mapBoundary (list of lists, Optional, default None) – If provided, the mapBoundary coordinates are used to determine a zoom level such that these coordinates are contained within view when the map is opened. This feature is useful if you want to create multiple comparison maps, each with the same zoom level and centering. mapBoundary must be in the form [[south lat, west lon], [north lat, east lon]].

  • zoomStart (int, Optional, default as None) – Specifies the default zoom level. 1 –> global view; 18 –> max zoom. Note that some map tiles have maximum zoom levels less than 18. The zoomStart will be overridden by a mapBoundary (if one is provided).

  • iso (isochrone object, Required, default as None) – See the isochrones() function for details on how to create this object.

  • showBoundingRegion (boolean, Optional, default as False) – The isochrone object contains a bounding region, which is the smallest rectangle enclosing the isochrones. If you wish to include this rectangle on the map, set showBoundingRegion=True.

  • iconPrefix (string, Optional, default as "glyphicon") – There are a large number of Leaflet icons available. The iconPrefix identifies one of three collections: “glyphicon”, “fa”, or “custom”. See Leaflet Style for more information.

  • iconType (string, Optional, default as "info-sign") – Specifies the particular icon to be used for the icon/pin. The list of available options depends on the choice of iconPrefix. See Leaflet Style for available options.

  • iconColor (string, Optional, default as "blue") – Defines the color of the icon/pin. See Leaflet Style for the list of available color options.

  • iconText (string, Optional, default as None) – Text that will be displayed within the node on a Leaflet map. This text will only be shown if iconPrefix is ‘custom’ and iconType includes a font color and font size. See Leaflet Style.

  • popupText (string, Optional, default as None) – The icon/pin will include this text as a popup label (you will need to click on the pin in the map to see this label).

  • lineWeight (int, Optional, default 3) – The width of the polygon’s outline, in units of [pixels]. This value is ignored if lineColor = None.

  • lineOpacity (float in [0, 1], Optional, default 0.8) – Specifies the opacity of the polygon’s outline. Valid values are in the range from 0 (invisible) to 1 (no transparency).

  • lineStyle (string, Optional, default 'solid') – The style of the polygon’s outline. See Leaflet Style for a list of valid options.

  • fillOpacity (float in [0, 1], Optional, default 0.3) – Specifies the opacity of the polygon’s interior. Valid values are in the range from 0 (invisible) to 1 (no transparency).

Returns

A Folium map object containing a polygon (and pre-existing items previously specified in mapObject).

Return type

Folium object

Example

Import veroviz and check if the version is up-to-date:
>>> import veroviz as vrv
>>> vrv.checkVersion()
The following examples assume the use of ORS as the data provider. If you have saved your API keys as environment variables, you may use os.environ to access them:
>>> import os
>>>
>>> ORS_API_KEY = os.environ['ORSKEY']
>>>
>>> # Otherwise, you may specify your keys here:
>>> # ORS_API_KEY = 'YOUR_ORS_KEY_GOES_HERE'
Get isochrone data:
>>> iso = vrv.isochrones(location         = [43.00154, -78.7871],
...                      locationType     = 'start',
...                      travelMode       = 'driving-car',
...                      rangeType        = 'time',
...                      rangeSize        = vrv.convertTime(5, 'minutes', 'seconds'),
...                      interval         = vrv.convertTime(2.5, 'minutes', 'seconds'),
...                      smoothing        = 5,
...                      dataProvider     ='ors-online',
...                      dataProviderArgs = {'APIkey': ORS_API_KEY})
A minimal working example, using mostly default values:
>>> vrv.addLeafletIsochrones(iso = iso)
An example using all of the functional parameters:
>>> vrv.addLeafletIsochrones(mapObject          = None,
...                          mapFilename        = None,
...                          mapBackground      = 'cartodb dark_matter',
...                          mapBoundary        = None,
...                          zoomStart          = None,
...                          iso                = iso,
...                          showBoundingRegion = True,
...                          iconPrefix         = 'custom',
...                          iconType           = '12-white-12',
...                          iconColor          = 'red',
...                          iconText           = '1',
...                          popupText          = None,
...                          lineWeight         = 3,
...                          lineOpacity        = 0.8,
...                          lineStyle          = 'solid',
...                          fillOpacity        = 0.3)
addLeafletMarker(mapObject=None, mapFilename=None, mapBackground='CartoDB positron', mapBoundary=None, zoomStart=None, center=None, radius=5, text=None, fontSize=24, fontColor='orange', popupText=None, lineWeight=3, lineColor=None, lineOpacity=0.8, lineStyle='solid', fillColor='red', fillOpacity=0.3)[source]

Add a circle-shaped marker, with a radius specified in [pixels], to a Leaflet map.

Note

This function differs from addLeafletCircle, in which the circle’s radius is specified in [meters].

Parameters
  • mapObject (Folium object, Optional, default None) – A Folium map object. If provided, the marker will be added to an existing map. Otherwise, a new map will be created.

  • mapFilename (string, Optional, default None) – If provided, the map will be saved to this file, which should have a .html extension. mapFilename can contain a filepath. If mapFilename is not provided, no file will be generated. The returned mapObject can be viewed within a Jupyter notebook.

  • mapBackground (string, Optional, default 'CartoDB positron') – The tiles of the map, default to be ‘CartoDB positron’, for options, see Leaflet Style, also see folium documentation (https://python-visualization.github.io/folium/modules.html) for more options

  • mapBoundary (list [LIST OF LISTS?], Optional, default None) – If provided, the mapBoundary coordinates are used to determine a zoom level such that these coordinates are contained within view when the map is opened. This feature is useful if you want to create multiple comparison maps, each with the same zoom level and centering. mapBoundary must be in the form [[south lat, west lon], [north lat, east lon]].

  • zoomStart (int, Optional, default as None) – Specifies the default zoom level. 1 –> global view; 18 –> max zoom. Note that some map tiles have maximum zoom levels less than 18. The zoomStart will be overridden by a mapBoundary (if one is provided).

  • center (list, Required, default None) – Specifies the center point of the circle marker. Must be a list of the form [lat, lon] or [lat, lon, alt]. If provided, the altitude component will be ignored (as all locations on Leaflet maps are assumed to be at ground level).

  • radius (float, Required, default None) – The radius of the circle marker, in units of [pixels].

  • text (string, Optional, default None) – Specifies the text to be displayed on the map, centered as the center location.

  • fontSize (float, Optional, default 24) – The size of the font, in units of [points]. The default is 24-point font.

  • fontColor (string, Optional, default 'orange') – The color of the text string. fontColor may be one of Leaflet’s pre-specified colors (see Leaflet Style), or it may be a hex value, such as #ff0000 (see https://www.w3schools.com/colors/colors_picker.asp).

  • popupText (string, Optional, default as None) – The marker will include this text as a popup label (you will need to click on the marker in the map to see this label).

  • lineWeight (int, Optional, default 3) – The width of the circle marker’s outline, in units of [pixels]. This value is ignored if line = False.

  • lineColor (string, Optional, default 'red') – The color of the circle marker’s outline. lineColor may be one of Leaflet’s pre-specified colors (see Leaflet Style), or it may be a hex value, such as #ff0000 (see https://www.w3schools.com/colors/colors_picker.asp). The line color is ignored if line = False.

  • lineOpacity (float in [0, 1], Optional, default 0.8) – The opacity of the circle marker’s outline, where 0 is invisible and 1 represents no transparency. See Leaflet Style

  • lineStyle (string, Optional, default 'solid') – The style of the circle marker’s outline. See Leaflet Style for a list of valid options.

  • fillColor (string, Optional, default None) – The color of the interior of the circle marker. fillColor may be one of Leaflet’s pre-specified colors (see Leaflet Style), or it may be a hex value, such as #ff0000 (see https://www.w3schools.com/colors/colors_picker.asp). The fill color is ignored if fill = False.

  • fillOpacity (float in [0, 1], Optional, default 0.3) – The opacity of the circle marker’s interior, where 0 is invisible and 1 represents no transparency. See Leaflet Style

Returns

A Folium map object containing a circle marker (and pre-existing items previously specified in mapObject).

Return type

Folium object

Example

>>> # Draw a circle of radius 10 pixels, centered on the Univ. at Buffalo campus.
>>> # Save this as "a_marker.html".
>>> import veroviz as vrv
>>> myMap = vrv.addLeafletMarker(
...     center=[43.00154, -78.7871],
...     radius=10,
...     mapFilename="a_marker.html")
>>> myMap
>>> # Draw a circle of radius 30 pixels, centered on the Univ. at Buffalo campus.
>>> # This example includes all of the available function arguments.
>>> import veroviz as vrv
>>> myMap = vrv.addLeafletMarker(
...     mapObject = None,
...     mapFilename = None,
...     mapBackground = 'CartoDB positron',
...     mapBoundary = None,
...     zoomStart = 11,
...     center = [43.00154, -78.7871],
...     radius = 30,
...     text = 'UB',
...     fontSize = 24,
...     fontColor = 'black',
...     popupText = 'Univ. at Buffalo',
...     lineWeight = 3,
...     lineColor = 'orange',
...     lineOpacity = 0.6,
...     lineStyle = 'dashed',
...     fillColor = 'blue',
...     fillOpacity = 0.3)
>>> myMap
addLeafletPolygon(mapObject=None, mapFilename=None, mapBackground='CartoDB positron', mapBoundary=None, zoomStart=None, points=None, popupText=None, lineWeight=3, lineColor='red', lineOpacity=0.8, lineStyle='solid', fillColor=None, fillOpacity=0.3)[source]

Add a polygon, as defined by an ordered collection of lat/lon coordinates, to a Leaflet map.

Note

There is also a “polyline” function, which does not assume a closed shape.

Parameters
  • mapObject (Folium object, Optional, default None) – A Folium map object. If provided, the polygon will be added to an existing map. Otherwise, a new map will be created.

  • mapFilename (string, Optional, default as None) – This is the name of the map file that will be created (e.g., “../output/map.html” or “map.html”). The filename should have a .html extension. If mapFilename is not provided, no map file will be generated. The returned map object can be viewed within a Jupyter notebook.

  • mapBackground (string, Optional, default as 'CartoDB positron') – Sets the background tiles of the map. See Leaflet Style for the list of options.

  • mapBoundary (list of lists, Optional, default as None) – Allows customization of the zoom level. If a map boundary is provided, the zoom level will correspond to the rectangle defined by the two map boundary points. This feature is useful if you want to create multiple comparison maps, each with the same zoom level and centering. Must be in the form [[south lat, west lon], [north lat, east lon]].

  • zoomStart (int, Optional, default as None) – Specifies the default zoom level. 1 –> global view; 18 –> max zoom. Note that some map tiles have maximum zoom levels less than 18. The zoomStart will be overridden by a mapBoundary (if one is provided).

  • points (list of lists, Required, default None) – Specifies the ordered collection of lat/lon coordinates comprising the polygon. This must be a list of lists, of the form [[lat1, lon1], [lat2, lon2], …, [latn, lonn]] or [[lat1, lon1, alt1], [lat2, lon2, alt2], …, [latn, lonn, altn]]. If an altitude is provided with each coordinate, this component will be ignored (as all Leaflet maps assume that objects are at ground level). It is not necessary for [lat1, lon1] and [latn, lonn] to be the same point. In other words, the polygon will automatically connect the first and last locations specified in the points list.

  • popupText (string, Optional, default as None) – The polygon will include this text as a popup label (you will need to click on the polygon in the map to see this label).

  • lineWeight (int, Optional, default 3) – The width of the polygon’s outline, in units of [pixels]. This value is ignored if lineColor = None.

  • lineColor (string, Optional, default 'red') – The color of the polygon’s outline. lineColor may be one of Leaflet’s pre-specified colors (see Leaflet Style), or it may be a hex value, such as #ff0000 (see https://www.w3schools.com/colors/colors_picker.asp). No line will be drawn if lineColor = None.

  • lineOpacity (float in [0, 1], Optional, default 0.8) – Specifies the opacity of the polygon’s outline. Valid values are in the range from 0 (invisible) to 1 (no transparency).

  • lineStyle (string, Optional, default 'solid') – The style of the polygon’s outline. See Leaflet Style for a list of valid options.

  • fillColor (string, Optional, default None) – The color of the interior of the polygon. fillColor may be one of Leaflet’s pre-specified colors (see Leaflet Style), or it may be a hex value, such as #ff0000 (see https://www.w3schools.com/colors/colors_picker.asp). The polygon will not be filled if fillColor = None.

  • fillOpacity (float in [0, 1], Optional, default 0.3) – Specifies the opacity of the polygon’s interior. Valid values are in the range from 0 (invisible) to 1 (no transparency).

Returns

A Folium map object containing a polygon (and pre-existing items previously specified in mapObject).

Return type

Folium object

Example

>>> # Draw a filled polygon around the Univ. at Buffalo campus.
>>> # Save this as "a_polygon.html".
>>> import veroviz as vrv
>>> campusPoints = [[43.0121, -78.7858],
...                 [43.0024, -78.7977],
...                 [42.9967, -78.7921],
...                 [42.9988, -78.7790]]
>>> myMap = vrv.addLeafletPolygon(
...     points=campusPoints,
...     mapFilename="a_polygon.html")
>>> myMap
>>> # Draw a filled polygon around the Univ. at Buffalo campus.
>>> # This example includes all of the available function arguments.
>>> import veroviz as vrv
>>> campusPoints = [[43.0121, -78.7858],
...                 [43.0024, -78.7977],
...                 [42.9967, -78.7921],
...                 [42.9988, -78.7790]]
>>> myMap = vrv.addLeafletPolygon(
...     mapObject = None,
...     mapFilename = None,
...     mapBackground = 'OpenStreetMap',
...     mapBoundary = vrv.getMapBoundary(locs=campusPoints),
...     zoomStart = 15,
...     points = campusPoints,
...     popupText = 'Univ. at Buffalo',
...     lineWeight = 7,
...     lineColor = '#ff00ff',
...     lineOpacity = 0.9,
...     lineStyle = 'solid',
...     fillColor = '#ff66ff',
...     fillOpacity = 0.3)
>>> myMap
addLeafletPolyline(mapObject=None, mapFilename=None, mapBackground='CartoDB positron', mapBoundary=None, zoomStart=None, points=None, popupText=None, lineWeight=3, lineColor='red', lineOpacity=0.8, lineStyle='solid', lineCurveType='straight', lineCurvature=45, useArrows=False, arrowsPerArc=1)[source]

Add a polyline, as described by an ordered collection of lat/lon coordinates, to a Leaflet map.

Note

The polyline is an “open” shape, in the sense that there’s nothing connecting the first and last locations. By contrast, the “polygon” shape will automatically connect the first and last locations.

Parameters
  • mapObject (Folium object, Optional, default None) – A Folium map object. If provided, the polyline will be added to an existing map. Otherwise, a new map will be created.

  • mapFilename (string, Optional, default as None) – This is the name of the map file that will be created (e.g., “../output/map.html” or “map.html”). The filename should have a .html extension. If mapFilename is not provided, no map file will be generated. The returned map object can be viewed within a Jupyter notebook.

  • mapBackground (string, Optional, default as 'CartoDB positron') – Sets the background tiles of the map. See Leaflet Style for the list of options.

  • mapBoundary (list of lists, Optional, default as None) – Allows customization of the zoom level. If a map boundary is provided, the zoom level will correspond to the rectangle defined by the two map boundary points. This feature is useful if you want to create multiple comparison maps, each with the same zoom level and centering. Must be in the form [[south lat, west lon], [north lat, east lon]].

  • zoomStart (int, Optional, default as None) – Specifies the default zoom level. 1 –> global view; 18 –> max zoom. Note that some map tiles have maximum zoom levels less than 18. The zoomStart will be overridden by a mapBoundary (if one is provided).

  • points (list of lists, Required, default None) – Specifies the ordered collection of lat/lon coordinates comprising the polyline. This must be a list of lists, of the form [[lat1, lon1], [lat2, lon2], …, [latn, lonn]] or [[lat1, lon1, alt1], [lat2, lon2, alt2], …, [latn, lonn, altn]]. If an altitude is provided with each coordinate, this component will be ignored (as all Leaflet maps assume that objects are at ground level). Note that the polyline will not automatically connect the first and last locations specified in the points list. (By contrast the “polygon” function does connect those locatons.)

  • popupText (string, Optional, default as None) – The polyline will include this text as a popup label (you will need to click on the polyline in the map to see this label).

  • lineWeight (int, Optional, default 3) – The width of the polyline’s outline, in units of [pixels]. This value is ignored if lineColor = None.

  • lineColor (string, Optional, default 'red') – The color of the polyline’s outline. lineColor may be one of Leaflet’s pre-specified colors (see Leaflet Style), or it may be a hex value, such as #ff0000 (see https://www.w3schools.com/colors/colors_picker.asp). No line will be drawn if lineColor = None.

  • lineOpacity (float in [0, 1], Optional, default 0.8) – Specifies the opacity of the polyline. Valid values are in the range from 0 (invisible) to 1 (no transparency).

  • lineStyle (string, Optional, default 'solid') – The style of the polyine. See Leaflet Style for a list of valid options.

  • lineCurveType (string, Optional, default as 'straight') – The type of curve to be shown on leaflet map for Arcs dataframes (curves will not be applied to :ref:Assignments dataframes). The options are ‘Bezier’, ‘greatcircle’, and ‘straight’. If Bezier is provided, the leafletCurvature is also required. If greatcircle is provided, the arc follow the curvature of the Earth.

  • lineCurvature (float in (-90, 90), Conditional, default as 45) – If leafletCurveType is ‘Bezier’, then leafletCurvature is required; otherwise this argument will not be used. The curvature specifies the angle between a straight line connecting the two nodes and the curved arc emanating from those two nodes. Therefore, this value should be in the open interval (-90, 90), although values in the (-45, 45) range tend to work best.

  • useArrows (boolean, Optional, default as None) – Indicates whether arrows should be shown on all arcs on the Leaflet map.

  • arrowsPerArc (int, Optional, default as 1) – Number of arrows display on each arc, should be integer greater than 0. Each arc will have the same number of arrows, regardless of arc length. If useArrows is False, this parameter will be ignored (i.e., no arrows will be drawn).

Returns

A Folium map object containing a polyline (and pre-existing items previously specified in mapObject).

Return type

Folium object

Example

>>> # Draw a polyline around the northern portion of the Univ. at Buffalo campus.
>>> # Save this as "a_polyline.html".
>>> import veroviz as vrv
>>> campusPoints = [[43.0024, -78.7977],
...                 [43.0121, -78.7858],
...                 [42.9988, -78.7790]]
>>> myMap = vrv.addLeafletPolyline(
...     points=campusPoints,
...     mapFilename="a_polyline.html")
>>> myMap
>>> # Draw a polyline around the northern portion of the Univ. at Buffalo campus.
>>> # This example includes all of the available function arguments.
>>> import veroviz as vrv
>>> campusPoints = [[43.0024, -78.7977],
...                 [43.0121, -78.7858],
...                 [42.9988, -78.7790]]
>>> myMap = vrv.addLeafletPolyline(
...     mapObject = None,
...     mapFilename = None,
...     mapBackground = 'CartoDB positron',
...     mapBoundary = vrv.getMapBoundary(locs=campusPoints),
...     zoomStart = None,
...     points = campusPoints,
...     popupText = 'Univ. at Buffalo',
...     lineWeight = 3,
...     lineColor = '#0055ff',
...     lineOpacity = 0.8,
...     lineStyle = 'solid',
...     lineCurveType = 'bezier',
...     lineCurvature = 30,
...     useArrows = True,
...     arrowsPerArc = 1)
>>> myMap
addLeafletText(mapObject=None, mapFilename=None, mapBackground='CartoDB positron', mapBoundary=None, zoomStart=None, anchorPoint=None, text=None, fontSize=24, fontColor='orange', horizAlign='center')[source]

Add a text label to a Leaflet map.

Parameters
  • mapObject (Folium object, Optional, default None) – A Folium map object. If provided, the text label will be added to an existing map. Otherwise, a new map will be created.

  • mapFilename (string, Optional, default as None) – This is the name of the map file that will be created (e.g., “../output/map.html” or “map.html”). The filename should have a .html extension. If mapFilename is not provided, no map file will be generated. The returned map object can be viewed within a Jupyter notebook.

  • mapBackground (string, Optional, default as 'CartoDB positron') – Sets the background tiles of the map. See Leaflet Style for the list of options.

  • mapBoundary (list of lists, Optional, default as None) – Allows customization of the zoom level. If a map boundary is provided, the zoom level will correspond to the rectangle defined by the two map boundary points. This feature is useful if you want to create multiple comparison maps, each with the same zoom level and centering. Must be in the form [[south lat, west lon], [north lat, east lon]].

  • zoomStart (int, Optional, default as None) – Specifies the default zoom level. 1 –> global view; 18 –> max zoom. Note that some map tiles have maximum zoom levels less than 18. The zoomStart will be overridden by a mapBoundary (if one is provided).

  • anchorPoint (list, Required, default None) – Specifies an anchor point (location) for the text label. Must be a list of the form [lat, lon] or [lat, lon, alt]. If provided, the altitude component will be ignored (as all locations on Leaflet maps are assumed to be at ground level). See also the horizAlign field below.

  • text (string, Required, default None) – Specifies the text to be displayed on the map at the location of anchorPoint.

  • fontSize (float, Optional, default 24) – The size of the font, in units of [points]. The default is 24-point font.

  • fontColor (string, Optional, default 'orange') – The color of the text string. fontColor may be one of Leaflet’s pre-specified colors (see Leaflet Style), or it may be a hex value, such as #ff0000 (see https://www.w3schools.com/colors/colors_picker.asp).

  • horizAlign (string, Optional, default 'center') – The horizontal alignment of the text string, relative to the location specified by the anchorPoint input argument. Valid options are ‘left’ (the text begins at the anchorPoint location), ‘right’ (the text ends at the anchorPoint location), or ‘center’ (the text is centered at the ‘anchorPoint’ location).

Returns

A Folium map object containing a text string (and pre-existing items previously specified in mapObject).

Return type

Folium object

Example

>>> # Draw a text label at the location of Bell Hall on the
>>> # Univ. at Buffalo campus.
>>> # Save this as "a_text_label.html".
>>> import veroviz as vrv
>>> myMap = vrv.addLeafletText(
...     anchorPoint=[43.00154, -78.7871],
...     text="Bell Hall",
...     mapFilename="a_text_label.html")
>>> myMap
>>> # Draw a text label at the location of Bell Hall on the
>>> # Univ. at Buffalo campus.
>>> # This example includes all of the available function arguments.
>>> import veroviz as vrv
>>> myMap = vrv.addLeafletText(
...     mapObject=None,
...     mapFilename=None,
...     mapBackground='CartoDB positron',
...     mapBoundary=None,
...     zoomStart=10,
...     anchorPoint=[43.00154, -78.7871],
...     text="Bell Hall",
...     fontSize=34,
...     fontColor='black',
...     horizAlign='left')
>>> myMap
addLeafletWeather(mapObject=None, mapType='precip', APIkey=None, mapFilename=None, mapBackground='CartoDB positron')[source]

Adds map tiles showing weather conditions to a Leaflet map. Weather tiles are obtained via openweathermap.org (an API key is required).

Parameters
  • mapObject (Folium object, Optional, default as None) – If you already have a map (as a Folium object), you can provide that object and overlay weather on that map.

  • mapType (string, Required, default as 'precip') – Specifies the type of weather map to overlay on the mapObject. Valid options are: ‘clouds’, ‘precip’, ‘pressure’, ‘wind’, and ‘temp’.

  • APIkey (string, Required, default at None) – These weather maps are hosted by openweathermap.org. You may register for a free API key at their website.

  • mapFilename (string, Optional, default as None) – This is the name of the map file that will be created (e.g., “../output/map.html” or “map.html”). The filename should have a .html extension. If mapFilename is not provided, no map file will be generated. The returned map object can be viewed within a Jupyter notebook.

  • mapBackground (string, Optional, default as 'CartoDB positron') – Sets the background tiles of the map. See Leaflet Style for the list of options.

Returns

A Folium map object containing a text string (and pre-existing items previously specified in mapObject).

Return type

Folium object

Example

Import veroviz and check if the version is up-to-date:
>>> import veroviz as vrv
>>> vrv.checkVersion()
If you have saved your API keys as environment variables, you may use os.environ to access them:
>>> import os
>>>
>>> OPENWEATHER_KEY = os.environ['OPENWEATHERKEY']
>>>
>>> # Otherwise, you may specify your keys here:
>>> # OPENWEATHER_KEY = 'YOUR_OPENWEATHERMAP_KEY_GOES_HERE'
Display a map showing wind conditions. This example includes all available function arguments.
>>> vrv.addLeafletWeather(mapObject     = None,
...                       mapType       = 'wind',
...                       APIkey        = OPENWEATHER_KEY,
...                       mapFilename   = None,
...                       mapBackground = 'cartodb dark_matter')
createLeaflet(mapObject=None, mapFilename=None, mapBackground='CartoDB positron', mapBoundary=None, zoomStart=None, nodes=None, iconPrefix=None, iconType=None, iconColor=None, iconText=None, arcs=None, arcWeight=None, arcStyle=None, arcOpacity=None, arcCurveType=None, arcCurvature=None, arcColor=None, useArrows=None, arrowsPerArc=1, boundingRegion=None, boundingWeight=3, boundingOpacity=0.6, boundingStyle='dashed', boundingColor='brown')[source]

createLeaflet is used to generate Leaflet objects using folium. The function takes a boundingRegion polygon, Nodes, Arcs, and Assignments dataframes as inputs, and creates a folium/leaflet map showing boundings, nodes and/or arcs.

Parameters
  • mapObject (Folium object, Optional, default as None) – If you already have a map (as a Folium object), you can provide that object and add content to that map.

  • mapFilename (string, Optional, default as None) – This is the name of the map file that will be created (e.g., “../output/map.html” or “map.html”). The filename should have a .html extension. If mapFilename is not provided, no map file will be generated. The returned map object can be viewed within a Jupyter notebook.

  • mapBackground (string, Optional, default as 'CartoDB positron') – Sets the background tiles of the map. See Leaflet Style for the list of options.

  • mapBoundary (list of lists, Optional, default as None) – Allows customization of the zoom level. If a map boundary is provided, the zoom level will correspond to the rectangle defined by the two map boundary points. This feature is useful if you want to create multiple comparison maps, each with the same zoom level and centering. Must be in the form [[south lat, west lon], [north lat, east lon]].

  • zoomStart (int, Optional, default as None) – Specifies the default zoom level. 1 –> global view; 18 –> max zoom. Note that some map tiles have maximum zoom levels less than 18. The zoomStart will be overridden by a mapBoundary (if one is provided).

  • nodes (Nodes, Conditional, nodes, arcs, and boundingRegion can not be None at the same time) – A Nodes dataframe describing the collection of nodes to be displayed on the Leaflet map. See Nodes for documentation on this type of dataframe.

  • iconPrefix (string, Optional, default as None) – Overrides the leafletIconPrefix column of an input Nodes dataframe. If provided, all nodes will use this icon prefix. Valid options are “glyphicon”, “fa”, or “custom”. See Leaflet Style for details.

  • iconType (string, Optional, default as None) – Overrides the leafletIconType column of an input Nodes dataframe. If provided, all nodes will use this icon type. The valid iconType options depend on the choice of iconPrefix. See Leaflet Style for the collection of valid icon prefix/type combinations.

  • iconColor (string, Optional, default as None) – Overrides the leafletColor column of an input Nodes dataframe. If provided, all icons will use this color when displayed on this Leaflet map. See Leaflet Style for the list of available color options.

  • iconText (string, Optional, default as None) – Overrides the leafletIconText column of an input Nodes dataframe. If provided, this text will be displayed within the node on a Leaflet map. This text will only be shown if leafletIconPrefix is ‘custom’ and leafletIconType includes a font color and font size. A value of None will result in the node ID being displayed in the node. See Leaflet Style.

  • arcs (Arcs or Assignments, Conditional, nodes, arcs and boundingRegion can not be None at the same time) – An Arcs or Assignments dataframe describing vehicle routes. Each row of this dataframe will be shown as a line on the Leaflet map. See the documentation on Arcs and Assignments for more information.

  • arcWeight (int, Optional, default as None) – Overrides the leafletWeight column of an input Arcs or Assignments dataframe. If provided, all arcs will be displayed with this line thickness (in pixels).

  • arcStyle (string, Optional, default as None) – Overrides the leafletStyle column of an input Arcs or Assignments dataframe. If provided, all arcs will be displayed with this type. Valid options are ‘solid’, ‘dotted’, or ‘dashed’. See Leaflet Style for more information.

  • arcOpacity (float in [0, 1], Optional, default as None) – Overrides the leafletOpacity column of an input Arcs or Assignments dataframe. If provided, each arc will be displayed with this opacity. Valid values are in the range from 0 (invisible) to 1 (no transparency).

  • arcColor (string, Optional, default as None) – Overrides the leafletColor column of an input Arcs or Assignments dataframe. If provided, all arcs will be displayed with this color. See Leaflet Style for a list of available colors.

  • arcCurveType (string, Optional, default as 'straight') – Choose the type of curve to be shown on leaflet map for Arcs dataframe (curves will not be applied to Assignments dataframes). The options are Bezier, greatcircle, and ‘straight’. If Bezier is provided, the arcCurvature should not be None, leaflet will draw a Bezier curve between given nodes. If greatcircle is provided, the curve will go along with the surface of the Earth.

  • arcCurvature (float in (-90, 90), Conditional, default as 45) – If choose Bezier as arcCurveType, then arcCurvature is required; otherwise this argument will not be used. The meaning of this argument is as following: link two nodes using straight line, the degrees between this straight line and the curve at two nodes is this argument, therefore it should be greater or equal to 0 and less than 90. A degree between -45 and 45 is recommended.

  • useArrows (boolean, Optional, default as None) – Indicates whether arrows should be shown on all arcs on the Leaflet map.

  • arrowsPerArc (int, Optional, default as 1) – Number of arrows display on each arc, should be integer greater than 0. Each arc will have the same number of arrows, regardless of arc length. If useArrows is False, this parameter will be ignored (i.e., no arrows will be drawn).

  • boundingRegion (list of lists, Conditional, nodes, arcs and boundingRegion can not be None at the same time) – A sequence of lat/lon coordinates defining a boundary polygon. The format is [[lat, lon], [lat, lon], …, [lat, lon]].

  • boundingWeight (int, Optional, default as 3) – Specifies the weight (in pixels) of the line defining the boundingRegion (if provided) when displayed in Leaflet.

  • boundingStyle (string, Optional, default as 'dashed') – Specifies the line style of the boundingRegion (if provided). Valid options are ‘solid’, ‘dotted’, ‘dashed’. See Leaflet Style for more information.

  • boundingOpacity (float in [0, 1], Optional, default as 0.6) – Specifies the opacity of the boundingRegion (if provided) when displayed in Leaflet. Valid values are in the range from 0 (invisible) to 1 (no transparency).

  • boundingColor (string, Optional, default as 'brown') – Specifies the line color of the boundingRegion (if provided) when displayed in Leaflet. See Leaflet Style for a list of available colors.

Returns

A new/updated map that displays the nodes, arcs, and/or bounding region.

Return type

Folium object

Examples

First, import veroviz and check the latest version
>>> import veroviz as vrv
>>> vrv.checkVersion()
Now, generate some example nodes inside a bounding region
>>> bounding = [
...     [42.98355351219673, -78.90518188476564],
...     [43.04731443361136, -78.83857727050783],
...     [43.02221961002041, -78.7108612060547],
...     [42.92777124914475, -78.68957519531251],
...     [42.866402688514626, -78.75343322753908],
...     [42.874957707517865, -78.82415771484375],
...     [42.90111863978987, -78.86878967285158],
...     [42.92224052343343, -78.8921356201172]]
>>> exampleNodes = vrv.generateNodes(
...     nodeType         = 'customer',
...     nodeDistrib      = 'normalBB',
...     nodeDistribArgs  = {
...         'center'         : [42.90, -78.80],
...         'stdDev'         : 10000,
...         'boundingRegion' : bounding
...     },
...     numNodes         = 3,
...     leafletColor     = 'orange')
The first example is using all default setting for generating a set of given nodes in Nodes dataframe.
>>> vrv.createLeaflet(nodes=exampleNodes)
Define some arcs based on the nodes we just generated:
>>> exampleArcs = vrv.createArcsFromNodeSeq(
...     nodes   = exampleNodes,
...     nodeSeq = [1, 2, 3])
>>> exampleArcs
Display the nodes, arcs, and bounding region simultaneously:
>>> vrv.createLeaflet(
...     nodes          = exampleNodes,
...     arcs           = exampleArcs,
...     boundingRegion = bounding)
The createLeaflet function provides options to override styles that were defined in the input nodes and/or arcs dataframes. Note: These overrides will not change the contents in the dataframes.
>>> nodesAndArcsMap = vrv.createLeaflet(
...     nodes      = exampleNodes,
...     iconPrefix = 'fa',
...     iconType   = 'car',
...     iconColor  = 'blue',
...     arcs       = exampleArcs,
...     arcStyle   = 'dotted')
>>> nodesAndArcsMap

If you already have a folium map object, you can add more into it. Here, we add a bounding region to the nodesAndArcsMap object defined above.

>>> nodesAndArcsMap = vrv.createLeaflet(
...     mapObject      = nodesAndArcsMap,
...     boundingRegion = bounding)
>>> nodesAndArcsMap
A new collection of nodes is defined here:
>>> newNodes = vrv.generateNodes(
...     nodeType        = 'customer',
...     nodeDistrib     = 'uniformBB',
...     nodeDistribArgs = {
...         'boundingRegion' : bounding
...     },
...     numNodes        = 4,
...     leafletColor    = 'red')
>>> newNodes

We will add these nodes to our existing map, but we’re overriding these new nodes with a green color: Notice that the addition of new entities will not change the style of previous entities that were already added into the map.

>>> newMapWithArcsAndMoreNodes = vrv.createLeaflet(
...     mapObject = nodesAndArcsMap,
...     nodes     = newNodes,
...     iconColor = 'green')
>>> newMapWithArcsAndMoreNodes
The following example includes all of the function arguments.
>>> vrv.createLeaflet(
...     mapObject       = None,
...     mapFilename     = 'example.html',
...     mapBackground   = 'CartoDB positron',
...     mapBoundary     = None,
...     zoomStart       = 10,
...     nodes           = exampleNodes,
...     iconPrefix      = 'fa',
...     iconType        = 'flag',
...     iconColor       = 'red',
...     iconText        = 'Here are some nodes',
...     arcs            = exampleArcs,
...     arcWeight       = 5,
...     arcStyle        = 'dashed',
...     arcOpacity      = 1,
...     arcColor        = 'green',
...     useArrows       = True,
...     boundingRegion  = bounding,
...     boundingWeight  = 1,
...     boundingOpacity = 0.8,
...     boundingStyle   = 'dotted',
...     boundingColor   = 'black')