Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PySegCNN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
earth_observation_public
PySegCNN
Commits
bc471953
Commit
bc471953
authored
4 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Added a check for an empty dataset.
parent
e0898c8c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pysegcnn/core/utils.py
+23
-19
23 additions, 19 deletions
pysegcnn/core/utils.py
with
23 additions
and
19 deletions
pysegcnn/core/utils.py
+
23
−
19
View file @
bc471953
...
...
@@ -365,31 +365,35 @@ def hdf2tifs(path, outpath=None, overwrite=False, create_stack=True, **kwargs):
# read the hdf dataset
hdf
=
gdal
.
Open
(
str
(
path
)).
GetSubDatasets
()
#
iterate over the different sub
dataset
s
i
n the hdf
f
or
ds
in
hdf
:
#
check if the
dataset i
s not empty
i
f
hdf
:
# name of the current subdataset
name
=
ds
[
0
].
split
(
'
:
'
)[
-
1
]
# iterate over the different subdatasets in the hdf
for
ds
in
hdf
:
# name of the current subdataset
name
=
ds
[
0
].
split
(
'
:
'
)[
-
1
]
# filename of the GeoTIFF
tif_name
=
outpath
.
joinpath
(
path
.
name
.
replace
(
path
.
suffix
,
'
_{}.tif
'
.
format
(
name
)))
# filename of the GeoTIFF
tif_name
=
outpath
.
joinpath
(
path
.
name
.
replace
(
path
.
suffix
,
'
_{}.tif
'
.
format
(
name
)))
# convert hdf subdataset to GeoTIFF
gdal
.
Translate
(
str
(
tif_name
),
gdal
.
Open
(
ds
[
0
]),
**
kwargs
)
# convert hdf subdataset to GeoTIFF
gdal
.
Translate
(
str
(
tif_name
),
gdal
.
Open
(
ds
[
0
]),
**
kwargs
)
# check whether to create a GeoTIFF stack
if
create_stack
:
# filename for the GeoTIFF stack
stk
=
tif_name
.
parent
.
joinpath
(
path
.
name
.
replace
(
path
.
suffix
,
'
.tif
'
))
LOGGER
.
info
(
'
Creating GeoTIFF stack: {}
'
.
format
(
stk
))
# check whether to create a GeoTIFF stack
if
create_stack
:
# filename for the GeoTIFF stack
stk
=
tif_name
.
parent
.
joinpath
(
path
.
name
.
replace
(
path
.
suffix
,
'
.tif
'
))
LOGGER
.
info
(
'
Creating GeoTIFF stack: {}
'
.
format
(
stk
))
# generated GeoTIFF files
tifs
=
[
str
(
f
)
for
f
in
outpath
.
iterdir
()
if
f
.
suffix
in
[
'
.tif
'
,
'
.TIF
'
]]
# generated GeoTIFF files
tifs
=
[
str
(
f
)
for
f
in
outpath
.
iterdir
()
if
f
.
suffix
in
[
'
.tif
'
,
'
.TIF
'
]]
# create stacked GeoTIFF
stack_tifs
(
str
(
stk
),
tifs
)
# create stacked GeoTIFF
stack_tifs
(
str
(
stk
),
tifs
)
return
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment