-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.py
More file actions
27 lines (19 loc) · 728 Bytes
/
helpers.py
File metadata and controls
27 lines (19 loc) · 728 Bytes
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
import pyproj
import numpy
wgs84 = pyproj.Geod(ellps="WGS84")
def geodesic_length(geom):
return wgs84.geometry_length(geom)
def geodesic_area(geom):
return abs(wgs84.geometry_area_perimeter(geom)[0])
def geodesic_perimeter(geom):
return wgs84.geometry_area_perimeter(geom)[1]
def proj(from_crs, to_crs):
if type(from_crs) is int:
from_crs = "EPSG:" + str(from_crs)
if type(to_crs) is int:
to_crs = "EPSG:" + str(to_crs)
transformer = pyproj.Transformer.from_crs(pyproj.CRS(from_crs), pyproj.CRS(to_crs), always_xy=True)
def wrapper(coords):
new_coords = transformer.transform(coords[:, 0], coords[:, 1])
return numpy.array(new_coords).T
return wrapper