large-image-source-rasterio 1.29.3.dev8__tar.gz → 1.29.3.dev24__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.
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/PKG-INFO +3 -3
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/large_image_source_rasterio/__init__.py +52 -26
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/large_image_source_rasterio.egg-info/PKG-INFO +3 -3
- large-image-source-rasterio-1.29.3.dev24/large_image_source_rasterio.egg-info/requires.txt +9 -0
- large-image-source-rasterio-1.29.3.dev8/large_image_source_rasterio.egg-info/requires.txt +0 -9
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/LICENSE +0 -0
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/README.rst +0 -0
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/large_image_source_rasterio/girder_source.py +0 -0
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/large_image_source_rasterio.egg-info/SOURCES.txt +0 -0
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/large_image_source_rasterio.egg-info/dependency_links.txt +0 -0
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/large_image_source_rasterio.egg-info/entry_points.txt +0 -0
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/large_image_source_rasterio.egg-info/top_level.txt +0 -0
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/pyproject.toml +0 -0
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/setup.cfg +0 -0
- {large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/setup.py +0 -0
{large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: large-image-source-rasterio
|
|
3
|
-
Version: 1.29.3.
|
|
3
|
+
Version: 1.29.3.dev24
|
|
4
4
|
Summary: A rasterio tilesource for large_image.
|
|
5
5
|
Home-page: https://github.com/girder/large_image
|
|
6
6
|
Author: Kitware, Inc.
|
|
@@ -17,11 +17,11 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Requires-Python: >=3.8
|
|
19
19
|
License-File: LICENSE
|
|
20
|
-
Requires-Dist: large-image>=1.29.3.
|
|
20
|
+
Requires-Dist: large-image>=1.29.3.dev24
|
|
21
21
|
Requires-Dist: rasterio>=1.3
|
|
22
22
|
Requires-Dist: packaging
|
|
23
23
|
Provides-Extra: girder
|
|
24
|
-
Requires-Dist: girder-large-image>=1.29.3.
|
|
24
|
+
Requires-Dist: girder-large-image>=1.29.3.dev24; extra == "girder"
|
|
25
25
|
Provides-Extra: all
|
|
26
26
|
Requires-Dist: rio-cogeo; extra == "all"
|
|
27
27
|
|
|
@@ -26,11 +26,6 @@ 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
|
|
@@ -51,11 +46,37 @@ except PackageNotFoundError:
|
|
|
51
46
|
# package is not installed
|
|
52
47
|
pass
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
|
|
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
|
+
print('XXXXXXXXXXXX')
|
|
61
|
+
if rio is None:
|
|
62
|
+
try:
|
|
63
|
+
import affine
|
|
64
|
+
import rasterio as rio
|
|
65
|
+
import rasterio.warp
|
|
66
|
+
|
|
67
|
+
Affine = affine.Affine
|
|
68
|
+
|
|
69
|
+
warnings.filterwarnings(
|
|
70
|
+
'ignore', category=rio.errors.NotGeoreferencedWarning, module='rasterio')
|
|
71
|
+
rio._env.code_map.pop(1, None)
|
|
72
|
+
except ImportError:
|
|
73
|
+
msg = 'rasterio module not found.'
|
|
74
|
+
raise TileSourceError(msg)
|
|
56
75
|
|
|
57
76
|
|
|
58
77
|
def make_crs(projection):
|
|
78
|
+
_lazyImport()
|
|
79
|
+
|
|
59
80
|
if isinstance(projection, str):
|
|
60
81
|
return rio.CRS.from_string(projection)
|
|
61
82
|
if isinstance(projection, dict):
|
|
@@ -87,6 +108,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
87
108
|
"""
|
|
88
109
|
# init the object
|
|
89
110
|
super().__init__(path, **kwargs)
|
|
111
|
+
_lazyImport()
|
|
90
112
|
self.addKnownExtensions()
|
|
91
113
|
|
|
92
114
|
# create a thread lock
|
|
@@ -109,7 +131,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
109
131
|
raise TileSourceFileNotFoundError(self._largeImagePath) from None
|
|
110
132
|
try:
|
|
111
133
|
self.dataset = rio.open(self._largeImagePath)
|
|
112
|
-
except RasterioIOError:
|
|
134
|
+
except rio.errors.RasterioIOError:
|
|
113
135
|
msg = 'File cannot be opened via rasterio.'
|
|
114
136
|
raise TileSourceError(msg)
|
|
115
137
|
if self.dataset.driver == 'netCDF':
|
|
@@ -246,8 +268,8 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
246
268
|
# If unitsPerPixel is not specified, the horizontal distance
|
|
247
269
|
# between -180,0 and +180,0 is used. Some projections (such as
|
|
248
270
|
# stereographic) will fail in this case; they must have a unitsPerPixel specified.
|
|
249
|
-
east, _ = warp.transform(srcCrs, dstCrs, [-180], [0])
|
|
250
|
-
west, _ = warp.transform(srcCrs, dstCrs, [180], [0])
|
|
271
|
+
east, _ = rio.warp.transform(srcCrs, dstCrs, [-180], [0])
|
|
272
|
+
west, _ = rio.warp.transform(srcCrs, dstCrs, [180], [0])
|
|
251
273
|
self.unitsAcrossLevel0 = abs(east[0] - west[0])
|
|
252
274
|
if not self.unitsAcrossLevel0:
|
|
253
275
|
msg = 'unitsPerPixel must be specified for this projection'
|
|
@@ -385,7 +407,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
385
407
|
# set the vertical bounds
|
|
386
408
|
# some projection system don't cover the poles so we need to adapt
|
|
387
409
|
# the values of ybounds accordingly
|
|
388
|
-
has_poles = warp.transform(4326, dstCrs, [0], [90])[1][0] != float('inf')
|
|
410
|
+
has_poles = rio.warp.transform(4326, dstCrs, [0], [90])[1][0] != float('inf')
|
|
389
411
|
yBounds = 90 if has_poles else 89.999999
|
|
390
412
|
|
|
391
413
|
# for each corner fix the latitude within -yBounds yBounds
|
|
@@ -409,7 +431,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
409
431
|
needProjection = dstCrs and dstCrs != srcCrs
|
|
410
432
|
if needProjection:
|
|
411
433
|
for pt in bounds.values():
|
|
412
|
-
[pt['x']], [pt['y']] = warp.transform(srcCrs, dstCrs, [pt['x']], [pt['y']])
|
|
434
|
+
[pt['x']], [pt['y']] = rio.warp.transform(srcCrs, dstCrs, [pt['x']], [pt['y']])
|
|
413
435
|
|
|
414
436
|
# extract min max coordinates from the corners
|
|
415
437
|
ll = bounds['ll']['x'], bounds['ll']['y']
|
|
@@ -573,7 +595,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
573
595
|
tile = self.dataset.read(
|
|
574
596
|
window=window,
|
|
575
597
|
out_shape=(count, h, w),
|
|
576
|
-
resampling=Resampling.nearest,
|
|
598
|
+
resampling=rio.enums.Resampling.nearest,
|
|
577
599
|
)
|
|
578
600
|
|
|
579
601
|
else:
|
|
@@ -600,7 +622,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
600
622
|
# It will result in surprisingly unmasked data.
|
|
601
623
|
src_alpha_band = 0
|
|
602
624
|
for i, interp in enumerate(self.dataset.colorinterp):
|
|
603
|
-
if interp == ColorInterp.alpha:
|
|
625
|
+
if interp == rio.enums.ColorInterp.alpha:
|
|
604
626
|
src_alpha_band = i
|
|
605
627
|
add_alpha = not src_alpha_band
|
|
606
628
|
|
|
@@ -608,14 +630,14 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
608
630
|
with self._getDatasetLock:
|
|
609
631
|
with rio.vrt.WarpedVRT(
|
|
610
632
|
self.dataset,
|
|
611
|
-
resampling=Resampling.nearest,
|
|
633
|
+
resampling=rio.enums.Resampling.nearest,
|
|
612
634
|
crs=self.projection,
|
|
613
635
|
transform=dst_transform,
|
|
614
636
|
height=self.tileHeight,
|
|
615
637
|
width=self.tileWidth,
|
|
616
638
|
add_alpha=add_alpha,
|
|
617
639
|
) as vrt:
|
|
618
|
-
tile = vrt.read(resampling=Resampling.nearest)
|
|
640
|
+
tile = vrt.read(resampling=rio.enums.Resampling.nearest)
|
|
619
641
|
|
|
620
642
|
# necessary for multispectral images:
|
|
621
643
|
# set the coordinates first and the bands at the end
|
|
@@ -686,12 +708,14 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
686
708
|
units = units.split(':', 1)[1]
|
|
687
709
|
srcCrs = make_crs(units)
|
|
688
710
|
dstCrs = self.projection # instance projection -- do not use the CRS native to the file
|
|
689
|
-
[pleft], [ptop] = warp.transform(
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
711
|
+
[pleft], [ptop] = rio.warp.transform(
|
|
712
|
+
srcCrs, dstCrs,
|
|
713
|
+
[right if left is None else left],
|
|
714
|
+
[bottom if top is None else top])
|
|
715
|
+
[pright], [pbottom] = rio.warp.transform(
|
|
716
|
+
srcCrs, dstCrs,
|
|
717
|
+
[left if right is None else right],
|
|
718
|
+
[top if bottom is None else bottom])
|
|
695
719
|
units = 'projection'
|
|
696
720
|
|
|
697
721
|
# set the corner value in pixel coordinates if the coordinate was initially
|
|
@@ -837,7 +861,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
837
861
|
|
|
838
862
|
# convert to the native projection
|
|
839
863
|
dstCrs = make_crs(self.getCrs())
|
|
840
|
-
[px], [py] = warp.transform(srcCrs, dstCrs, [x], [y])
|
|
864
|
+
[px], [py] = rio.warp.transform(srcCrs, dstCrs, [x], [y])
|
|
841
865
|
|
|
842
866
|
# convert to native pixel coordinates
|
|
843
867
|
af = self._getAffine()
|
|
@@ -884,7 +908,7 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
884
908
|
window = rio.windows.Window(int(x), int(y), 1, 1)
|
|
885
909
|
try:
|
|
886
910
|
value = self.dataset.read(
|
|
887
|
-
i, window=window, resampling=Resampling.nearest,
|
|
911
|
+
i, window=window, resampling=rio.enums.Resampling.nearest,
|
|
888
912
|
)
|
|
889
913
|
value = value[0][0] # there should be 1 single pixel
|
|
890
914
|
pixel.setdefault('bands', {})[i] = value.item()
|
|
@@ -950,13 +974,13 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
950
974
|
|
|
951
975
|
with rio.vrt.WarpedVRT(
|
|
952
976
|
self.dataset,
|
|
953
|
-
resampling=Resampling.nearest,
|
|
977
|
+
resampling=rio.enums.Resampling.nearest,
|
|
954
978
|
crs=self.projection,
|
|
955
979
|
transform=dst_transform,
|
|
956
980
|
height=height,
|
|
957
981
|
width=width,
|
|
958
982
|
) as vrt:
|
|
959
|
-
data = vrt.read(resampling=Resampling.nearest)
|
|
983
|
+
data = vrt.read(resampling=rio.enums.Resampling.nearest)
|
|
960
984
|
|
|
961
985
|
profile = self.dataset.meta.copy()
|
|
962
986
|
profile.update(
|
|
@@ -1019,6 +1043,8 @@ class RasterioFileTileSource(GDALBaseFileTileSource, metaclass=LruCacheMetaclass
|
|
|
1019
1043
|
:param path: The path to the file
|
|
1020
1044
|
:returns: True if geospatial.
|
|
1021
1045
|
"""
|
|
1046
|
+
_lazyImport()
|
|
1047
|
+
|
|
1022
1048
|
if isinstance(path, rio.io.DatasetReaderBase):
|
|
1023
1049
|
ds = path
|
|
1024
1050
|
else:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: large-image-source-rasterio
|
|
3
|
-
Version: 1.29.3.
|
|
3
|
+
Version: 1.29.3.dev24
|
|
4
4
|
Summary: A rasterio tilesource for large_image.
|
|
5
5
|
Home-page: https://github.com/girder/large_image
|
|
6
6
|
Author: Kitware, Inc.
|
|
@@ -17,11 +17,11 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Requires-Python: >=3.8
|
|
19
19
|
License-File: LICENSE
|
|
20
|
-
Requires-Dist: large-image>=1.29.3.
|
|
20
|
+
Requires-Dist: large-image>=1.29.3.dev24
|
|
21
21
|
Requires-Dist: rasterio>=1.3
|
|
22
22
|
Requires-Dist: packaging
|
|
23
23
|
Provides-Extra: girder
|
|
24
|
-
Requires-Dist: girder-large-image>=1.29.3.
|
|
24
|
+
Requires-Dist: girder-large-image>=1.29.3.dev24; extra == "girder"
|
|
25
25
|
Provides-Extra: all
|
|
26
26
|
Requires-Dist: rio-cogeo; extra == "all"
|
|
27
27
|
|
{large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/LICENSE
RENAMED
|
File without changes
|
{large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/README.rst
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/pyproject.toml
RENAMED
|
File without changes
|
{large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/setup.cfg
RENAMED
|
File without changes
|
{large-image-source-rasterio-1.29.3.dev8 → large-image-source-rasterio-1.29.3.dev24}/setup.py
RENAMED
|
File without changes
|