lds

This module contains functions and procedures that make use of location data services, such as geocoding, reverse geocoding, isolines and routing computation.

For manual installations of the CARTO Analytics Toolbox, after installing it for the first time, and before using any LDS function you need to call the SETUP procedure to configure the LDS and gateway functions. It also optionally sets default credentials.

Credentials

Your CARTO account has monthly quotas assigned for each LDS service that are used up by every call to the LDS functions and procedures in the Analytics Toolbox.

Accordingly, the use of these functions and procedures requires providing authorization credentials to prevent fraudulent usage. Two parameters are needed:

  • api_base_url The API base url is simply the address through which you can access all the services of your CARTO account, and it depends on the region or premises where your account is located. Usually it will be this one: https://gcp-us-east1.api.carto.com.

  • api_access_token This token is an API Access Tokenarrow-up-right that is allowed to use the LDS API. You must keep this secret! Anyone that has access to this token can use up the LDS quota assigned to your account.

Both the API base url and your API access token can be accessed through the developers section of the CARTO user interface. The API base url is displayed inside this section while for the API access token you will have to create a new API access token allowing the LDS API.

For more information about CARTO for developers, please check our documentation for Developersarrow-up-right.

If default credentials are provided to the SETUP procedure, you can pass NULL values for the credentials in the LDS functions, and the credentials configured during SETUP will be used.

circle-info

tip

To check that everything works correctly, without spending any credits, make a call to the GET_LDS_QUOTA_INFO procedure. You can enter the following in the Databricks console having selected the project where the Analytics Toolbox is installed:

SELECT carto.GET_LDS_QUOTA_INFO(NULL, NULL);

Note that if you haven't set up default LDS credentials with SETUP you'll need to provide them when calling the LDS fucntions:

SELECT carto.GET_LDS_QUOTA_INFO(
  '<my-api-base-url>',
  '<my-api-access-token>'
)

You should get a JSON response like this, with the available services and the quotas:

[
  {
    "used_quota": 10,
    "annual_quota": 100000,
    "providers": {
        "geocoding": "tomtom",
        "isolines": "here",
        "routing":"tomtom"
    }
  }
]

LDS quota is an annual quota that defines how much geocoding and isolines you can compute. Each geocoded row or computed isolines counts as one LDS quota unit. The single element in the result of LDS_QUOTA_INFO will show your LDS quota for the current annual period (annual_quota), how much you’ve spent (used_quota), and which LDS providers are in use.

This also will allow you to verify that you have the right credentials, the AT is installed correctly and the service is working.

GEOCODE_TABLE

circle-exclamation

Description

Geocodes an input table by adding an user defined column geom_column with the geographic coordinates (latitude and longitude) of a given address column. This procedure also adds a carto_geocode_metadata column with additional information of the geocoding result in JSON format. It geocodes the table sequentially in batches, with the batch size optimized for the specific LDS provider that you are using.

  • api_base_url: STRING|NULL url of the API where the customer account is stored. If default credentials have been configured with SETUP NULL can be passed to use them.

  • api_access_token: STRING|NULL an API Access Tokenarrow-up-right that is allowed to use the LDS API. If default credentials have been configured with SETUP NULL can be passed to use them.

  • input_table: STRING name of the table to be geocoded. Please make sure you have enough permissions to alter this table, as this procedure will add two columns to it to store the geocoding result.

  • address_column: STRING name of the column from the input table that contains the addresses to be geocoded.

  • geom_column: STRING|NULL column name for the geometry column. Defaults to 'geom'. Set to NULL to use the default value.

  • country: STRING|NULL name of the country in ISO 3166-1 alpha-2arrow-up-right. Defaults to ''. Set to NULL to use the default value.

  • options: STRING|NULL containing a valid JSON with the different options. In addition to provider-specific options described below, you can specify batch_size to control the number of addresses processed per batch (subject to provider limits). Additional options include:

    • carto_force_geocode: A boolean option (false by default) that can be used to force geocoding rows that already have a non-null value in geom_column.

    • language: A STRING that specifies the language of the geocoding in RFC 4647 format (supported by all providers).

If the input table already contains a geometry column with the name defined by geom_column, only those rows with NULL values will be geocoded.

Examples

GEOCODE_REVERSE_TABLE

circle-exclamation

Description

Reverse-geocodes an input table by adding a user defined column address_column with the address corresponding to a given point location column. It reverse-geocodes the table sequentially in batches, with the batch size optimized for the specific LDS provider that you are using.

  • api_base_url: STRING|NULL URL of the API where the customer account is stored. If default credentials have been configured with SETUP NULL can be passed to use them.

  • api_access_token: STRING|NULL an API Access Tokenarrow-up-right that is allowed to use the LDS API. If default credentials have been configured with SETUP NULL can be passed to use them.

  • input_table: STRING name of the table to be reverse-geocoded. Please make sure you have enough permissions to alter this table, as this procedure will add a column to it to store the reverse geocoding result.

  • geom_column: STRING|NULL column name for the geometry column that contains the points to be reverse-geocoded. Defaults to 'geom'. Set to NULL to use the default value.

  • address_column: STRING|NULL name of the column where the computed addresses will be stored. Defaults to 'address', and it is created on the input table if it doesn't exist. Set to NULL to use the default value.

  • language: STRING|NULL language in which results should be returned. Defaults to ''. The effect and interpretation of this parameter depends on the LDS provider assigned to your account. Set to NULL to use the default value.

  • options: STRING|NULL containing a valid JSON with the different options. You can specify batch_size to control the number of points processed per batch (subject to provider limits).

If the input table already contains a column with the name defined by address_column, only those rows with NULL or empty values will be reverse-geocoded.

Examples

CREATE_ISOLINES

circle-exclamation

Description

Calculates the isolines (polygons) from given origins (points) in a table or query. It creates a new table with the columns of the input table or query plus the isolines in the column geom and error information in the column carto_isoline_metadata. It calculates isolines sequentially in batches, with the batch size optimized for the specific LDS provider that you are using.

The output table will contain a column named carto_isoline_metadata with error information for each isoline result. Rows with errors will have a NULL geom.

Note that The term isoline is used here in a general way to refer to the areas that can be reached from a given origin point within the given travel time or distance (depending on the range_type parameter).

  • api_base_url: STRING|NULL url of the API where the customer account is stored. If default credentials have been configured with SETUP NULL can be passed to use them.

  • api_access_token: STRING|NULL an API Access Tokenarrow-up-right that is allowed to use the LDS API. If default credentials have been configured with SETUP NULL can be passed to use them.

  • input_table: STRING name of the input table or query.

  • output_table: STRING name of the output table. It will raise an error if the table already exists.

  • geom_column: STRING|NULL column name for the origin geometry column. Defaults to 'geom'. Set to NULL to use the default value.

  • mode: STRING type of transport. The supported modes depend on the provider:

    • HERE: 'walk', 'car', 'truck', 'taxi', 'bus', 'private_bus'.

    • TomTom: 'walk', 'car', 'bike', 'motorbike', 'truck', 'taxi', 'bus', 'van'.

    • TravelTime: 'walk', 'car', 'bike', 'public_transport', 'coach', 'bus', 'train', 'ferry'.

    • Mapbox: 'walk', 'car', 'bike'.

  • range_value: INT range of the isoline in seconds (for range_type 'time') or meters (for range_type 'distance').

  • range_type: STRING type of range. Supported: 'time' (for isochrones), 'distance' (for isodistances).

  • options: STRING|NULL containing a valid JSON with the different options. In addition to provider-specific options described below, you can specify batch_size to control the number of points processed per batch (subject to provider limits). Valid options are described in the table below. If no options are indicated then 'default' values would be applied.

    Provider
    Option
    Description

    HERE

    arrival_time

    A STRING that specifies the time of arrival. If the value is set, a reverse isoline is calculated. If set to "any", then time-dependent effects will not be taken into account. It cannot be used in combination with departure_time. Supported: "any", "now" and date-time as "<YYYY-MM-DD>T<hh:mm:ss>".

    HERE

    departure_time

    Default: "any". A STRING that specifies the time of departure. If set to "any", then time-dependent effects will not be taken into account. It cannot be used in combination with arrival_time. Supported: "any", "now" and date-time as "<YYYY-MM-DD>T<hh:mm:ss>".

    HERE

    optimize_for

    Default: "balanced". A STRING that specifies how isoline calculation is optimized. Supported: "quality" (calculation of isoline focuses on quality, that is, the graph used for isoline calculation has higher granularity generating an isoline that is more precise), "performance" (calculation of isoline is performance-centric, quality of isoline is reduced to provide better performance) and "balanced" (calculation of isoline takes a balanced approach averaging between quality and performance).

    HERE

    routing_mode

    Default: "fast". A STRING that specifies which optimization is applied during isoline calculation. Supported: "fast" (route calculation from start to destination optimized by travel time. In many cases, the route returned by the fast mode may not be the route with the fastest possible travel time. For example, the routing service may favor a route that remains on a highway, even if a faster travel time can be achieved by taking a detour or shortcut through an inconvenient side road) and "short" (route calculation from start to destination disregarding any speed information. In this mode, the distance of the route is minimized, while keeping the route sensible. This includes, for example, penalizing turns. Because of that, the resulting route will not necessarily be the one with minimal distance).

    TomTom

    departure_time

    Default: "now". A STRING that specifies the time of departure. Supported: "now" and date-time as "<YYYY-MM-DD>T<hh:mm:ss>".

    TomTom

    traffic

    Default: false. A BOOLEAN that specifies if all available traffic information will be taken into consideration. Supported: true and false.

    TravelTime

    level_of_detail

    A JSON string. In the most typical case, you will want to use a string in the form { scale_type: 'simple_numeric', level: -N }, with N being the detail level (-8 by default). Higher Ns (more negative levels) will simplify the polygons more but will reduce performance. There are other ways of setting the level of detail. Check the TravelTime docsarrow-up-right for more info.

    TravelTime

    departure_time

    Default: "now". A STRING that specifies the time of departure. Supported: "now" and date-time as "<YYYY-MM-DD>T<hh:mm:ss>Z".

circle-exclamation

Examples

CREATE_ROUTES

circle-exclamation

Description

Calculates the routes (line strings) between given origins and destinations (points) in a table or query. It creates a new table with the columns of the input table or query with the resulting route in the user defined column geom_column and a carto_routing_metadata column with error information. It calculates routes sequentially in batches, with the batch size optimized for the specific LDS provider that you are using.

Note that routes are calculated using the external LDS provider assigned to your CARTO account. Currently TomTom and HERE are supported.

  • api_base_url: STRING|NULL url of the API where the customer account is stored. If default credentials have been configured with SETUP NULL can be passed to use them.

  • api_access_token: STRING|NULL an API Access Tokenarrow-up-right that is allowed to use the LDS API. If default credentials have been configured with SETUP NULL can be passed to use them.

  • input_table: STRING name of the input table or query, which must have columns named origin and destination of type GEOMETRY(4326) containing points.

  • output_table: STRING name of the output table. It will raise an error if the table already exists.

  • geom_column: STRING|NULL column name for the generated geometry column that will contain the resulting routes. Defaults to 'geom'. Set to NULL to use the default value.

  • mode: STRING type of transport. The supported modes depend on the provider:

    • TomTom: 'car', 'pedestrian', 'bicycle', 'motorcycle', 'truck', 'taxi', 'bus', 'van'.

    • HERE: 'car', 'truck', 'pedestrian', 'bicycle', 'scooter', 'taxi', 'bus', 'privateBus'.

  • options: STRING|NULL containing a valid JSON with optional parameters. In addition to provider-specific options described below, you can specify batch_size to control the number of routes processed per batch (subject to provider limits). Additional parameters can be passed directly to the Routing provider by placing them in this JSON string. To find out what your provider is, check the GET_LDS_QUOTA_INFO function. The following are some of the most common parameters for each provider:

    • TomTom:

      • avoid: Specifies something that the route calculation should try to avoid when determining the route. Possible values (several of them can be used at the same time):

        • tollRoads

        • motorways

        • ferries

        • unpavedRoads

        • carpools

        • alreadyUsedRoads

        • borderCrossings

        • tunnels

        • carTrains

        • lowEmissionZones

      • routeType: Specifies the type of optimization used when calculating routes. Possible values: fastest, shortest, short, eco, thrilling

      • traffic: Set to true to consider all available traffic information during routing. Set to false otherwise

      • departAt: The date and time of departure at the departure point. It should be specified in RFC 3339 format with an optional time zone offset.

      • arriveAt: The date and time of arrival at the destination point. It should be specified in RFC 3339 format with an optional time zone offset.

      • vehicleMaxspeed: Maximum speed of the vehicle in kilometers/hour.

    • HERE:

      • avoid: Elements or areas to avoid. Information about avoidance can be found in the HERE avoidance documentationarrow-up-right

      • departureTime: The date and time of departure at the departure point. It should be specified in RFC 3339 format with an optional time zone offset.

      • arrivalTime: The date and time of arrival at the destination point. It should be specified in RFC 3339 format with an optional time zone offset.

      • language: The language to use. Supported language codes can be found in the HERE languages documentationarrow-up-right

    For more advanced usage, check the documentation of your provider's routing API.

circle-exclamation

Examples

Example with TomTom specific parameters:

GEOCODE

circle-exclamation

Description

Geocodes an address into a point with its geographic coordinates (latitude and longitude).

  • api_base_url: STRING|NULL url of the API where the customer account is stored. If default credentials have been configured with SETUP NULL can be passed to use them.

  • api_access_token: STRING|NULL an API Access Tokenarrow-up-right that is allowed to use the LDS API. If default credentials have been configured with SETUP NULL can be passed to use them.

  • address: STRING input address to geocode.

  • country: STRING|NULL name of the country in ISO 3166-1 alpha-2arrow-up-right. Defaults to ''. Set to NULL to use the default value.

  • options: STRING|NULL containing a valid JSON with the different options.

    Provider
    Option
    Description

    All

    language

    A STRING that specifies the language of the geocoding in RFC 4647 format.

Return type

GEOMETRY(4326)

Examples

GEOCODE_REVERSE

circle-exclamation

Description

Performs a reverse geocoding of the point received as input.

  • api_base_url: STRING|NULL url of the API where the customer account is stored. If default credentials have been configured with SETUP NULL can be passed to use them.

  • api_access_token: STRING|NULL an API Access Tokenarrow-up-right that is allowed to use the LDS API. If default credentials have been configured with SETUP NULL can be passed to use them.

  • geom: GEOMETRY(4326) input point for which to obtain the address.

  • language: STRING|NULL language in which results should be returned. Defaults to ''. The effect and interpretation of this parameter depends on the LDS provider assigned to your account.

  • options: STRING|NULL containing a valid JSON with the different options. No options are allowed currently, so this value will not be taken into account.

Return type

STRING

Examples

ISOLINE

circle-exclamation

Description

Calculates the isoline polygon from a given point.

  • api_base_url: STRING|NULL url of the API where the customer account is stored. If default credentials have been configured with SETUP NULL can be passed to use them.

  • api_access_token: STRING|NULL an API Access Tokenarrow-up-right that is allowed to use the LDS API. If default credentials have been configured with SETUP NULL can be passed to use them.

  • origin: GEOMETRY(4326) origin point for the isoline.

  • mode: STRING type of transport. The supported modes depend on the provider:

    • HERE: 'walk', 'car', 'truck', 'taxi', 'bus', 'private_bus'.

    • TomTom: 'walk', 'car', 'bike', 'motorbike', 'truck', 'taxi', 'bus', 'van'.

    • TravelTime: 'walk', 'car', 'bike', 'public_transport', 'coach', 'bus', 'train', 'ferry'.

    • Mapbox: 'walk', 'car', 'bike'.

  • range_value: INT range of the isoline in seconds (for range_type 'time') or meters (for range_type 'distance').

  • range_type: STRING type of range. Supported: 'time' (for isochrones), 'distance' (for isodistances).

  • options STRING|NULL containing a valid JSON with the different options. Valid options are described in the table below. If no options are indicated then 'default' values would be applied.

    Provider
    Option
    Description

    HERE

    arrival_time

    A STRING that specifies the time of arrival. If the value is set, a reverse isoline is calculated. If set to "any", then time-dependent effects will not be taken into account. It cannot be used in combination with departure_time. Supported: "any", "now" and date-time as "<YYYY-MM-DD>T<hh:mm:ss>".

    HERE

    departure_time

    Default: "now". A STRING that specifies the time of departure. If set to "any", then time-dependent effects will not be taken into account. It cannot be used in combination with arrival_time. Supported: "any", "now" and date-time as "<YYYY-MM-DD>T<hh:mm:ss>".

    HERE

    optimize_for

    Default: "balanced". A STRING that specifies how isoline calculation is optimized. Supported: "quality", "performance" and "balanced".

    HERE

    routing_mode

    Default: "fast". A STRING that specifies which optimization is applied during isoline calculation. Supported: "fast" and "short".

    TomTom

    departure_time

    Default: "now". A STRING that specifies the time of departure. If set to "any", then time-dependent effects will not be taken into account. Supported: "any", "now" and date-time as "<YYYY-MM-DD>T<hh:mm:ss>".

    TomTom

    traffic

    Default: true. A BOOLEAN that specifies if all available traffic information will be taken into consideration. Supported: true and false.

    TravelTime

    level_of_detail

    A JSON string for setting polygon detail level. Check the TravelTime docs for more info.

    TravelTime

    departure_time

    Default: "now". A STRING that specifies the time of departure. Supported: "now" and date-time as "<YYYY-MM-DD>T<hh:mm:ss>Z".

