large-image-source-rasterio 1.27.5.dev6__tar.gz → 1.30.7.dev12__tar.gz

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.
Files changed (15) hide show
  1. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/PKG-INFO +10 -2
  2. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/README.rst +20 -40
  3. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/large_image_source_rasterio/__init__.py +105 -58
  4. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/large_image_source_rasterio.egg-info/PKG-INFO +10 -2
  5. large_image_source_rasterio-1.30.7.dev12/large_image_source_rasterio.egg-info/requires.txt +14 -0
  6. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/setup.py +6 -3
  7. large-image-source-rasterio-1.27.5.dev6/large_image_source_rasterio.egg-info/requires.txt +0 -9
  8. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/LICENSE +0 -0
  9. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/large_image_source_rasterio/girder_source.py +0 -0
  10. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/large_image_source_rasterio.egg-info/SOURCES.txt +0 -0
  11. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/large_image_source_rasterio.egg-info/dependency_links.txt +0 -0
  12. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/large_image_source_rasterio.egg-info/entry_points.txt +0 -0
  13. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/large_image_source_rasterio.egg-info/top_level.txt +0 -0
  14. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/pyproject.toml +0 -0
  15. {large-image-source-rasterio-1.27.5.dev6 → large_image_source_rasterio-1.30.7.dev12}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: large-image-source-rasterio
3
- Version: 1.27.5.dev6
3
+ Version: 1.30.7.dev12
4
4
  Summary: A rasterio tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -15,10 +15,18 @@ Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
18
19
  Requires-Python: >=3.8
20
+ Description-Content-Type: text/x-rst
21
+ License-File: LICENSE
22
+ Requires-Dist: large-image>=1.30.7.dev12
23
+ Requires-Dist: rasterio<1.3.11,>=1.3; python_version < "3.9"
24
+ Requires-Dist: rasterio>=1.3; python_version >= "3.9"
25
+ Requires-Dist: packaging
19
26
  Provides-Extra: girder
27
+ Requires-Dist: girder-large-image>=1.30.7.dev12; extra == "girder"
20
28
  Provides-Extra: all
21
- License-File: LICENSE
29
+ Requires-Dist: rio-cogeo; extra == "all"
22
30
 
23
31
  A rasterio tilesource for large_image.
24
32
 
@@ -15,7 +15,7 @@ Large Image
15
15
  :target: https://codecov.io/github/girder/large_image?branch=master
16
16
  :alt: codecov.io
17
17
 
18
- .. |doi-badge| image:: https://img.shields.io/badge/DOI-10.5281%2Fzenodo.4723355-blue
18
+ .. |doi-badge| image:: https://img.shields.io/badge/DOI-10.5281%2Fzenodo.4723355-blue.svg
19
19
  :target: https://zenodo.org/badge/latestdoi/45569214
20
20
 
21
21
  .. |pypi-badge| image:: https://img.shields.io/pypi/v/large-image.svg?logo=python&logoColor=white
@@ -39,7 +39,7 @@ Highlights
39
39
  Installation
40
40
  ------------
41
41
 
42
- In addition to installing the ``large-image`` package, you'll need at least one tile source (a ``large-image-source-xxx`` package). You can install everything from the main project with one of these commands:
42
+ In addition to installing the base ``large-image`` package, you'll need at least one tile source which corresponds to your target file format(s) (a ``large-image-source-xxx`` package). You can install everything from the main project with one of these commands:
43
43
 
44
44
  Pip
45
45
  ~~~
@@ -52,7 +52,7 @@ Install all tile sources on linux::
52
52
 
53
53
  pip install large-image[all] --find-links https://girder.github.io/large_image_wheels
54
54
 
55
- Install all tile sources and all Girder plugins on linux::
55
+ When using large-image with an instance of `Girder`_, install all tile sources and all Girder plugins on linux::
56
56
 
57
57
  pip install large-image[all] girder-large-image-annotation[tasks] --find-links https://girder.github.io/large_image_wheels
58
58
 
@@ -60,8 +60,9 @@ Install all tile sources and all Girder plugins on linux::
60
60
  Conda
61
61
  ~~~~~
