So i have these records in my db with lat/long. I'd like to be able to query for records that are near some specific a lat/long. So I started to look around for a solution for that and it seem to point to use mysql spatial extension.
Reading this documentation http://dev.mysql.com/doc/refman/5.0/en/mysql-spatial-datatypes.html
Is a Point correspond to lat/long? If it's not, what is it? and how do i convert it to a Point?
A Point in MySQL is a lat/long pair. I would suggest looking at this first:
http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates
Related
I have a table in mysql with geometry data in one of the columns. The datatype is text and I need to save it as Polygon geometry.
I have tried a few solutions, but keep running into Invalid GIS data provided to function st_polygonfromtext. error.
Here's some data to work with and an example:
https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=78ac63e16ccb5b1e4012c21809cba5ff
Table has 25k rows, there are likely some bad geometries in there. When I attempt to update on a subset of rows, it seems to successfully work, like it did in the fiddle example. It fails when I attempt to update all 25k rows.
Someone suggested using wrapping the statements around TRY and CATCH. Detecting faulty geometry WKT and returning the faulty record
I am not too familiar with using them in MySQL or stored procedures either.
I need a spatial index on the table to be able to use spatial functions and filter queries by location.
Plan A: Create a new table and try to convert as you INSERT IGNORE INTO that table from your existing table. I don't know if this will apply the "IGNORE" to conversion failures. Also, you would end up with the "good" values. What do you want to do about the "bad" values?
Plan B: Write a loop in application code -- read one row, convert the varchar value, check for errors.
I am trying to find an efficient way to do proximity queries, ie to return POINTs which are within a radius from a central POINT.
I understand that PostGIS's ST_DWithin method is a good way to do this in PostgreSQL and that it uses the INDEX.
I am currently using ST_Distance_Sphere(g1, g2 [, radius]) which returns the minimum spherical distance between Point on a sphere, in meters.
SELECT placeNames FROM myPlaces
WHERE ST_Distance_Sphere(placeLocation, POINT(28.861105, 77.337)) < 10000
I'm using the WHERE clause to filter the rows. Is the query using the index? If no, is there a better approach to implement the same.
I'm using MySQL 5.7.26 and 8.0.16, both running the default InnoDB database engine.
At this point in MySQL, there seems to be no 'more efficient' alternative to ST_Distance_Sphere or any other which uses a spatial index.
Firtly SRID set this query 4326 use it;
sample
SELECT ST_SetSRID(ST_MakePoint(-71.1043443253471, 42.3150676015829),4326);
I've been given some data which I am trying to import into mysql, the data was provided in a text file format which is usually fine by me - i know mssql uses different data types so a SQL dump was a none starter...
For some reason mssql must store LINESTRINGS in reverse order, which seemed very odd to me. As a result of this, when i try to upload the file with navicat the import fails. Below is an example of the LINESTRING - as you can see the longitude is first, then the latitude - this is what i believe to be the issue?
LINESTRING (-1.61674 54.9828,-1.61625 54.9828)
Does anybody know how i can get this data into my database?
Im quite new to spatial/geometry extensions.
Thanks,
Paul
must remember that the columns with spatial data have their own data type, navicat it does is call the "toString ()" or "AsText ()" event to display data, but in the background are blob, the advantage is that 2 are based on the standard WKT, I recommend that the db of origin to become space for text in the db destination takes that text and use it to "geometrifromtext" to convert the data (obviously you have to make a script with some programming language, with navicat can not do that)
info wkt
info mysql spatial
info sql server
I've been using the following mysql client in node. I have noticed for some querys(mostly nulls) I get the following string appearing("\u0001") - where I would expect NaN(if I was using mysql-native) or null.
I have also noticed it where I use booleans in my data - before anybody points out I know this is mysql so I use bits to replicate boolean data. Still I get the crazy string above being returned.
If someone could explain what this is and possibly how to get around it I would be grateful.
Thanks in advance.
My question is how to store a nested JSON as key value in mysql table. Earlier I thought of storing it as CSV but on deep diving I found it like it would be difficult to query those values and to manage as well.
Please help me in giving alternate solutions of how and where to store JSON.
The version of MySQL I am using does not support the JSON data type
If you are using MySQL 5.7, you can store ans query JSON objects. Look at this link for more details and examples.
Since MySQL 5.7 a native JSON data type is supported.
See also https://dev.mysql.com/doc/refman/5.7/en/json.html
If your MySQL version is lower the only option left is to store it as text. Otherwise you will not be able to store it in a simple key value pair manner.