5

The Buffer call is formatted Buffer(g,d).

g is a geometry value (e.g. point, linestring, and polygon).

d is a distance.

What unit of measurement is d using? Meters? Miles? Kilometers?

James Chevalier
  • 10,604
  • 5
  • 48
  • 74

2 Answers2

7

There aren't units here, or in any of the spatial analysis functions.

These functions are commonly used with geometriy values with coordinates using degrees latitude and longitude, but the spatial capabilities can be used with data from any arbitrary grid coordinate system, and the server's capabilities don't have any awareness of the nature of the particular "space" being mapped.

The distance, then, would be in "units."

The units would be whatever units your coordinates are also using. If the coordinates are in feet, the distance is expressed in feet; if the distance is in degrees lat/long, you'd need to express the desired buffer distance in degrees.

Michael - sqlbot
  • 169,571
  • 25
  • 353
  • 427
  • 2
    Wow, that's smart. Does that mean there isn't a value to drop in there to get points within a mile of a lat/long? Something like `buffer(Point(42.20696, -72.607429), 0.07)` where `0.07` is The Magic Number. – James Chevalier Nov 15 '14 at 23:23
  • 3
    Sure, if the earth were flat. :) – Michael - sqlbot Nov 15 '14 at 23:37
  • 2
    @JamesChevalier there is in PostgreSQL with the geography type. `geography ST_Buffer(geography g1, float radius_of_buffer_in_meters);`. You really shouldn't be using GIS in MySQL. It's mainly there so it can pretend to be a real database. – Evan Carroll Aug 20 '17 at 18:40
  • 2
    Thanks @EvanCarroll - I've since moved to PostgreSQL & I use `ST_DWITHIN(geog, ST_GeographyFromText('#{path.geog}'), 25)` to get items within 25 meters of a `path` where its `geog` field is a `geography(Point,4326)` in the database. – James Chevalier Sep 15 '17 at 00:26
0

Since MySQL 8.0.26 the distance argument is set in meters for geographic geometries:

For MySQL versions that permit geographic Point geometries:

If the distance is not negative and no strategies are specified, the function returns the geographic buffer of the Point in its SRS. The distance argument must be in the SRS distance unit (currently always meters).

https://dev.mysql.com/doc/refman/8.0/en/spatial-operator-functions.html#function_st-buffer

Albion S.
  • 218
  • 2
  • 13