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
eb5cae7e
Commit
eb5cae7e
authored
4 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Improved logging for gdal functions.
parent
bd963ba7
No related branches found
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
+9
-6
9 additions, 6 deletions
pysegcnn/core/utils.py
with
9 additions
and
6 deletions
pysegcnn/core/utils.py
+
9
−
6
View file @
eb5cae7e
...
...
@@ -1922,7 +1922,6 @@ def reproject_raster(src_ds, trg_ds, ref_ds=None, epsg=None, resample='near',
# check whether the output datasets exists
trg_path
=
pathlib
.
Path
(
trg_ds
)
if
not
trg_path
.
exists
():
LOGGER
.
info
(
'
mkdir {}
'
.
format
(
str
(
trg_path
.
parent
)))
trg_path
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
else
:
# check whether to overwrite existing files
...
...
@@ -1935,7 +1934,9 @@ def reproject_raster(src_ds, trg_ds, ref_ds=None, epsg=None, resample='near',
# encode the NoData value to the output data type
out_type
=
src_ds
.
GetRasterBand
(
1
).
DataType
nodata
=
getattr
(
Gdal2Numpy
,
gdal
.
GetDataTypeName
(
out_type
)).
value
(
no_data
)
if
no_data
is
not
None
:
no_data
=
getattr
(
Gdal2Numpy
,
gdal
.
GetDataTypeName
(
out_type
)).
value
(
no_data
)
# get the projection of the source dataset
src_epsg
=
get_epsg
(
src_ds
)
...
...
@@ -1979,7 +1980,7 @@ def reproject_raster(src_ds, trg_ds, ref_ds=None, epsg=None, resample='near',
srcSRS
=
src_proj
,
dstSRS
=
ref_proj
,
outputType
=
out_type
,
dstNodata
=
nodata
,
dstNodata
=
no
_
data
,
xRes
=
ref_xres
,
yRes
=
ref_yres
,
resampleAlg
=
resample
)
...
...
@@ -2257,7 +2258,7 @@ def dec2bin(number, nbits=8):
def
extract_by_mask
(
src_ds
,
mask_ds
,
trg_ds
,
overwrite
=
False
,
src_no_data
=
None
,
trg_no_data
=
0
):
src_no_data
=
None
,
trg_no_data
=
None
):
"""
Extract raster values by mask.
Extract the extent of ``mask_ds`` from ``src_ds``. The masked values of
...
...
@@ -2282,7 +2283,8 @@ def extract_by_mask(src_ds, mask_ds, trg_ds, overwrite=False,
means the value is read from ``src_ds``. If specified, values equal to
``src_no_data`` are masked as ``trg_no_data`` in ``trg_ds``.
trg_no_data : `int` or `float`, optional
The value to assign to NoData values in ``trg_ds``. The default is `0`.
The value to assign to NoData values in ``trg_ds``. The default is
`None`, which means conserving the NoData value of ``src_ds``.
"""
# convert path to source dataset and mask dataset to pathlib.Path object
...
...
@@ -2300,7 +2302,6 @@ def extract_by_mask(src_ds, mask_ds, trg_ds, overwrite=False,
# check whether the output datasets exists
trg_path
=
pathlib
.
Path
(
trg_ds
)
if
not
trg_path
.
exists
():
LOGGER
.
info
(
'
mkdir {}
'
.
format
(
str
(
trg_path
.
parent
)))
trg_path
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
else
:
# check whether to overwrite existing files
...
...
@@ -2315,6 +2316,8 @@ def extract_by_mask(src_ds, mask_ds, trg_ds, overwrite=False,
src_sr
=
osr
.
SpatialReference
()
src_sr
.
ImportFromWkt
(
src_ds
.
GetProjection
())
LOGGER
.
info
(
'
Extract: {}, {}
'
.
format
(
src_path
.
name
,
mask_path
.
name
))
# checkt the type of the mask dataset
if
mask_path
.
name
.
endswith
(
'
.shp
'
):
# clip raster values by shapefile
...
...
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