forked from gisalgs/geom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransforms.py
56 lines (44 loc) · 1.35 KB
/
transforms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
A Python program for the sinusoidal and equirectangular projections.
Change history
October 2018
Replace numtp with math
Contact:
Ningchuan Xiao
The Ohio State University
Columbus, OH
"""
__author__ = "Ningchuan Xiao <[email protected]>"
from math import cos, radians
def transform_sinusoidal(lon, lat, lon0=0):
"""
Returns the transformation of lon and lat on the Sinusoidal projection.
Input
lon: longitude in degrees
lat: latitude in degrees
lon0: central meridian in degrees
Output
x: x coordinate (origin at 0,0)
y: y coordinate (origin at 0,0)
"""
lon1 = lon-lon0
x = lon1 * cos(radians(lat))
y = lat
return x, y
def transform_equirectangular(lon, lat, lat0=0):
"""
Returns the transformation of lon and lat on the equirectangular projection,
a.k.a. the equidistant cylindrical projection, geographic projection, or la
carte parallelogrammatique projection. It is a special case of the plate carree
projection
Input
lon: longitude in degrees
lat: latitude in degrees (will not be used)
lat0: standard parallel in degrees (true scale)
Output
x: x coordinate (origin at 0,0)
y: y coordinate (origin at 0,0)
"""
x = lon * cos(radians(lat0))
y = lat
return x, y