62
62
 
63
- Conda makes dependency management a bit easier if not on Linux. Some of the source modules are available on conda-forge. You can install the following::
63
+ Conda makes dependency management a bit easier if not on Linux. The base module, converter module, and two of the source modules are available on conda-forge. You can install the following::
64
64
 
65
+ conda install -c conda-forge large-image
65
66
  conda install -c conda-forge large-image-source-gdal
66
67
  conda install -c conda-forge large-image-source-tiff
67
68
  conda install -c conda-forge large-image-converter
@@ -118,7 +119,7 @@ Large Image consists of several Python modules designed to work together. These
118
119
 
119
120
  - ``large-image-source-deepzoom``: A tile source for reading Deepzoom tiles.
120
121
 
121
- - ``large-image-source-dicom``: A tile source for reading DICOM WSI images.
122
+ - ``large-image-source-dicom``: A tile source for reading DICOM Whole Slide Images (WSI).
122
123
 
123
124
  - ``large-image-source-gdal``: A tile source for reading geotiff files via GDAL. This handles source data with more complex transforms than the mapnik tile source.
124
125
 
@@ -128,62 +129,41 @@ Large Image consists of several Python modules designed to work together. These
128
129
 
129
130
  - ``large-image-source-nd2``: A tile source for reading nd2 (NIS Element) images.
130
131
 
131
- - ``large-image-source-ometiff``: A tile source using the tiff library that can handle some multi-frame OMETiff files.
132
+ - ``large-image-source-ometiff``: A tile source using the tiff library that can handle most multi-frame OMETiff files that are compliant with the specification.
132
133
 
133
134
  - ``large-image-source-openjpeg``: A tile source using the Glymur library to read jp2 (JPEG 2000) files.
134
135
 
135
136
  - ``large-image-source-openslide``: A tile source using the OpenSlide library. This works with svs, ndpi, Mirax, tiff, vms, and other file formats.
136
137
 
137
- - ``large-image-source-pil``: A tile source for small images via the Python Imaging Library (Pillow).
138
+ - ``large-image-source-pil``: A tile source for small images via the Python Imaging Library (Pillow). By default, the maximum size is 4096, but the maximum size can be configured.
138
139
 
139
140
  - ``large-image-source-tiff``: A tile source for reading pyramidal tiff files in common compression formats.
140
141
 
141
142
  - ``large-image-source-tifffile``: A tile source using the tifffile library that can handle a wide variety of tiff-like files.
142
143
 
143
- - ``large-image-source-vips``: A tile source for reading any files handled by libvips. This also can be used for writing tiled images from numpy arrays.
144
+ - ``large-image-source-vips``: A tile source for reading any files handled by libvips. This also can be used for writing tiled images from numpy arrays (up to 4 dimensions).
144
145
 
145
- - ``large-image-source-zarr``: A tile source using the zarr library that can handle OME-Zarr (OME-NGFF) files as well as some other zarr files.
146
+ - ``large-image-source-zarr``: A tile source using the zarr library that can handle OME-Zarr (OME-NGFF) files as well as some other zarr files. This can also be used for writing N-dimensional tiled images from numpy arrays. Written images can be saved as any supported format.
146
147
 
147
148
  - ``large-image-source-test``: A tile source that generates test tiles, including a simple fractal pattern. Useful for testing extreme zoom levels.
148
149
 
149
- - ``large-image-source-dummy``: A tile source that does nothing.
150
+ - ``large-image-source-dummy``: A tile source that does nothing. This is an absolutely minimal implementation of a tile source used for testing. If you want to create a custom tile source, start with this implementation.
150
151
 
151
- Most tile sources can be used with girder-large-image. You can specific an extras_require of ``girder`` to include ``girder-large-image`` with the source.
152
152
 
153
- - As a Girder plugin:
153
+ As a `Girder`_ plugin, ``large-image`` adds end points to access all of the image formats it can read both to get metadata and to act as a tile server.
154
+ In the Girder UI, ``large-image`` shows images on item pages, and can show thumbnails in item lists when browsing folders.
155
+ There is also cache management to balance memory use and speed of response in Girder when ``large-image`` is used as a tile server.
154
156
 
