Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know of a single package that both queries MySQL and handles spatial data, but <a href="http://dev.mysql.com/doc/refman/5.0/en/supported-spatial-data-formats.html" rel="nofollow">MySQL supports</a> the <a href="http://en.wikipedia.org/wiki/Well-known_text" rel="nofollow">well-known-text</a> and <a href="http://en.wikipedia.org/wiki/Well-known_text#Well-known_binary" rel="nofollow">well-known-binary</a> spatial data formats (which will allow you to store points, lines, polygons, etc).</p> <p>You would need to make a query to your MySQL using <a href="http://mysql-python.sourceforge.net/MySQLdb.html" rel="nofollow">MySQLdb</a>, fetching the data with an SQL statement (<a href="http://dev.mysql.com/doc/refman/5.0/en/fetching-spatial-data.html" rel="nofollow">examples here</a>). If all you want is the points that make up a polygon, you can do some simple string manipulation to construct an array of points:</p> <pre><code>input = "POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))" def polygon_to_points(polygon): geometry = polygon[10:-2] coordinates = geometry.split(', ') coord_pairs = [] for c in coordinates: pair = c.split(' ') pair_num = [float(pair[0]), float(pair[1])] coord_pairs.append(pair_num) return coord_pairs </code></pre> <p>This returns <code>[[30.0,10.0],[10.0,20.0],[20.0,40.0],[40.0,40.0],[30.0,10.0]]</code> as intended. If you want to do some more complex spatial querying/analysis, take a look at the <a href="https://pypi.python.org/pypi/Shapely" rel="nofollow">Shapely</a> package.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload