longitude valuse changing wit point

50 views
Skip to first unread message

slickrick murphy

unread,
Apr 7, 2013, 2:16:40 PM4/7/13
to rgeo-...@googlegroups.com
When creating a new point the y value is getting saved as a different value.

so - factory.point(49.186143892, 122.8010223)

is outputting - POINT (49.186143892 -85.0511287)

Any ideas?

Thanks,
Daniel

slickrick murphy

unread,
Jun 26, 2013, 5:14:23 PM6/26/13
to rgeo-...@googlegroups.com
Anyone any ideas on this?

Tyler DeWitt

unread,
Jun 26, 2013, 5:20:37 PM6/26/13
to rgeo-...@googlegroups.com
What's the definition of 'factory'?


--
You received this message because you are subscribed to the Google Groups "RGeo-Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rgeo-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Daniel Azuma

unread,
Jun 26, 2013, 5:19:39 PM6/26/13
to rgeo-...@googlegroups.com
I assume you're using a geographic (longitude-latitude) factory. If so, your coordinates are reversed. Longitude comes first, then latitude. (It makes sense: coordinates should be x,y rather than y,x)

Daniel

slickrick murphy

unread,
Jun 27, 2013, 8:59:42 AM6/27/13
to rgeo-...@googlegroups.com
Sorry I was missing the minus, so factory is simple mercator and i'm passing it in x,y

so 
new_point = factory.point(49.261569868, -122.964657378)
outputs 
POINT (49.261569868 -85.0511287)

That's for Vancouver yet if I do a Toronto lat long - 
new_point = factory.point(43.658931,-79.425659)
outputs 
POINT (43.658931 -79.425659)

which is correct. Why is Vancouver point different?

Tyler DeWitt

unread,
Jun 27, 2013, 9:33:07 AM6/27/13
to rgeo-...@googlegroups.com
I think Daniel is right and you are passing in the coordinates like we've always been told, lat/lon.  I commonly make this mistake.  Latitude actually measures the Y-axis, while longitude is the x-axis.  When creating a point with RGeo, the signature is actually POINT(lon, lat).  The -85.05 part is a result of latitude only ranging from -90 to +90 and you are providing a value of -122.96, which is an illegal latitude, but -79.42 is a legal value.

Try to reverse the coordinates and do new_point = factory.point(-122.964657378, 49.261569868) and new_point = factory.point(-79.425659, 43.658931) and you should get the results you expect. 

To convince yourself that the way you are entering the points now is backwards, check the distance between the 2 points. point1.distance(point2).  It won't be anywhere near what it should be.

I've made this mistake of lat/lon too many times to count.  

Hope that helps,
Tyler
Reply all
Reply to author
Forward
0 new messages