rio-tiler 7.2.1__py3-none-any.whl → 7.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rio_tiler/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """rio-tiler."""
2
2
 
3
- __version__ = "7.2.1"
3
+ __version__ = "7.3.0"
4
4
 
5
5
  from . import ( # noqa
6
6
  colormap,
rio_tiler/utils.py CHANGED
@@ -33,7 +33,7 @@ from rasterio.warp import calculate_default_transform, transform_geom
33
33
 
34
34
  from rio_tiler.colormap import apply_cmap
35
35
  from rio_tiler.constants import WEB_MERCATOR_CRS, WGS84_CRS
36
- from rio_tiler.errors import RioTilerError
36
+ from rio_tiler.errors import InvalidFormat, RioTilerError
37
37
  from rio_tiler.types import BBox, ColorMapType, IntervalTuple, RIOResampling
38
38
 
39
39
 
@@ -133,6 +133,8 @@ def get_array_statistics(
133
133
  else:
134
134
  coverage = numpy.ones((data.shape[1], data.shape[2]))
135
135
 
136
+ coverage_pixels = numpy.count_nonzero(coverage)
137
+
136
138
  # Avoid non masked nan/inf values
137
139
  numpy.ma.fix_invalid(data, copy=False)
138
140
 
@@ -143,7 +145,7 @@ def get_array_statistics(
143
145
 
144
146
  valid_pixels = float(numpy.ma.count(data[b]))
145
147
  masked_pixels = float(numpy.ma.count_masked(data[b]))
146
- valid_percent = round((valid_pixels / data[b].size) * 100, 2)
148
+ valid_percent = round(min(valid_pixels / coverage_pixels, 1) * 100, 2)
147
149
 
148
150
  if categorical:
149
151
  out_dict = dict(zip(keys.tolist(), counts.tolist()))
@@ -588,24 +590,30 @@ def render(
588
590
  }
589
591
  output_profile.update(creation_options)
590
592
 
591
- with warnings.catch_warnings():
592
- warnings.filterwarnings(
593
- "ignore",
594
- category=NotGeoreferencedWarning,
595
- module="rasterio",
596
- )
597
- with MemoryFile() as memfile:
598
- with memfile.open(**output_profile) as dst:
599
- dst.write(data, indexes=list(range(1, count + 1)))
593
+ try:
594
+ with warnings.catch_warnings():
595
+ warnings.filterwarnings(
596
+ "ignore",
597
+ category=NotGeoreferencedWarning,
598
+ module="rasterio",
599
+ )
600
+ with MemoryFile() as memfile:
601
+ with memfile.open(**output_profile) as dst:
602
+ dst.write(data, indexes=list(range(1, count + 1)))
603
+
604
+ # Use Mask as an alpha band
605
+ if mask is not None:
606
+ if ColorInterp.alpha not in dst.colorinterp:
607
+ dst.colorinterp = *dst.colorinterp[:-1], ColorInterp.alpha
600
608
 
601
- # Use Mask as an alpha band
602
- if mask is not None:
603
- if ColorInterp.alpha not in dst.colorinterp:
604
- dst.colorinterp = *dst.colorinterp[:-1], ColorInterp.alpha
609
+ dst.write(mask.astype(data.dtype), indexes=count + 1)
605
610
 
606
- dst.write(mask.astype(data.dtype), indexes=count + 1)
611
+ return memfile.read()
607
612
 
608
- return memfile.read()
613
+ except Exception as e:
614
+ raise InvalidFormat(
615
+ f"Could not encode array of shape ({count},{height},{width}) and of datatype `{data.dtype}` using {img_format} driver"
616
+ ) from e
609
617
 
610
618
 
611
619
  def mapzen_elevation_rgb(data: numpy.ndarray) -> numpy.ndarray:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: rio-tiler
3
- Version: 7.2.1
3
+ Version: 7.3.0
4
4
  Summary: User friendly Rasterio plugin to read raster datasets.
5
5
  Project-URL: Homepage, https://cogeotiff.github.io/rio-tiler/
6
6
  Project-URL: Documentation, https://cogeotiff.github.io/rio-tiler/
@@ -37,17 +37,19 @@ License: BSD 3-Clause License
37
37
  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
38
38
  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39
39
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
+ License-File: AUTHORS.txt
41
+ License-File: LICENSE
40
42
  Keywords: COGEO,Cloud Optimized Geotiff,STAC,rasterio,slippy-map
41
43
  Classifier: Intended Audience :: Information Technology
42
44
  Classifier: Intended Audience :: Science/Research
43
45
  Classifier: License :: OSI Approved :: BSD License
44
- Classifier: Programming Language :: Python :: 3.8
45
46
  Classifier: Programming Language :: Python :: 3.9
46
47
  Classifier: Programming Language :: Python :: 3.10
47
48
  Classifier: Programming Language :: Python :: 3.11
48
49
  Classifier: Programming Language :: Python :: 3.12
50
+ Classifier: Programming Language :: Python :: 3.13
49
51
  Classifier: Topic :: Scientific/Engineering :: GIS
50
- Requires-Python: >=3.8
52
+ Requires-Python: >=3.9
51
53
  Requires-Dist: attrs
52
54
  Requires-Dist: cachetools
53
55
  Requires-Dist: color-operations
@@ -1,4 +1,4 @@
1
- rio_tiler/__init__.py,sha256=OB3FKef6gLmJCPcAVLXOm65pGXyYbM3Woy6hlUUTb7o,192
1
+ rio_tiler/__init__.py,sha256=3yPtQUY6hUBWtEbFnbqu1Zh46mGK9Ch3eiEi72aJy7g,192
2
2
  rio_tiler/colormap.py,sha256=Ale0ToTrEKwP3JOhrySYKuQsfeeTgJT1YGBcmdssJ0k,11411
3
3
  rio_tiler/constants.py,sha256=55i-7JZDupTXZdLgxL03KsgM4lAzuGuIVP1zZKktzp0,426
4
4
  rio_tiler/errors.py,sha256=4I3i0e1FtkLX5sIX6dfhUMUj3SWWoKqkjCkSG7k5i2M,1901
@@ -10,7 +10,7 @@ rio_tiler/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  rio_tiler/reader.py,sha256=FiDQQU_v8mDk2JTxBpLmsTqaCQFOsjOw0LocasLeXjk,22721
11
11
  rio_tiler/tasks.py,sha256=tiQo24rZHBVxids40QkNInuMzDFEei08zYW3I_pkSVE,3157
12
12
  rio_tiler/types.py,sha256=wrGiiGBQ-WdzHf-lEypiH3cub7Knu_rXJw7EWZ2FAS8,1632
13
- rio_tiler/utils.py,sha256=_msIyfmDtvNnk3MGIENfGurTs2_Fb-hJ-YughEi82Rc,29507
13
+ rio_tiler/utils.py,sha256=okDKTIKitoDMefhpz3XiAZeR1JWcw9Br9BrVMlmmzxM,29858
14
14
  rio_tiler/cmap_data/__init__.py,sha256=8FtVmfpTjXlvhxQ5QesN0UC1m_B3MuF3LbGbhMC5Rw4,1039
15
15
  rio_tiler/cmap_data/accent.npy,sha256=Qde1ldOoXghe4L05v1QbVvnMA1ldwNjKWPf5xCBbmI4,1152
16
16
  rio_tiler/cmap_data/accent_r.npy,sha256=ba-GWSMSPRAcm9CGzlXJeNG4ABbBHDCV602hAWV2idc,1152
@@ -233,8 +233,8 @@ rio_tiler/mosaic/reader.py,sha256=_YBwTJwHvXOzKwpNpOmmh0F4yicyxgWo9vHyof3w_Do,96
233
233
  rio_tiler/mosaic/methods/__init__.py,sha256=tgkXM9skaTLXIm5QFoheOEznQXM97KGflcAWHfkrt1g,612
234
234
  rio_tiler/mosaic/methods/base.py,sha256=9YZJWVRwH5Fk9KO9q5CW52Q8Mf60tAJ21oM4ixEDXBo,1424
235
235
  rio_tiler/mosaic/methods/defaults.py,sha256=z34lna2wGXnAPwculjk_6hDrloqS8wzer68FFoIo7pg,6744
236
- rio_tiler-7.2.1.dist-info/METADATA,sha256=9zT-xK6xrp_qJGaYX_kweOSXuP31RpDbYomHceUfSPc,12202
237
- rio_tiler-7.2.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
238
- rio_tiler-7.2.1.dist-info/licenses/AUTHORS.txt,sha256=FCVd4Tjg-8syl0ZugCunpXER8X2-XonW2ZfllyTnRvE,158
239
- rio_tiler-7.2.1.dist-info/licenses/LICENSE,sha256=vq8Tt4KoYQT9JxAjQ4yXMmmhFYRTsBRgrOj-ao-bC5o,1517
240
- rio_tiler-7.2.1.dist-info/RECORD,,
236
+ rio_tiler-7.3.0.dist-info/METADATA,sha256=DnzEcej-GfaW0oHvzCnVfGQ2SSKgMfXe4ogrhmpyJJw,12251
237
+ rio_tiler-7.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
238
+ rio_tiler-7.3.0.dist-info/licenses/AUTHORS.txt,sha256=FCVd4Tjg-8syl0ZugCunpXER8X2-XonW2ZfllyTnRvE,158
239
+ rio_tiler-7.3.0.dist-info/licenses/LICENSE,sha256=vq8Tt4KoYQT9JxAjQ4yXMmmhFYRTsBRgrOj-ao-bC5o,1517
240
+ rio_tiler-7.3.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.26.3
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any