Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
e127ef62
Kaydet (Commit)
e127ef62
authored
Eki 21, 2018
tarafından
Florian Apolloner
Kaydeden (comit)
Florian Apolloner
Eki 21, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed a failing test when the source directory is on a readonly fs.
üst
3deea61f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
28 deletions
+29
-28
test_raster.py
tests/gis_tests/gdal_tests/test_raster.py
+29
-28
No files found.
tests/gis_tests/gdal_tests/test_raster.py
Dosyayı görüntüle @
e127ef62
import
os
import
shutil
import
struct
import
tempfile
...
...
@@ -541,54 +542,54 @@ class GDALRasterTests(SimpleTestCase):
class
GDALBandTests
(
SimpleTestCase
):
def
setUp
(
self
):
self
.
rs_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'../data/rasters/raster.tif'
)
rs
=
GDALRaster
(
self
.
rs_path
)
self
.
band
=
rs
.
bands
[
0
]
rs_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'../data/rasters/raster.tif'
)
def
test_band_data
(
self
):
pam_file
=
self
.
rs_path
+
'.aux.xml'
self
.
assertEqual
(
self
.
band
.
width
,
163
)
self
.
assertEqual
(
self
.
band
.
height
,
174
)
self
.
assertEqual
(
self
.
band
.
description
,
''
)
self
.
assertEqual
(
self
.
band
.
datatype
(),
1
)
self
.
assertEqual
(
self
.
band
.
datatype
(
as_string
=
True
),
'GDT_Byte'
)
self
.
assertEqual
(
self
.
band
.
color_interp
(),
1
)
self
.
assertEqual
(
self
.
band
.
color_interp
(
as_string
=
True
),
'GCI_GrayIndex'
)
self
.
assertEqual
(
self
.
band
.
nodata_value
,
15
)
rs
=
GDALRaster
(
self
.
rs_path
)
band
=
rs
.
bands
[
0
]
self
.
assertEqual
(
band
.
width
,
163
)
self
.
assertEqual
(
band
.
height
,
174
)
self
.
assertEqual
(
band
.
description
,
''
)
self
.
assertEqual
(
band
.
datatype
(),
1
)
self
.
assertEqual
(
band
.
datatype
(
as_string
=
True
),
'GDT_Byte'
)
self
.
assertEqual
(
band
.
color_interp
(),
1
)
self
.
assertEqual
(
band
.
color_interp
(
as_string
=
True
),
'GCI_GrayIndex'
)
self
.
assertEqual
(
band
.
nodata_value
,
15
)
if
numpy
:
data
=
self
.
band
.
data
()
data
=
band
.
data
()
assert_array
=
numpy
.
loadtxt
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'../data/rasters/raster.numpy.txt'
)
)
numpy
.
testing
.
assert_equal
(
data
,
assert_array
)
self
.
assertEqual
(
data
.
shape
,
(
self
.
band
.
height
,
self
.
band
.
width
))
try
:
smin
,
smax
,
smean
,
sstd
=
self
.
band
.
statistics
(
approximate
=
True
)
self
.
assertEqual
(
data
.
shape
,
(
band
.
height
,
band
.
width
))
def
test_band_statistics
(
self
):
with
tempfile
.
TemporaryDirectory
()
as
tmp_dir
:
rs_path
=
os
.
path
.
join
(
tmp_dir
,
'raster.tif'
)
shutil
.
copyfile
(
self
.
rs_path
,
rs_path
)
rs
=
GDALRaster
(
rs_path
)
band
=
rs
.
bands
[
0
]
pam_file
=
rs_path
+
'.aux.xml'
smin
,
smax
,
smean
,
sstd
=
band
.
statistics
(
approximate
=
True
)
self
.
assertEqual
(
smin
,
0
)
self
.
assertEqual
(
smax
,
9
)
self
.
assertAlmostEqual
(
smean
,
2.842331288343558
)
self
.
assertAlmostEqual
(
sstd
,
2.3965567248965356
)
smin
,
smax
,
smean
,
sstd
=
self
.
band
.
statistics
(
approximate
=
False
,
refresh
=
True
)
smin
,
smax
,
smean
,
sstd
=
band
.
statistics
(
approximate
=
False
,
refresh
=
True
)
self
.
assertEqual
(
smin
,
0
)
self
.
assertEqual
(
smax
,
9
)
self
.
assertAlmostEqual
(
smean
,
2.828326634228898
)
self
.
assertAlmostEqual
(
sstd
,
2.4260526986669095
)
self
.
assertEqual
(
self
.
band
.
min
,
0
)
self
.
assertEqual
(
self
.
band
.
max
,
9
)
self
.
assertAlmostEqual
(
self
.
band
.
mean
,
2.828326634228898
)
self
.
assertAlmostEqual
(
self
.
band
.
std
,
2.4260526986669095
)
self
.
assertEqual
(
band
.
min
,
0
)
self
.
assertEqual
(
band
.
max
,
9
)
self
.
assertAlmostEqual
(
band
.
mean
,
2.828326634228898
)
self
.
assertAlmostEqual
(
band
.
std
,
2.4260526986669095
)
# Statistics are persisted into PAM file on band close
self
.
band
=
None
rs
=
band
=
None
self
.
assertTrue
(
os
.
path
.
isfile
(
pam_file
))
finally
:
# Close band and remove file if created
self
.
band
=
None
if
os
.
path
.
isfile
(
pam_file
):
os
.
remove
(
pam_file
)
def
test_read_mode_error
(
self
):
# Open raster in read mode
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment