
Analytics Toolbox for Redshift
lds
This module contains functions and procedures that make use of location data services, such as geocoding, reverse geocoding and isolines computation.
GEOCODE
Description
Geocodes an address into a point with its geographic coordinates (latitude and longitude).
address
:VARCHAR(MAX)
input address to geocode.country
(optional):VARCHAR
name of the country in ISO 3166-1 alpha-2. Defaults to''
.
Return type
GEOMETRY
Constraints
This function performs requests to the CARTO Location Data Services API. Redshift 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. The payload size of these requests depends on the number of records and could cause a timeout in the external function, with the error message External function timeout
. The limit is around 500 records but could vary with the provider. To avoid this error, please try geocoding smaller volumes of data or using the procedure GEOCODE_TABLE
instead. This procedure manages concurrency and payload size to avoid exceeding this limit.
Examples
|
|
|
|
|
|
GEOCODE_REVERSE
Description
Performs a reverse geocoding of the point received as input.
geom
:GEOMETRY
input point to obtain the address.
Return type
VARCHAR(MAX)
Constraints
This function performs requests to the CARTO Location Data Services API. Redshift 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. The payload size of these requests depends on the number of records and could cause a timeout in the external function, with the error message External function timeout
. The limit is around 500 records but could vary with the provider. To avoid this error, please try processing smaller volumes of data.
Example
|
|
GEOCODE_TABLE
Description
Geocodes an input table by adding a column geom
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 sequentially the table in chunks of 100.
input_table
:VARCHAR(MAX)
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
:VARCHAR(MAX)
name of the column from the input table that contains the addresses to be geocoded.geom_column
(optional):VARCHAR(MAX)
column name for the geometry column. Defaults to'geom'
.country
(optional):VARCHAR(MAX)
name of the country in ISO 3166-1 alpha-2. Defaults to''
.
If the input table already contains a geometry column with the name geom_column
, only those rows with NULL values will be geocoded.
Examples
|
|
|
|
|
|
|
|
ISOLINE
Description
Calculates the isoline polygon from a given point.
origin
:GEOMETRY
of the origin of the isoline.mode
:VARCHAR(MAX)
of the type of transport. Supported: ‘walk’, ‘car’.range
:INT
range of the isoline in seconds (forrange_type
‘time’) or meters (forrange_type
‘distance’).range_type
:VARCHAR(MAX)
of the range type. Supported: ‘time’ (for isochrones), ‘distance’ (for isodistances).
Return type
GEOMETRY
Constraints
This function performs requests to the CARTO Location Data Services API. Redshift 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. The payload size of these requests depends on the number of records and could cause a timeout in the external function, with the error message External function timeout
. The limit is around 500 records but could vary with the provider. To avoid this error, please try processing smaller volumes of data.
Examples
|
|
LDS_QUOTA_INFO
Description
Returns statistics about the usage of Location Data Services for the user account, including the monthly and consumed quota for both geocoding and isolines services and their associated provider.
Return type
VARCHAR(MAX)
Example
|
|