155
- - ``girder-large-image``: Large Image as a Girder_ 3.x plugin.
156
- You can specify extras_require of ``tasks`` to install a Girder Worker task that can convert otherwise unreadable images to pyramidal tiff files.
157
+ Most tile sources can be used with Girder Large Image. You can specify an extras_require of ``girder`` to install the following packages:
157
158
 
158
- - ``girder-large-image-annotation``: Annotations for large images as a Girder_ 3.x plugin.
159
+ - ``girder-large-image``: Large Image as a Girder 3.x plugin.
160
+ You can install ``large-image[tasks]`` to install a Girder Worker task that can convert otherwise unreadable images to pyramidal tiff files.
161
+
162
+ - ``girder-large-image-annotation``: Adds models to the Girder database for supporting annotating large images. These annotations can be rendered on images. Annotations can include polygons, points, image overlays, and other types. Each annotation can have a label and metadata.
159
163
 
160
164
  - ``large-image-tasks``: A utility for running the converter via Girder Worker.
161
165
  You can specify an extras_require of ``girder`` to include modules needed to work with the Girder remote worker or ``worker`` to include modules needed on the remote side of the Girder remote worker. If neither is specified, some conversion tasks can be run using Girder local jobs.
162
166
 
163
167
 
164
- Developer Installation
165
- ----------------------
166
-
167
- To install all packages from source, clone the repository::
168
-
169
- git clone https://github.com/girder/large_image.git
170
- cd large_image
171
-
172
- Install all packages and dependencies::
173
-
174
- pip install -e . -r requirements-dev.txt
175
-
176
- If you aren't developing with Girder 3, you can skip installing those components. Use ``requirements-dev-core.txt`` instead of ``requirements-dev.txt``::
177
-
178
- pip install -e . -r requirements-dev-core.txt
179
-
180
-
181
- Tile source prerequisites
182
- =========================
183
-
184
- Many tile sources have complex prerequisites. These can be installed directly using your system's package manager or from some prebuilt Python wheels for Linux. The prebuilt wheels are not official packages, but they can be used by instructing pip to use them by preference::
185
-
186
- pip install -e . -r requirements-dev.txt --find-links https://girder.github.io/large_image_wheels
187
-
188
168
 
189
- .. _Girder: https://github.com/girder/girder
169
+ .. _Girder: https://girder.readthedocs.io/en/latest/
@@ -26,17 +26,12 @@ from importlib.metadata import version as _importlib_version
26
26
 
27
27
  import numpy as np
28
28
  import PIL.Image
29
- import rasterio as rio
30
- from affine import Affine
31
- from rasterio import warp
32
- from rasterio.enums import ColorInterp, Resampling
33
- from rasterio.errors import RasterioIOError
34
29
 
35
30
  import large_image
36
31
  from large_image.cache_util import LruCacheMetaclass, methodcache
37
32
  from large_image.constants import (TILE_FORMAT_IMAGE, TILE_FORMAT_NUMPY,
38
- TILE_FORMAT_PIL, TileInputUnits,
39
- TileOutputMimeTypes)
33
+ TILE_FORMAT_PIL, SourcePriority,
34
+ TileInputUnits, TileOutputMimeTypes)
40
35
  from large_image.exceptions import (TileSourceError,
41
36
  TileSourceFileNotFoundError,
42
37
  TileSourceInefficientError)
@@ -51,11 +46,36 @@ except PackageNotFoundError:
51
46
  # package is not installed
52
47
  pass
53
48
 
54
- warnings.filterwarnings('ignore', category=rio.errors.NotGeoreferencedWarning, module='rasterio')
55
- rio._env.code_map.pop(1, None)
49
+ rio = None
50
+ Affine = None
51
+
52
+
53
+ def _lazyImport():
54
+ """
55
+ Import the rasterio module. This is done when needed rather than in the
56
+ module initialization because it is slow.
57
+ """
58
+ global Affine, rio
59
+
60
+ if rio is None:
61
+ try:
62
+ import affine
63
+ import rasterio as rio
64
+ import rasterio.warp
65
+
66
+ Affine = affine.Affine
67
+
68
+ warnings.filterwarnings(
69
+ 'ignore', category=rio.errors.NotGeoreferencedWarning, module='rasterio')
70
+ rio._env.code_map.pop(1, None)
71
+ except ImportError:
72
+ msg = 'rasterio module not found.'
73
+ raise TileSourceError(msg)
56
74
 
