PyMySQL
The popular MySQL (available at http://dev.mysql.com/downloads) database system is gradually evolving spatial functions. It has support for OGC geometries and a few spatial functions. It also has a pure Python API available in the PyMySQL
library. The limited spatial functions use planar geometry and bounding rectangles as opposed to spherical geometry and shapes. The latest development release of MySQL contains some additional functions that improve this capability.
In the following example, we’ll create a database in MySQL called spatial_db
. Then, we’ll add a table called PLACES
with a geometry column. Next, we’ll add two cities as point locations. Finally, we’ll calculate the distance using MySQL’s ST_Distance
function and then convert the result from degrees into miles. In order to perform this example, you’ll have to install MySQL following the instructions on the download site.
First, we will import our mysql
library and...