Creating Spatial Entities
Learn how to create spatial entities and other methods for constructing different types of geometries in MySQL.
We'll cover the following
MySQL’s support for spatial data is based on the OpenGIS geometry model, which outlines a hierarchical structure of spatial entities. The database system offers a range of corresponding types for these entities, allowing us to work with various geometric shapes. These types are particularly useful for defining spatial data structure, such as the e-scooter business in Berlin that we’ve used as an example in previous lessons.
One of the functions provided by MySQL for working with spatial data is ST_GeomFromText()
. This function allows us to create a spatial entity by passing a string that defines one of the OpenGIS counterparts. For instance, we have already seen how to create POLYGON
geometries using this function, which can restrict parking zones for our startup’s e-scooters.
However, POLYGON
is just one of the many spatial entities that MySQL can create. There are several other methods for constructing different types of geometries, which we have not yet explored. As we move forward, we will examine these methods’ benefits and limitations to better understand how they can enhance our spatial data handling in MySQL.
Points
Like the ST_GeomFromText()
function we’ve used before, MySQL offers ST_PointFromText()
specifically for creating POINT
geometries from string input. This function has already proven useful previously when we created the locations for our startup’s e-scooters:
Get hands-on with 1400+ tech skills courses.