What is the unit of measurement used in MySQL's spatial Buffer call?
Asked Answered
K

2

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?

Keary answered 15/11, 2014 at 15:25 Comment(0)
A
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.

Acus answered 15/11, 2014 at 23:8 Comment(4)
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.Keary
Sure, if the earth were flat. :)Acus
@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.Lovell
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.Keary
A
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

Aggappora answered 24/10, 2022 at 15:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.