cs_lang:python:things-to-know:geographic
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
cs_lang:python:things-to-know:geographic [2012/06/20 11:18] – cedric | cs_lang:python:things-to-know:geographic [2012/06/20 11:21] (current) – cedric | ||
---|---|---|---|
Line 11: | Line 11: | ||
""" | """ | ||
return x * (180/ | return x * (180/ | ||
+ | |||
+ | def CalcRad(lat): | ||
+ | """ | ||
+ | Radius of curvature in meters at specified latitude. | ||
+ | """ | ||
+ | a = 6378.137 | ||
+ | e2 = 0.081082 * 0.081082 | ||
+ | # the radius of curvature of an ellipsoidal Earth in the plane of a | ||
+ | # meridian of latitude is given by | ||
+ | # | ||
+ | # R' = a * (1 - e^2) / (1 - e^2 * (sin(lat))^2)^(3/ | ||
+ | # | ||
+ | # where a is the equatorial radius, | ||
+ | # b is the polar radius, and | ||
+ | # e is the eccentricity of the ellipsoid = sqrt(1 - b^2/a^2) | ||
+ | # | ||
+ | # a = 6378 km (3963 mi) Equatorial radius (surface to center distance) | ||
+ | # b = 6356.752 km (3950 mi) Polar radius (surface to center distance) | ||
+ | # e = 0.081082 Eccentricity | ||
+ | sc = math.sin(Deg2Rad(lat)) | ||
+ | x = a * (1.0 - e2) | ||
+ | z = 1.0 - e2 * sc * sc | ||
+ | y = pow(z, 1.5) | ||
+ | r = x / y | ||
+ | |||
+ | r = r * 1000.0 | ||
+ | return r | ||
+ | |||
def EarthDistance((lat1, | def EarthDistance((lat1, | ||
Line 32: | Line 60: | ||
a = -1 | a = -1 | ||
return CalcRad((lat1+lat2) / 2) * math.acos(a) | return CalcRad((lat1+lat2) / 2) * math.acos(a) | ||
- | </ | ||
- | <code python> | ||
def MeterOffset((lat1, | def MeterOffset((lat1, | ||
""" | """ | ||
Line 46: | Line 72: | ||
dx *= -1 | dx *= -1 | ||
return (dx, dy) | return (dx, dy) | ||
- | </ | ||
- | |||
- | <code python> | ||
- | def CalcRad(lat): | ||
- | """ | ||
- | Radius of curvature in meters at specified latitude. | ||
- | """ | ||
- | a = 6378.137 | ||
- | e2 = 0.081082 * 0.081082 | ||
- | # the radius of curvature of an ellipsoidal Earth in the plane of a | ||
- | # meridian of latitude is given by | ||
- | # | ||
- | # R' = a * (1 - e^2) / (1 - e^2 * (sin(lat))^2)^(3/ | ||
- | # | ||
- | # where a is the equatorial radius, | ||
- | # b is the polar radius, and | ||
- | # e is the eccentricity of the ellipsoid = sqrt(1 - b^2/a^2) | ||
- | # | ||
- | # a = 6378 km (3963 mi) Equatorial radius (surface to center distance) | ||
- | # b = 6356.752 km (3950 mi) Polar radius (surface to center distance) | ||
- | # e = 0.081082 Eccentricity | ||
- | sc = math.sin(Deg2Rad(lat)) | ||
- | x = a * (1.0 - e2) | ||
- | z = 1.0 - e2 * sc * sc | ||
- | y = pow(z, 1.5) | ||
- | r = x / y | ||
- | |||
- | r = r * 1000.0 | ||
- | return rime.mktime(time.strptime(date_time, | ||
- | print epoch | ||
</ | </ |
cs_lang/python/things-to-know/geographic.1340183899.txt.gz · Last modified: 2012/06/20 11:18 by cedric