1414import kerchunk .utils
1515
1616
17- def tiff_to_zarr (urlpath , remote_options = None , target = None , target_options = None ):
17+ def tiff_to_zarr (
18+ urlpath ,
19+ remote_options = None ,
20+ target = None ,
21+ target_options = None ,
22+ inline_threshold = 0 ,
23+ storage_options = None ,
24+ ):
1825 """Wraps TIFFFile's fsspec writer to extract metadata as attributes
1926
2027 Parameters
@@ -27,14 +34,20 @@ def tiff_to_zarr(urlpath, remote_options=None, target=None, target_options=None)
2734 Write JSON to this location. If not given, no file is output
2835 target_options: dict
2936 pass these to fsspec when opening target
37+ inline_threshold: int
38+ Bytes blocks smaller than this will be inlined
39+ storage_options: dict
40+ same as remote_options, for compatibility. If both are given, remote_options wins.
3041
3142 Returns
3243 -------
3344 references dict
3445 """
3546
36- with fsspec .open (urlpath , ** (remote_options or {})) as of :
47+ with fsspec .open (urlpath , ** (remote_options or storage_options or {})) as of :
3748 url , name = urlpath .rsplit ("/" , 1 )
49+ prot = of .fs .protocol
50+ remote_protocol = prot [0 ] if isinstance (prot , tuple ) else prot
3851
3952 with tifffile .TiffFile (of , name = name ) as tif :
4053 with tif .series [0 ].aszarr () as store :
@@ -72,6 +85,10 @@ def tiff_to_zarr(urlpath, remote_options=None, target=None, target_options=None)
7285 # coords = generate_coords(meta, z.shape)
7386 # rasterio.crs.CRS.from_epsg(attrs['ProjectedCSTypeGeoKey']).to_wkt("WKT1_GDAL") ??
7487 pass
88+ if inline_threshold :
89+ out = kerchunk .utils .do_inline (
90+ out , inline_threshold , remote_options , remote_protocol
91+ )
7592 if target is not None :
7693 with fsspec .open (target , ** (target_options or {})) as of :
7794 ujson .dump (out , of )
0 commit comments