Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.
  • Is there a ST_Distance_Sphere, ST_Distance_Spheroid equivalent function in MySQL's GeoSpatial Support?

  • If not, any way to emulate this?


  • What is the metric used in return type of GLength (length of the LineString)?

  • The manual for GLength says that GLength() is a nonstandard name. It corresponds to the OpenGIS Length() function. But I couldn't find any Docs for OpenGIS Length(). All I found was for ST_Length are they the same?


  • Also for accuracy do I need to specify the SRID(4326)? How Do I do this in MySQL?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

In a nutshell, you need to use a projection library. PostGIS uses one (PROJ.4), but MySQL doesn't.

The "ST_Distance_Sphere" like functions are much easier to implement, since the math is simpler (see Great-circle distance formulas, or other good examples). The "ST_Distance_Spheroid" like functions are more accurate (the shape of the earth is closer to a spheroid than a sphere), but are much more complicated.

GLength returns the length of the linestring, where the units are the same as the input. So if you have long/lat in degrees, then your length is in degrees, which is usually meaningless. This is typically only meaningful with a projected geometry, using something like UTM where the length units are metres. If your mapping area is small, then you should store everything in projected units, not long/lat.

As for accuracy, it is good as you want it to be (e.g., your GPS equipment). The coordinate geometry storage used with MySQL, as with most other GIS, is double precision, which should preserve any coordinate on earth within a small fraction of a millimetre.

share|improve this answer
    
Thanks for the information. I have already read the Movable Type Scripts article.. And was planning on implementing the function. My mapping area is not small. In fact I am considering the whole world. So I will have to store the data in lat/long. What do you mean by projected units? –  ThinkingMonkey Jul 16 '12 at 4:22
1  
"Projected" means coordinates projected on a Cartesian X,Y plane, like UTM, which uses projected units of metres. However projected systems only work on small segments of the earth. For the whole earth, you need WGS84 long/lat, which is sometimes called "unprojected", which makes distance calculations difficult. –  Mike T Jul 16 '12 at 5:01
    
@ThinkingMonkey also check out this question for a MySQL solution. Also, if you were thinking about using PostGIS, consider using the geography type, which is also available in MS SQL Server. –  Mike T Jul 16 '12 at 5:43
    
Pardon for the delayed reply. Thanks for the clarification on Projected Units. I have already read that MySQL presentation thanks for the link to the question though. I am already using the geography type, on MySQL. Currently it supports only Cartesian coordinate calculations. I think I am better off implementing the Haversine function myself. Thanks again for all the help. I will leave this question open for another 2 days before accepting it. :) –  ThinkingMonkey Jul 17 '12 at 13:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.