57
75
 
58
76
  def make_crs(projection):
77
+ _lazyImport()
78
+
59
79
  if isinstance(projection, str):
60
80
  return rio.CRS.from_string(projection)
61
81
  if isinstance(projection, dict):
@@ -87,6 +107,8 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
87
107
  """
88
108
  # init the object
89
109
  super().__init__(path, **kwargs)
110
+ _lazyImport()
111
+ self.addKnownExtensions()
90
112
 
91
113
  # create a thread lock
92
114
  self._getDatasetLock = threading.RLock()
@@ -108,7 +130,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
108
130
  raise TileSourceFileNotFoundError(self._largeImagePath) from None
109
131
  try:
110
132
  self.dataset = rio.open(self._largeImagePath)
111
- except RasterioIOError:
133
+ except rio.errors.RasterioIOError:
112
134
  msg = 'File cannot be opened via rasterio.'
113
135
  raise TileSourceError(msg)
114
136
  if self.dataset.driver == 'netCDF':
@@ -131,29 +153,33 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
131
153
  # use the mapnik source if needed. This variable is always ignored
132
154
  # is_netcdf = False
133
155
 
134
- # get the different scales and projections from the image
135
- scale = self.getPixelSizeInMeters()
136
-
137
- # raise an error if we are missing some information about the projection
138
- # i.e. we don't know where to place it on a map
139
- isProjected = self.projection or self.dataset.driver.lower() in {'png'}
140
- if isProjected and not scale:
141
- msg = ('File does not have a projected scale, so will not be '
142
- 'opened via rasterio with a projection.')
156
+ try:
157
+ # get the different scales and projections from the image
158
+ scale = self.getPixelSizeInMeters()
159
+
160
+ # raise an error if we are missing some information about the projection
161
+ # i.e. we don't know where to place it on a map
162
+ isProjected = self.projection or self.dataset.driver.lower() in {'png'}
163
+ if isProjected and not scale:
164
+ msg = ('File does not have a projected scale, so will not be '
165
+ 'opened via rasterio with a projection.')
166
+ raise TileSourceError(msg)
167
+
168
+ # set the levels of the tiles
169
+ logX = math.log(float(self.sizeX) / self.tileWidth)
170
+ logY = math.log(float(self.sizeY) / self.tileHeight)
171
+ computedLevel = math.ceil(max(logX, logY) / math.log(2))
172
+ self.sourceLevels = self.levels = int(max(0, computedLevel) + 1)
173
+
174
+ self._unitsPerPixel = unitsPerPixel
175
+ self.projection is None or self._initWithProjection(unitsPerPixel)
176
+ self._getPopulatedLevels()
177
+ self._getTileLock = threading.Lock()
178
+ self._setDefaultStyle()
179
+ except Exception as exc:
180
+ msg = f'File cannot be opened via rasterio {exc}.'
143
181
  raise TileSourceError(msg)
144
182
 
145
- # set the levels of the tiles
146
- logX = math.log(float(self.sizeX) / self.tileWidth)
147
- logY = math.log(float(self.sizeY) / self.tileHeight)
148
- computedLevel = math.ceil(max(logX, logY) / math.log(2))
149
- self.sourceLevels = self.levels = int(max(0, computedLevel) + 1)
150
-
151
- self._unitsPerPixel = unitsPerPixel
152
- self.projection is None or self._initWithProjection(unitsPerPixel)
153
- self._getPopulatedLevels()
154
- self._getTileLock = threading.Lock()
155
- self._setDefaultStyle()
156
-
157
183
  def _getPopulatedLevels(self):
158
184
  try:
159
185
  with self._getDatasetLock:
@@ -245,8 +271,8 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
245
271
  # If unitsPerPixel is not specified, the horizontal distance
246
272
  # between -180,0 and +180,0 is used. Some projections (such as
247
273
  # stereographic) will fail in this case; they must have a unitsPerPixel specified.
248
- east, _ = warp.transform(srcCrs, dstCrs, [-180], [0])
249
- west, _ = warp.transform(srcCrs, dstCrs, [180], [0])
274
+ east, _ = rio.warp.transform(srcCrs, dstCrs, [-180], [0])
275
+ west, _ = rio.warp.transform(srcCrs, dstCrs, [180], [0])
250
276
  self.unitsAcrossLevel0 = abs(east[0] - west[0])
251
277
  if not self.unitsAcrossLevel0:
252
278
  msg = 'unitsPerPixel must be specified for this projection'
@@ -354,7 +380,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
354
380
  # set bounds to none and exit if no crs is set for the dataset
355
381
  if not srcCrs:
356
382
  self._bounds[strDstCrs] = None
357
- return
383
+ return None
358
384
 
359
385
  # compute the corner coordinates using the affine transformation as
360
386
  # longitudes and latitudes. Cannot only rely on bounds because of
@@ -384,22 +410,21 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
384
410
  # set the vertical bounds
385
411
  # some projection system don't cover the poles so we need to adapt
386
412
  # the values of ybounds accordingly
387
- has_poles = warp.transform(4326, dstCrs, [0], [90])[1][0] != float('inf')
413
+ has_poles = rio.warp.transform(4326, dstCrs, [0], [90])[1][0] != float('inf')
388
414
  yBounds = 90 if has_poles else 89.999999
389
415
 
390
416
  # for each corner fix the latitude within -yBounds yBounds
391
417
  for k in bounds:
392
418
  bounds[k]['y'] = max(min(bounds[k]['y'], yBounds), -yBounds)
393
419
 
394
- # for each corner rotate longitude until it's within -180, 180
395
- while any(v['x'] > 180 for v in bounds.values()):
420
+ # rotate longitude so the western-most corner is within [-180, 180)
421
+ dx = min(v['x'] for v in bounds.values())
422
+ if dx < -180 or dx >= 180:
423
+ dx = ((dx + 180) % 360 - 180) - dx
396
424
  for k in bounds:
397
- bounds[k]['x'] -= 180
398
- while any(v['x'] < -180 for v in bounds.values()):
399
- for k in bounds:
400
- bounds[k]['x'] += 360
425
+ bounds[k]['x'] += dx
401
426
 
402
- # if one of the corner is > 180 set all the corner to world width
427
+ # if one of the corner is >= 180 set all the corners to world width
403
428
  if any(v['x'] >= 180 for v in bounds.values()):
404
429
  bounds['ul']['x'] = bounds['ll']['x'] = -180
405
430
  bounds['ur']['x'] = bounds['lr']['x'] = 180
@@ -408,7 +433,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
408
433
  needProjection = dstCrs and dstCrs != srcCrs
409
434
  if needProjection:
410
435
  for pt in bounds.values():
411
- [pt['x']], [pt['y']] = warp.transform(srcCrs, dstCrs, [pt['x']], [pt['y']])
436
+ [pt['x']], [pt['y']] = rio.warp.transform(srcCrs, dstCrs, [pt['x']], [pt['y']])
412
437
 
413
438
  # extract min max coordinates from the corners
414
439
  ll = bounds['ll']['x'], bounds['ll']['y']
@@ -457,7 +482,10 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
457
482
  for i in dataset.indexes: # 1 indexed
458
483
 
459
484
  # get the stats
460
- stats = dataset.statistics(i, approx=True, clear_cache=True)
485
+ if hasattr(dataset, 'stats'):
486
+ stats = dataset.stats(indexes=[i], approx=True)[0]
487
+ else:
488
+ stats = dataset.statistics(i, approx=True, clear_cache=True)
461
489
 
462
490
  # rasterio doesn't provide support for maskband as for RCF 15
463
491
  # instead the whole mask numpy array is rendered. We don't want to save it
@@ -572,7 +600,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
572
600
  tile = self.dataset.read(
573
601
  window=window,
574
602
  out_shape=(count, h, w),
575
- resampling=Resampling.nearest,
603
+ resampling=rio.enums.Resampling.nearest,
576
604
  )
577
605
 
578
606
  else:
@@ -599,7 +627,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
599
627
  # It will result in surprisingly unmasked data.
600
628
  src_alpha_band = 0
601
629
  for i, interp in enumerate(self.dataset.colorinterp):
602
- if interp == ColorInterp.alpha:
630
+ if interp == rio.enums.ColorInterp.alpha:
603
631
  src_alpha_band = i
604
632
  add_alpha = not src_alpha_band
605
633
 
@@ -607,14 +635,18 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
607
635
  with self._getDatasetLock:
608
636
  with rio.vrt.WarpedVRT(
609
637
  self.dataset,
610
- resampling=Resampling.nearest,
638
+ resampling=rio.enums.Resampling.nearest,
611
639
  crs=self.projection,
612
640
  transform=dst_transform,
613
641
  height=self.tileHeight,
614
642
  width=self.tileWidth,
615
643
  add_alpha=add_alpha,
616
644
  ) as vrt:
617
- tile = vrt.read(resampling=Resampling.nearest)
645
+ try:
646
+ tile = vrt.read(resampling=rio.enums.Resampling.nearest)
647
+ except Exception:
648
+ self.logger.exception('Failed to getTile')
649
+ tile = np.zeros((1, 1))
618
650
 
619
651
  # necessary for multispectral images:
620
652
  # set the coordinates first and the bands at the end
@@ -685,12 +717,14 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
685
717
  units = units.split(':', 1)[1]
686
718
  srcCrs = make_crs(units)
687
719
  dstCrs = self.projection # instance projection -- do not use the CRS native to the file
688
- [pleft], [ptop] = warp.transform(srcCrs, dstCrs,
689
- [right if left is None else left],
690
- [bottom if top is None else top])
691
- [pright], [pbottom] = warp.transform(srcCrs, dstCrs,
692
- [left if right is None else right],
693
- [top if bottom is None else bottom])
720
+ [pleft], [ptop] = rio.warp.transform(
721
+ srcCrs, dstCrs,
722
+ [right if left is None else left],
723
+ [bottom if top is None else top])
724
+ [pright], [pbottom] = rio.warp.transform(
725
+ srcCrs, dstCrs,
726
+ [left if right is None else right],
727
+ [top if bottom is None else bottom])
694
728
  units = 'projection'
695
729
 
696
730
  # set the corner value in pixel coordinates if the coordinate was initially
@@ -836,7 +870,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
836
870
 
837
871
  # convert to the native projection
838
872
  dstCrs = make_crs(self.getCrs())
839
- [px], [py] = warp.transform(srcCrs, dstCrs, [x], [y])
873
+ [px], [py] = rio.warp.transform(srcCrs, dstCrs, [x], [y])
840
874
 
841
875
  # convert to native pixel coordinates
842
876
  af = self._getAffine()
@@ -883,7 +917,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
883
917
  window = rio.windows.Window(int(x), int(y), 1, 1)
884
918
  try:
885
919
  value = self.dataset.read(
886
- i, window=window, resampling=Resampling.nearest,
920
+ i, window=window, resampling=rio.enums.Resampling.nearest,
887
921
  )
888
922
  value = value[0][0] # there should be 1 single pixel
889
923
  pixel.setdefault('bands', {})[i] = value.item()
@@ -949,13 +983,13 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
949
983
 
950
984
  with rio.vrt.WarpedVRT(
951
985
  self.dataset,
952
- resampling=Resampling.nearest,
986
+ resampling=rio.enums.Resampling.nearest,
953
987
  crs=self.projection,
954
988
  transform=dst_transform,
955
989
  height=height,
956
990
  width=width,
957
991
  ) as vrt:
958
- data = vrt.read(resampling=Resampling.nearest)
992
+ data = vrt.read(resampling=rio.enums.Resampling.nearest)
959
993
 
960
994
  profile = self.dataset.meta.copy()
961
995
  profile.update(
@@ -1018,6 +1052,8 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
1018
1052
  :param path: The path to the file
1019
1053
  :returns: True if geospatial.
1020
1054
  """
