Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Daniel Scheffler
geoarray
Commits
6cedabc1
Commit
6cedabc1
authored
Jul 24, 2017
by
Daniel Scheffler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added GeoArray.show_histogram().
parent
7df1bd7c
Pipeline
#493
passed with stages
in 44 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
geoarray/baseclasses.py
geoarray/baseclasses.py
+37
-0
No files found.
geoarray/baseclasses.py
View file @
6cedabc1
...
...
@@ -1213,6 +1213,43 @@ class GeoArray(object):
return
m
def
show_histogram
(
self
,
band
=
1
,
bins
=
200
,
normed
=
False
,
exclude_nodata
=
True
,
vmin
=
None
,
vmax
=
None
,
figsize
=
None
):
# type: (int, int, bool, bool, float, float, tuple) -> None
"""Show a histogram of a given band.
:param band: the band to be used to plot the histogram
:param bins: number of bins to plot (default: 200)
:param normed: whether to normalize the y-axis or not (default: False)
:param exclude_nodata: whether tp exclude nodata value from the histogram
:param vmin: minimum value for the x-axis of the histogram
:param vmax: maximum value for the x-axis of the histogram
:param figsize: figure size (tuple)
"""
if
self
.
nodata
is
not
None
and
exclude_nodata
:
data
=
np
.
ma
.
masked_equal
(
self
[
band
],
self
.
nodata
)
data
=
data
.
compressed
()
else
:
data
=
self
[
band
]
vmin
=
vmin
if
vmin
is
not
None
else
np
.
percentile
(
data
,
1
)
vmax
=
vmax
if
vmax
is
not
None
else
np
.
percentile
(
data
,
99
)
image2plot
=
data
plt
.
figure
(
figsize
=
figsize
)
plt
.
hist
(
list
(
image2plot
.
flat
),
normed
=
normed
,
bins
=
bins
,
color
=
'gray'
,
range
=
[
vmin
,
vmax
])
plt
.
xlabel
(
'Pixel value'
)
plt
.
ylabel
(
'Probabilty'
if
normed
else
'Count'
)
plt
.
show
()
if
not
self
.
q
:
print
(
'STD:'
,
np
.
std
(
data
))
print
(
'MEAN:'
,
np
.
mean
(
data
))
print
(
'2 % percentile:'
,
np
.
percentile
(
data
,
2
))
print
(
'98 % percentile:'
,
np
.
percentile
(
data
,
98
))
def
get_mapPos
(
self
,
mapBounds
,
mapBounds_prj
,
band2get
=
None
,
out_prj
=
None
,
arr_gt
=
None
,
arr_prj
=
None
,
fillVal
=
None
,
rspAlg
=
'near'
,
progress
=
None
,
v
=
False
):
# TODO implement slice for indexing bands
# type: (tuple, str, int, str, tuple, str, int, str, bool, bool) -> (np.ndarray, tuple, str)
...
...
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