Skip to content

Commit 3b77a1a

Browse files
committed
More pyproj upgrading
1 parent 8e10681 commit 3b77a1a

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

label_maker/label.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import numpy as np
1111
import mapbox_vector_tile
12-
import pyproj
1312
from shapely.geometry import shape, mapping, Polygon
1413
from shapely.errors import TopologicalError
1514
from rasterio.features import rasterize
@@ -325,10 +324,3 @@ def _create_empty_label(ml_type, classes):
325324
elif ml_type == 'segmentation':
326325
return np.zeros((256, 256), dtype=np.int)
327326
return None
328-
329-
# Use with 'transform' to project to EPSG:4326
330-
project = partial(
331-
pyproj.transform,
332-
pyproj.Proj('epsg:3857'),
333-
pyproj.Proj('epsg:4326')
334-
)

label_maker/utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from urllib.parse import urlparse, parse_qs
55

66
from mercantile import bounds
7-
from pyproj import Proj, transform
7+
from pyproj import Proj, Transformer
88
from PIL import Image
99
import numpy as np
1010
import requests
@@ -51,6 +51,7 @@ def get_tile_tif(tile, imagery, folder, kwargs):
5151
x_res, y_res = src.transform[0], src.transform[4]
5252
p1 = Proj('epsg:4326')
5353
p2 = Proj(str(src.crs))
54+
transformer = Transformer.from_crs(p1, p2)
5455

5556
# offset our imagery in the "destination pixel" space
5657
offset_bound = dict()
@@ -63,8 +64,8 @@ def get_tile_tif(tile, imagery, folder, kwargs):
6364
offset_bound['south'] = bound.south + imagery_offset[1] * deg_per_pix_y
6465

6566
# project tile boundaries from lat/lng to source CRS
66-
tile_ul_proj = transform(p1, p2, offset_bound['west'], offset_bound['north'])
67-
tile_lr_proj = transform(p1, p2, offset_bound['east'], offset_bound['south'])
67+
tile_ul_proj = transformer.transform(offset_bound['west'], offset_bound['north'])
68+
tile_lr_proj = transformer.transform(offset_bound['east'], offset_bound['south'])
6869
# get origin point from the TIF
6970
tif_ul_proj = (src.bounds.left, src.bounds.top)
7071

@@ -108,10 +109,11 @@ def get_tile_wms(tile, imagery, folder, kwargs):
108109
bound = bounds(*[int(t) for t in tile.split('-')])
109110
p1 = Proj('epsg:4326')
110111
p2 = Proj(wms_srs)
112+
transformer = Transformer.from_crs(p1, p2)
111113

112114
# project the tile bounding box from lat/lng to WMS SRS
113-
tile_ll_proj = transform(p1, p2, bound.west, bound.south)
114-
tile_ur_proj = transform(p1, p2, bound.east, bound.north)
115+
tile_ll_proj = transformer.transform(bound.west, bound.south)
116+
tile_ur_proj = transformer.transform(bound.east, bound.north)
115117
if wms_version == '1.3.0':
116118
bbox = tile_ll_proj[::-1] + tile_ur_proj[::-1]
117119
else:

0 commit comments

Comments
 (0)