Cesar
Cesar

Reputation: 1

Unreadable data in Mysql from a GeoDjango PointField

I'm using GeoDjango with MySQL. I use a models.PointField(srid=4326) object, all works fine, the data is correctly saved and retrieved from the database, but when I do a select * from table from MySQL command line, data of PointField field shows unreadable characters, instead of a POINT(x,y) form, as I expected.

Is it a normal behavior?

Upvotes: 0

Views: 407

Answers (2)

sandeepsinghnegi
sandeepsinghnegi

Reputation: 292

you can use ST_AsText for storing points

mysql> SELECT ST_Y(Point(56.7, 53.34));
+--------------------------+
| ST_Y(Point(56.7, 53.34)) |
+--------------------------+
|                    53.34 |
+--------------------------+
mysql> SELECT ST_AsText(ST_Y(Point(56.7, 53.34), 10.5));
+-------------------------------------------+
| ST_AsText(ST_Y(Point(56.7, 53.34), 10.5)) |
+-------------------------------------------+
| POINT(56.7 10.5)                          |
+-------------------------------------------+

you can refer to the link for more detail: https://dev.mysql.com/doc/refman/8.0/en/gis-point-property-functions.html

Upvotes: 0

Sean
Sean

Reputation: 341

Yes, that is normal. The data is stored in a binary format.

Try select AsText(geom) from table where 'geom' is the name of your geometry column.

Upvotes: 1

Related Questions