# distance_in_meters(...)

### distance_in_meters(...)

Returns the distance between two Points in meters

Works with the following datatypes:

This function works with 2.1 endpoint(s). What does this mean? »

The distance_in_meters(...) function will return the distance, measured in meters, between two Point s. It accepts two parameters, both of which must be Points, either referenced as field names or encoded as Well-Known Text (WKT):

WKT is a standard way of encoding geospatial data in a textual manner, and is more compact than GeoJSON. For example, a Point would be encoded as:

POINT (-87.637714 41.887275)


Heads up! Contrary to the normal convention of "latitude, longitude" ordering in the coordinates property, Well-known text orders the coordinates as "longitude, latitude" (X coordinate, Y coordinate), as other GIS coordiate systems are encoded.

For example, the below query will return the distance from the Seattle Central Library to the Socrata offices:

https://data.seattle.gov/resource/3c4b-gdxv.json?city_feature=Libraries&common_name=Central&$select=DISTANCE_IN_METERS(location, 'POINT(-122.334540 47.59815)') AS range Meters not your thing? That’s easy to fix with a little math: https://data.seattle.gov/resource/3c4b-gdxv.json?city_feature=Libraries&common_name=Central&$select=DISTANCE_IN_METERS(location, 'POINT(-122.334540 47.59815)') * 3.28084 AS range_in_feet

The distance_in_meters(...) function can also be used to sort data by range. The below query will return the 5 closest dog parks to our office:

https://data.seattle.gov/resource/3c4b-gdxv.json?city_feature=Off Leash Areas&$order=distance_in_meters(location, 'POINT (-122.334540 47.59815)')&$limit=5&\$select=*, distance_in_meters(location, 'POINT (-122.334540 47.59815)') AS range