1055
+ _lazyImport()
1056
+
1021
1057
  if isinstance(path, rio.io.DatasetReaderBase):
1022
1058
  ds = path
1023
1059
  else:
@@ -1031,6 +1067,17 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
1031
1067
  return True
1032
1068
  return False
1033
1069
 
1070
+ @classmethod
1071
+ def addKnownExtensions(cls):
1072
+ import rasterio.drivers
1073
+
1074
+ if not hasattr(cls, '_addedExtensions'):
1075
+ cls._addedExtensions = True
1076
+ cls.extensions = cls.extensions.copy()
1077
+ for ext in rasterio.drivers.raster_driver_extensions():
1078
+ if ext not in cls.extensions:
1079
+ cls.extensions[ext] = SourcePriority.IMPLICIT
1080
+
1034
1081
 
1035
1082
  def open(*args, **kwargs):
1036
1083
  """Create an instance of the module class."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: large-image-source-rasterio
3
- Version: 1.27.5.dev6
3
+ Version: 1.30.7.dev12
4
4
  Summary: A rasterio tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -15,10 +15,18 @@ Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
18
19
  Requires-Python: >=3.8
20
+ Description-Content-Type: text/x-rst
21
+ License-File: LICENSE
22
+ Requires-Dist: large-image>=1.30.7.dev12
23
+ Requires-Dist: rasterio<1.3.11,>=1.3; python_version < "3.9"
24
+ Requires-Dist: rasterio>=1.3; python_version >= "3.9"
25
+ Requires-Dist: packaging
19
26
  Provides-Extra: girder
27
+ Requires-Dist: girder-large-image>=1.30.7.dev12; extra == "girder"
20
28
  Provides-Extra: all
21
- License-File: LICENSE
29
+ Requires-Dist: rio-cogeo; extra == "all"
22
30
 
23
31
  A rasterio tilesource for large_image.
24
32
 
@@ -0,0 +1,14 @@
1
+ large-image>=1.30.7.dev12
2
+ packaging
3
+
4
+ [:python_version < "3.9"]
5
+ rasterio<1.3.11,>=1.3
6
+
7
+ [:python_version >= "3.9"]
8
+ rasterio>=1.3
9
+
10
+ [all]
11
+ rio-cogeo
12
+
13
+ [girder]
14
+ girder-large-image>=1.30.7.dev12
@@ -19,8 +19,7 @@ def prerelease_local_scheme(version):
19
19
 
20
20
  if os.getenv('CIRCLE_BRANCH') in ('master',):
21
21
  return ''
22
- else:
23
- return get_local_node_and_date(version)
22
+ return get_local_node_and_date(version)
24
23
 
25
24
 
26
25
  try:
@@ -40,6 +39,7 @@ setup(
40
39
  },
41
40
  description=description,
42
41
  long_description=long_description,
42
+ long_description_content_type='text/x-rst',
43
43
  license='Apache Software License 2.0',
44
44
  author='Kitware, Inc.',
45
45
  author_email='kitware@kitware.com',
@@ -52,10 +52,13 @@ setup(
52
52
  'Programming Language :: Python :: 3.10',
53
53
  'Programming Language :: Python :: 3.11',
54
54
  'Programming Language :: Python :: 3.12',
55
+ 'Programming Language :: Python :: 3.13',
55
56
  ],
56
57
  install_requires=[
57
58
  f'large-image{limit_version}',
58
- 'rasterio>=1.3', # to get the statistics attribute (<=> gdalinfo)
59
+ 'rasterio>=1.3,<1.3.11 ; python_version < "3.9"',
60
+ # We need rasterio > 1.3 to get the statistics attribute (<=> gdalinfo)
61
+ 'rasterio>=1.3 ; python_version >= "3.9"',
59
62
  'packaging',
60
63
  ],
61
64
  extras_require={
@@ -1,9 +0,0 @@
1
- large-image>=1.27.5.dev6
2
- rasterio>=1.3
3
- packaging
4
-
5
- [all]
6
- rio-cogeo
7
-
8
- [girder]
9
- girder-large-image>=1.27.5.dev6