circle-exclamation

Return type

GEOMETRY(4326)

Examples

GET_LDS_QUOTA_INFO

Description

Returns statistics about the LDS quota. LDS quota is an annual quota that defines how much geocoding and isolines you can compute. Each geocoded row or computed isolines counts as one LDS quota unit. The single element in the result of GET_LDS_QUOTA_INFO will show your LDS quota for the current annual period (annual_quota), how much you've spent (used_quota), and which LDS providers are in use.

  • api_base_url: STRING|NULL url of the API where the customer account is stored. If default credentials have been configured with SETUP NULL can be passed to use them.

  • api_access_token: STRING|NULL an API Access Tokenarrow-up-right that is allowed to use the LDS API. If default credentials have been configured with SETUP NULL can be passed to use them.

Return type

STRING

Example

CREATE_H3_ISOLINES

circle-exclamation
circle-exclamation

Description

Calculates H3 isolines (isochrones represented as H3 cells) from given origins (points) in a table or query. Unlike the standard CREATE_ISOLINES procedure which returns polygon geometries, this procedure returns H3 cells with travel time information.

It creates a new table with the columns of the input table (except the geometry column), with each H3 cell unnested into a separate row containing h3, h3_min, h3_max, and h3_mean as scalar values. It calculates H3 isolines sequentially in batches, with the batch size optimized for the specific LDS provider that you are using.

The output table will contain a column named carto_isoline_metadata with error information for each H3 isoline result. Rows with errors will have NULL values in the H3 columns.

  • api_base_url: STRING|NULL url of the API where the customer account is stored. If default credentials have been configured with SETUP NULL can be passed to use them.

  • api_access_token: STRING|NULL an API Access Tokenarrow-up-right that is allowed to use the LDS API. If default credentials have been configured with SETUP NULL can be passed to use them.

  • input_table: STRING name of the input table or query.

  • output_table: STRING name of the output table. It will raise an error if the table already exists.

  • geom_column: STRING|NULL column name for the origin geometry column. Defaults to 'geom'. Set to NULL to use the default value.

  • mode: STRING type of transport. Supported modes for TravelTime: 'walk', 'car', 'bike', 'public_transport', 'coach', 'bus', 'train', 'ferry'.

  • range_value: INT range of the isoline in seconds (for range_type 'time') or meters (for range_type 'distance'). Valid range for time: 60-36000 (1 minute to 10 hours).

  • range_type: STRING type of range. Currently only 'time' is supported for H3 isolines.

  • resolution: INT H3 resolution level for the output cells. Valid range: 6-12.

  • options: STRING|NULL containing a valid JSON with the different options. In addition to provider-specific options described below, you can specify batch_size to control the number of points processed per batch (subject to provider limits). Valid options are described in the table below. If no options are indicated then 'default' values would be applied.

    Provider
    Option
    Description

    TravelTime

    level_of_detail

    A JSON string. In the most typical case, you will want to use a string in the form { scale_type: 'simple_numeric', level: -N }, with N being the detail level (-8 by default). Higher Ns (more negative levels) will simplify the results more but will reduce performance. Check the TravelTime docsarrow-up-right for more info.

    TravelTime

    departure_time

    Default: "now". A STRING that specifies the time of departure. Supported: "now" and date-time as "<YYYY-MM-DD>T<hh:mm:ss>Z".

