-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathtest_crs.py
48 lines (33 loc) · 1.24 KB
/
test_crs.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
"""Not really sure what the best way to test these are. For now, we
simply try converting things that we think should be the same and
making sure they are the same.
"""
import pytest
import fiona.crs
import rasterio.crs
import pyproj
import cartopy.crs
import watershed_workflow.crs
def epsg_harness(epsg, test_cartopy=True):
gold = watershed_workflow.crs.from_epsg(epsg)
fcrs = watershed_workflow.crs.from_fiona(fiona.crs.from_epsg(epsg))
rcrs = watershed_workflow.crs.from_rasterio(rasterio.crs.CRS.from_string(
'EPSG:{}'.format(epsg)))
ppcrs2 = watershed_workflow.crs.from_proj(pyproj.crs.CRS('EPSG:{}'.format(epsg)))
# print(f'gold: {gold}')
# print(f'fiona: {fcrs}')
# print(f'rasterio: {rcrs}')
# print(f'proj: {ppcrs2}')
assert (watershed_workflow.crs.equal(gold, fcrs))
assert (watershed_workflow.crs.equal(gold, rcrs))
assert (watershed_workflow.crs.equal(gold, ppcrs2))
if test_cartopy:
cartopy_crs = cartopy.crs.epsg(epsg)
ccrs = watershed_workflow.crs.from_cartopy(cartopy_crs)
#assert(watershed_workflow.crs.equal(gold, ccrs))
def test_default():
epsg_harness(5070)
def test_alaska():
epsg_harness(3338)
def test_latlon():
epsg_harness(4269, False)