Expression: 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.
GeoDist(latitude1, longitude1, latitude2, longitude2, [units])
|
GeoNearest |
Returns index of point nearest to reference point. Latitude and longitude specified in decimal degrees. Index is 1-based.
GeoDist(referenceLatitude, referenceLongitude, latitude1, longitude1, latitude2, longitude2 ...)
|
GeoDistMin |
Returns distance to nearest point from reference point. Latitude and longitude specified in decimal degrees. Optional Units parameter starts with m for miles (default) or k for km.
GeoDistMin(referenceLatitude, referenceLongitude, latitude1, longitude1, latitude2, longitude2, ..., [Units])
|
GeoDistNth |
Returns the distance in miles to the Nth nearest to a lat/long reference. This is determined by the first parameter in the expression.
GeoDistNth(Number, ReferenceLatitude, ReferenceLongitude,, Latitude1, Longitude1, Latitude2, Longitude2, ...)
GeoDistNth([Postcode Latitude],[Postcode Longitude],2,51.47,-0.45,52.45,-1.74,55.95,-3.36) - will find the distance to the 2nd nearest lat/long in the list.
|
GeoNth |
Returns the index of the point Nth nearest to a lat/long reference point. This is determined by the first parameter in the expression.
GeoNth(Number, ReferenceLatitude, ReferenceLongitude, Latitude1, Longitude1, Latitude2, Longitude2 ...) - where (ReferenceLatitude, ReferenceLongitude) is a reference point (Latitude1, Longitude1), (Latitude2, Longitude2) etc. are test points.
Points can also be specified from numeric lists for latitude and longitude which have the same number of points.
GeoNth([Postcode Latitude],[Postcode Longitude],2,51.47,-0.45,52.45,-1.74,55.95,-3.36) - will find the 2nd nearest lat/long in the list.
|
GeoPointInArea |
Returns whether the reference point is in the polygon specified by the other coordinates.
GeoPointInArea(ReferenceLatitude, ReferenceLongitude, Latitude1, Longitude1, Latitude2, Longitude2 ...) - where Latitude and longitude (East positive) are specified in decimal degrees and Index is 1-based.
The first two parameters can be variables, but all other parameters must be fixed numeric values. Points can also be specified from numeric lists for latitude and longitude which have the same number of points.
e.g. GeoPointInArea([Latitude], [Longitude], 52.3553, -2.0720, 52.3486, -1.8120, 52.4784, -1.7113, 52.5527, -1.9696)
|
UKPostcode |
Returns position information for the middle point of a given UK postcode
UKPostcode("CV34 4EH", "Valid") returns 1 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
|
UKPostcodeDistance |
Returns the distance (in miles) between two UK postcodes
UKPostcodeDistance("CV34 4EH", "SW1A 1AA") 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
UKPostcodeDistMin("CV34 4EH", "SW1A 1AA","EH99 1SP", "CF99 1NA") 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
UKPostcodeDistMin("CV34 4EH", "SW1A 1AA","EH99 1SP", "CF99 1NA") 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
|
UKPostcodeFormat |
Returns part of a given UK postcode
UKPostcodeFormat("CV34 4EH", "Area") returns CV 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
|
UKPostcodeNth |
Returns the 1-based index of the point that is the Nth nearest to the reference point.
UKPostcodeNth(N, ReferencePostcode, Postcode1 [, Postcode2, ...])
Points can also be specified from text lists for postcodes The distances are calculated as straight lines between the postcode centroids.
e.g. To find a person's 2nd nearest store... UKPostcodeNth(2, [postcode], "CV34 4EH", "SK7 2PX", "SWIA 0AA") - returns 1 if CV34 4EH is the 2nd nearest location to the current record.
|
UKPostcodeDistNth |
Calculates and returns the straight line distance between the reference point and the Nth nearest point from the list.
UKPostcodeDistNth(N, ReferencePostcode, Postcode1 [, Postcode2, ...])
Points can also be specified from text lists for postcodes. The distances are calculated as straight lines between the postcode centroids in miles.
UKPostcodeDistNth(2,[Postcode],”EX38 8LH”, “CV34 4EH”,”M90 1QX”) - this example will find the distance to the 2nd nearest postcode in the list
|