Output Table Schema

The output table will contain all columns from the input table except geom_column, with each H3 cell as a separate row:

Column
Type
Description

h3

STRING

H3 cell index.

h3_min

INT

Minimum travel time in seconds for this H3 cell.

h3_max

INT

Maximum travel time in seconds for this H3 cell.

h3_mean

INT

Average travel time in seconds for this H3 cell.

carto_isoline_metadata

STRING

Error information, or NULL if successful.

Examples

CREATE_ROUTING_MATRIX

circle-exclamation

Description

Calculates the routes (line strings) between given origins and destinations (points) in two tables or queries. It creates a new table with the cross join of the origin and destination geom columns adding the distance or time between the different routes. A carto_routing_matrix_metadata column will also be added containing potential errors thrown by the service provider for particular origin-destination combinations.

Note that routes are calculated using the external LDS provider assigned to your CARTO account. Currently TomTom and TravelTime are supported.

  • api_base_url: STRING|NULL url of the API where the customer account is stored. If default credentials have been configured with SETUP NULL can be passed to use them.

  • api_access_token: STRING|NULL an API Access Tokenarrow-up-right that is allowed to use the LDS API. If default credentials have been configured with SETUP NULL can be passed to use them.

  • origins_table: STRING name of the origins input table or query.

  • origins_geom_column: STRING column name for the origin geometry column.

  • destinations_table: STRING name of the destinations input table or query.

  • destinations_geom_column: STRING column name for the destination geometry column.

  • output_table: STRING name of the output table. It will raise an error if the table already exists.

  • geom_column: STRING column name for the generated geography column that will contain the resulting routes.

  • mode: STRING type of transport. The supported modes depend on the provider:

    • TomTom: 'car', 'truck', 'pedestrian'.

    • TravelTime: 'cycling', 'driving', 'driving+train', 'driving+public_transport', 'public_transport', 'walking', 'coach', 'bus', 'train', 'ferry', 'driving+ferry', 'cycling+ferry', 'cycling+public_transport'.

  • options: STRING|NULL containing a valid JSON with optional parameters. This is intended for advanced use: additional parameters can be passed directly to the Routing provider by placing them in this JSON string. To find out what your provider is, check the GET_LDS_QUOTA_INFO function. The following are some of the most common parameters for each provider:

    Provider
    Option
    Description

    TomTom

    avoid

    Default: []. An ARRAY that specifies something that the route calculation should try to avoid when determining the route. Supported: ["tollRoads"], ["unpavedRoads"].

    TomTom

    departAt

    Default: "any". A STRING that specifies the time of departure. Supported: "now", "any" and date-time as "<YYYY-MM-DD>T<hh:mm:ss>".

    TomTom

    routeType

    Default: "fastest". A STRING that specifies the type of optimization used when calculating routes. Supported: "fastest", "shortest".

    TomTom

    traffic

    Default: historical. A STRING that decides how traffic is considered for computing routes. Supported: historical and live. live may not be used in conjunction with departAt=any.

    TomTom

    vehicleMaxSpeed

    Default: 0. A NUMBER that specifies the maximum speed of the vehicle in kilometers/hour. Supported: a value in the range [0, 250]. A value of 0 means that an appropriate value for the vehicle will be determined and applied during route planning.

    TravelTime

    departure_time

    Default: "now". A STRING that specifies the time of departure. Supported: "now" and date-time as "<YYYY-MM-DD>T<hh:mm:ss>Z".

    TravelTime

    travel_time

    Default: 14400 (4 hours). A NUMBER that specifies the maximum travel time in seconds. Supported: a value in the range [0, 14400].

    For more advanced usage, check the documentation of your provider's matrix routing API.

    The following are options provided by CARTO in order to adjust the procedure performance:

    Option
    Description

    carto_origins_batch_size

    Default: TomTom: 100, TravelTime: 1. Max: TomTom: 10000, TravelTime: 10. A NUMBER that specifies the number of origins rows to process in each batch. Increasing this value in the case of Traveltime can cause some origins-destinations combinations to be skipped when the origin is not found.

    carto_destinations_batch_size

    Default: TomTom: 100, TravelTime: 2000. Max: TomTom: 10000, TravelTime: 2000. A NUMBER that specifies the number of destinations rows to process in each batch.

    In the case of TomTom the next requirements must be met:

    • If departAt=now or departAT=dateTime then:

      • The size of the matrix should not be larger than 2500.

      • The number of origins should not be larger than 1000.

      • The number of destinations should not be larger than 1000.

      • The bounding box should not be larger than 400km X 400km. Example: 2X1000, 5X500, 100X25, etc.

    • If departAt=any then:

      • The size of the matrix can be as large as 100M.

      • The number of origins should not be larger than 10000.

      • The number of destinations should not be larger than 10000.

