Distance between two Points

2,160 مرّة مشاهدة
التخطي إلى أول رسالة غير مقروءة

tomwardill

غير مقروءة،
28‏/03‏/2010، 3:45:20 م28‏/3‏/2010
إلى geodjango
I have a list of Points (and matching time data), I want to calculate
the maximum/minimum speed over the list of points.
I'm attempting to do this by doing distance/time = speed.

However,
point_a.distance(point_b)
is returning me a float, and I don't know the scale, or how to convert
this into something I can use (ideally meters).
The srs.name is 'WGS 84'

I'm knew to both geodjango, and geospatial calculations in general.

Anyone know what I'm doing wrong?
Cheers
--
Tom Wardill

Tengfei Wei

غير مقروءة،
29‏/03‏/2010، 11:41:18 ص29‏/3‏/2010
إلى geod...@googlegroups.com
the unit for speed is usually km/h or m/s in geospatial calculations based on the unit you used for time, and distance
if the unit of distance you used is in meters, if the time is hours, then you can simply transform the time to sec by doing hours*3600 = sec
; what you get will be meters/sec (m/s). if you wanna convert to km/h, you can transform your distance from meters to kilometers by doing meters/1000 = kilometers, then your speed will be kilometers/hours (km/h). hope thats wut ur asking and hope it solves ur problem.



 

--
You received this message because you are subscribed to the Google Groups "geodjango" group.
To post to this group, send email to geod...@googlegroups.com.
To unsubscribe from this group, send email to geodjango+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/geodjango?hl=en.




--
Phil Wei
1(403)389-3548
#64 Tuscany Springs Way, NW
Calgary, AB, T3L2N4
Canada

Josh Livni

غير مقروءة،
29‏/03‏/2010، 11:44:22 ص29‏/3‏/2010
إلى geod...@googlegroups.com
Hey Tom,

Short answer is distances don't make sense in decimal degrees, and you'll probably want to put your points into a projection that makes sense for your area of interest.  There are lots of projections.  If all your data is in California, you might want to use UTM zone 10N, which has  srs=26910.  If global data, and you don't care a ton about exact accuracy, and you're not near the poles, and distances aren't huge, then maybe go with 'spherical mercator', or srs=900913.  These all return meters.

Example:
point_a.transform(900913)
point_b.transform(900913)
point_a.distance(point_b) #this is in meters

Cheers,

 -Josh


Tom Wardill

غير مقروءة،
29‏/03‏/2010، 3:52:22 م29‏/3‏/2010
إلى geod...@googlegroups.com
This got it, thanks!
Is there anyway to work out which UTM zone I should apply, using the lat/longs that I have? Or is it something I have to code myself (or can it not be done?)
The spherical mercator looks accurate enough, but if I can get more accuracy without much more work, then I'll give it a try.

Thanks again for the help
Tom

Tyler Erickson

غير مقروءة،
29‏/03‏/2010، 10:42:48 م29‏/3‏/2010
إلى geod...@googlegroups.com
You might look into GeoDjango with PostGIS.  The GeoDjango docs now list support for 1.5, with which you can make distance queries on data that is stored in lat/lon WGS84.

http://docs.djangoproject.com/en/dev/ref/contrib/gis/db-api/

"Note:  PostGIS 1.5 introduced geography columns, which is limited on what geometry types distance queries are performed with. In other words, if you have geography=True in your geometry field definition you'll be allowed to peform arbitrary distance queries with your data in geodetic units of WGS84."

http://postgis.refractions.net/documentation/manual-1.5/ch04.html#PostGIS_Geography

- Tyler

luben

غير مقروءة،
30‏/03‏/2010، 5:23:43 ص30‏/3‏/2010
إلى geodjango
Each country or state usually maintains each own reference system. If
your application is restricted within a certain country then it will
be easy to find which one is used. I strongly recommend using the
local reference system since it will be more accurate and you will
have better compatibility with data from local authorities.

Here, http://www.movable-type.co.uk/scripts/latlong-vincenty.html, you
can find the mathematical and theoretical formulation of calculating
the distance in meters using WGS84. The whole process is iterative,
but not very complicated and gives good accuracy.

> > For more options, visit this group athttp://groups.google.com/group/geodjango?hl=en.

Jeremy Dunck

غير مقروءة،
30‏/03‏/2010، 10:38:33 ص30‏/3‏/2010
إلى geod...@googlegroups.com
On Tue, Mar 30, 2010 at 4:23 AM, luben
<lubensch.pro...@gmail.com> wrote:
> Each country or state usually maintains each own reference system. If
> your application is restricted within a certain country then it will
> be easy to find which one is used. I strongly recommend using the
> local reference system since it will be more accurate and you will
> have better compatibility with data from local authorities.
>
> Here, http://www.movable-type.co.uk/scripts/latlong-vincenty.html, you
> can find the mathematical and theoretical formulation of calculating
> the distance in meters using WGS84. The whole process is iterative,
> but not very complicated and gives good accuracy.

FWIW, geopy has an implementation of Vincenty in python:
http://code.google.com/p/geopy/wiki/GettingStarted#Calculating_distances

الرد على الكل
رد على الكاتب
إعادة توجيه
0 رسالة جديدة