Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodata masking [WIP] #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions rio_rgbify/mbtiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from PIL import Image

from rasterio import transform
from rasterio.crs import CRS
from rasterio.warp import reproject, transform_bounds
try:
from rasterio.warp import RESAMPLING
Expand Down Expand Up @@ -129,9 +130,9 @@ def _tile_worker(tile):
reproject(
rasterio.band(src, 1), out,
dst_transform=toaffine,
dst_crs="init='epsg:3857'",
dst_crs=CRS({'init': 'epsg:3857'}),
resampling=RESAMPLING.bilinear)

out = np.clip(out, global_args['base_val'], (global_args['base_val'] + 256 ** 3) * global_args['interval'])
out = data_to_rgb(out, global_args['base_val'], global_args['interval'])

return tile, global_args['writer_func'](out, global_args['kwargs'].copy(), toaffine)
Expand Down Expand Up @@ -182,7 +183,7 @@ def _make_tiles(bbox, src_crs, minz, maxz):
generator of [x, y, z] tiles that intersect
the provided bounding box
'''
w, s, e, n = transform_bounds(*[src_crs, 'epsg:4326'] + bbox, densify_pts=0)
w, s, e, n = transform_bounds(*[src_crs, CRS({'init': 'epsg:4326'})] + bbox, densify_pts=0)

EPSILON = 1.0e-10

Expand Down Expand Up @@ -267,7 +268,7 @@ def __init__(self, inpath, outpath, min_z, max_z, interval=1, base_val=0, boundi
'height': 512,
'width': 512,
'count': 3,
'crs': 'EPSG:3857'
'crs': CRS({'init': 'EPSG:3857'})
},
'base_val': base_val,
'interval': interval,
Expand Down