Skip to content

Location functions

These functions allow you to use latitude and longitude to calculate distance as well as selecting parts of UK postcodes.

GeoDist

Calculates the straight line distance between two points.

Expression
GeoDist(latitude1, longitude1, latitude2, longitude2, [units])

Latitude and longitude specified in decimal degrees. Optional Units parameter starts with m for miles (default) or k for km.

GeoDistMin

Returns distance to nearest point from reference point.

Expression
GeoDistMin(referenceLatitude, referenceLongitude, latitude1, longitude1, latitude2, longitude2, ..., [Units])

Latitude and longitude specified in decimal degrees. Optional Units parameter starts with m for miles (default) or k for km.

GeoNearest

Returns index of point nearest to reference point.

Expression
GeoDist(referenceLatitude, referenceLongitude, latitude1, longitude1, latitude2, longitude2 ...)

Latitude and longitude specified in decimal degrees. Index is 1-based.

UKPostcode

Returns position information for the middle point of a given UK postcode.

Expression
UKPostcode("CV34 4EH", "Valid")

The above expression returns 1.

Other examples:

  • UKPostcode("CV34 4EH", "Latitude") returns 52.2813
  • UKPostcode("CV34 4EH", "Longitude") returns -1.5854
  • UKPostcode("CV34 4EH", "Easting") returns 428278
  • UKPostcode("CV34 4EH", "Northing") returns 264918

CV34 4EH is a valid postcode and has a latitude and longitude of 52.2813, -1.5854 and an Ordinance Survey all numeric grid reference of 428278,264918.

UKPostcodeFormat

Returns part of a given UK postcode

Expression
UKPostcodeFormat("CV34 4EH", "Area")

The above expression returns CV.

Other examples:

  • UKPostcodeFormat ("CV34 4EH", "District") returns CV34
  • UKPostcodeFormat ("CV34 4EH", "Sector") returns CV34 4
  • UKPostcodeFormat ("CV34 4EH", "Outward") returns CV34
  • UKPostcodeFormat ("CV34 4EH", "Inward") returns 4EH
  • UKPostcodeFormat("CV34 4EH", "Postcode") returns CV34 4EH

UKPostcodeDistance

Returns the distance (in miles) between two UK postcodes.

Expression
UKPostcodeDistance("CV34 4EH", "SW1A 1AA")

The above expression returns 82.05.

The distance between CV34 4EH and SW1A 1AA "as the crow flies" is 82.05 miles.

UKPostcodeDistMin

Returns the distance (in miles) between the first, reference, UK postcode and the nearest other UK postcode specified.

Expression
UKPostcodeDistMin("CV34 4EH", "SW1A 1AA","EH99 1SP", "CF99 1NA")

The above expression returns 82.05.

The distance between CV34 4EH and SW1A 1AA "as the crow flies" is 82.05 miles, between CV34 4EH and EH99 1SP is 261.81 miles and between CV34 4EH and CF99 1NA is 87.91 miles. Therefore 82.05 is the smallest distance.

UKPostcodeNearest

Returns the index of the UK postcode that has the smallest distance between itself and the first, reference, UK postcode.

Expression
UKPostcodeDistMin("CV34 4EH", "SW1A 1AA","EH99 1SP", "CF99 1NA")

The above expression returns 1.

The distance between CV34 4EH and SW1A 1AA "as the crow flies" is 82.05 miles, between CV34 4EH and EH99 1SP is 261.81 miles and between CV34 4EH and CF99 1NA is 87.91 miles. Therefore the first postcode after the reference postcode is the nearest.