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.
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.
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.
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.
The above expression returns 1.
Other examples:
UKPostcode("CV34 4EH", "Latitude")returns 52.2813UKPostcode("CV34 4EH", "Longitude")returns -1.5854UKPostcode("CV34 4EH", "Easting")returns 428278UKPostcode("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
The above expression returns CV.
Other examples:
UKPostcodeFormat ("CV34 4EH", "District")returns CV34UKPostcodeFormat ("CV34 4EH", "Sector")returns CV34 4UKPostcodeFormat ("CV34 4EH", "Outward")returns CV34UKPostcodeFormat ("CV34 4EH", "Inward")returns 4EHUKPostcodeFormat("CV34 4EH", "Postcode")returns CV34 4EH
UKPostcodeDistance¶
Returns the distance (in miles) between two UK postcodes.
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.
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.
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.