Skip to main content

Geographic Functions

Geographical functions operate on geographic input, like points, lines or polygons. The built-in geographic functions for Tableau geography values are listed below.

Tableau geography functions

FunctionDescription
tableau.geo_make_point(latitude double, longitude double)tableau.tabgeography(point)Creates a point with coordinates latitude and longitude
tableau.geo_make_line(a tableau.tabgeography(point), b tableau.tabgeography(point))tableau.tabgeography(linestring)Creates a line between a and b
tableau.geo_distance(a tableau.tabgeography(point),b tableau.tabgeography (point), unit string)doubleDistance in the WGS84 ellipsoid between points a and b expressed in unit
tableau.geo_buffer(p tableau.tabgeography(point), r double, unit string)tableau.tabgeography(polygon)120-sided polygon around point p, which is fully enclosed by circle with center in same point and radius r, where radius unit is given in unit. When radius is 0, a single point is returned (the input parameter) instead of a 120-sided polygon
tableau.geo_auto_vertex_order(arg tableau.tabgeography)tableau.tabgeographyInverts the vertex order for all polygons if they are specified in an interior-right winding order assuming flat earth to topology 4
tableau.geo_invert_vertex_order(arg tableau.tabgeography)tableau.tabgeographyInverts the vertex order of all polygons
note

Explicit use of tableau.geo_auto_vertex_order is needed and recommended only when processing extracts generated by Hyper API version v0.0.12514 or earlier. tableau.geo_auto_vertex_order is implicitly used when parsing TABLEAU.TABGEOGRAPHY values from WKT format.

Examples

To pass a tableau.tabgeography constant as an argument, it needs to be cast from a string which contains a tableau.tabgeography object formatted in the Well-known text (WKT) format defined by the Open GIS Consortium, Inc, in the OpenGIS Simple Features Specification For SQL. More examples of handling tableau.tabgeography objects using the Hyper API can be found here. Return values of type tableau.tabgeography are also shown in WKT format.

SELECT tableau.geo_make_point(20, 30);
Result: POINT(30.0000000 20.0000000)
(Note that the latitude and longitude are flipped in the result, because it is shown in the WKT format as point(longitude latitude))

SELECT tableau.geo_make_line('point(14 42)'::tableau.tabgeography,'point(18 43)'::tableau.tabgeography);
Result: LINESTRING(14.0000000 42.0000000, 18.0000000 43.0000000)

SELECT tableau.geo_distance('point(0 0)'::tableau.tabgeography, 'point(0 1)'::tableau.tabgeography, 'kilometers');
Result: 110.574391628025

SELECT tableau.geo_buffer('point(90 45)'::tableau.tabgeography, 1989.0, 'meter');
Result: POLYGON((90.0000000 45.0178977, 89.9986793 45.0178731, ..., 90.0013206 45.0178731, 90.0000000 45.0178977))

SELECT tableau.geo_invert_vertex_order('geometrycollection(polygon((0 0, 2 0, 0 4, 0 0)), polygon((0 0, 0 2, 4 0, 0 0)), point(0 2))'::tableau.tabgeography);
Result: GEOMETRYCOLLECTION(POINT(0.0000000 2.0000000), POLYGON((0.0000000 0.0000000, ..., 0.0625000 0.0000000, 0.0000000 0.0000000)))

SELECT tableau.geo_auto_vertex_order('geometrycollection(polygon((0 0, 2 0, 0 4, 0 0)), polygon((0 0, 0 2, 4 0, 0 0)), point(0 2))'::tableau.tabgeography);
Result: GEOMETRYCOLLECTION(POINT(0.0000000 2.0000000), POLYGON((0.0000000 0.0000000, ..., 0.0000000 0.0625000, 0.0000000 0.0000000)))

Supported distance units

The supported units of length are:

Unit name in American spellingOther supported spellingsDescription
metermetre, m, meters, metresBase unit of length in International System of Units (SI)
kilometerkilometre, km, kilometers, kilometresEqual to 1000 meters
milemi, milesEqual to 1609.344 meters
footft, feetEqual to 0.3048 meters