circle-exclamation
circle-exclamation

Return type

The results are stored in the table named <output_table>, which contains the following columns:

  • origin_geom: STRING the origin geometry.

  • destination_geom: STRING the destination geometry.

  • route_distance: INT the distance of the route in meters.

  • route_duration: INT the duration of the route in seconds.

  • carto_routing_matrix_metadata: STRING possible errors thrown by the service provider for particular origin-destination combinations.

When generating the output table origin-destination combinations, duplicated or null geometries will not be processed.

circle-exclamation

Examples

Example with options:

H3_ISOLINE

circle-exclamation
circle-exclamation

Description

Calculates H3 isolines (isochrones represented as H3 cells) from a given point. Unlike the standard ISOLINE function which returns a polygon geometry, this function returns an array of H3 cells with travel time information for each cell.

  • api_base_url: STRING url of the API where the customer account is stored. If default credentials have been configured with SETUP an empty string '' can be passed to use them.

  • api_access_token: STRING an API Access Tokenarrow-up-right that is allowed to use the LDS API. If default credentials have been configured with SETUP an empty string '' can be passed to use them.

  • origin: GEOMETRY(4326) origin point of the isoline.

  • mode: STRING type of transport. Supported modes for TravelTime: 'walk', 'car', 'bike', 'public_transport', 'coach', 'bus', 'train', 'ferry'.

  • range_value: INT range of the isoline in seconds (for range_type 'time') or meters (for range_type 'distance'). Valid range for time: 60-36000 (1 minute to 10 hours).

  • range_type: STRING type of range. Currently only 'time' is supported for H3 isolines.

  • resolution: INT H3 resolution level for the output cells. Valid range: 6-12.

  • options: STRING|NULL containing a valid JSON with the different options. Valid options are described in the table below. If no options are indicated then 'default' values would be applied.

    Provider
    Option
    Description

    TravelTime

    level_of_detail

    A JSON string. In the most typical case, you will want to use a string in the form { scale_type: 'simple_numeric', level: -N }, with N being the detail level (-8 by default). Higher Ns (more negative levels) will simplify the results more but will reduce performance. Check the TravelTime docsarrow-up-right for more info.

    TravelTime

    departure_time

    Default: "now". A STRING that specifies the time of departure. Supported: "now" and date-time as "<YYYY-MM-DD>T<hh:mm:ss>Z".

Return type

ARRAY<STRUCT<h3: STRING, h3_min: INT, h3_max: INT, h3_mean: INT>>

Each element in the array is a struct representing an H3 cell within the isochrone:

Field
Type
Description

h3

STRING

H3 cell index.

h3_min

INT

Minimum travel time in seconds to reach this H3 cell.

h3_max

INT

Maximum travel time in seconds to reach this H3 cell.

h3_mean

INT

Average travel time in seconds to reach this H3 cell.

Constraints

This function performs requests to the CARTO Location Data Services API. Databricks makes parallel requests depending on the number of records you are processing, potentially hitting the limit of the number of requests per seconds allowed for your account. To avoid this error, please try processing smaller volumes of data or use the CREATE_H3_ISOLINES procedure instead.

Examples

Last updated

Was this helpful?