EOX GitLab Instance
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESA
PRISM
VS
Commits
23c9a7aa
Commit
23c9a7aa
authored
4 years ago
by
Fabian Schindler
Browse files
Options
Downloads
Patches
Plain Diff
Step to apply georeference from Browse Report
parent
ae754ca1
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
preprocessor/preprocessor/steps/browse_report.py
+56
-0
56 additions, 0 deletions
preprocessor/preprocessor/steps/browse_report.py
with
56 additions
and
0 deletions
preprocessor/preprocessor/steps/browse_report.py
0 → 100644
+
56
−
0
View file @
23c9a7aa
import
os
from
glob
import
glob
from
os.path
import
join
,
basename
from
..util
import
replace_ext
,
pairwise
,
gdal
,
osr
def
browse_georeference
(
source_dir
:
os
.
PathLike
,
target_dir
:
os
.
PathLike
,
browse
:
dict
):
for
filename
in
glob
(
join
(
source_dir
,
'
*
'
)):
target_filename
=
join
(
target_dir
,
replace_ext
(
basename
(
filename
),
'
.tif
'
))
apply_browse_report_georeference
(
filename
,
target_filename
,
browse
)
def
apply_browse_report_georeference
(
input_filename
:
os
.
PathLike
,
target_filename
:
os
.
PathLike
,
browse
:
dict
):
ds
=
gdal
.
GetDriverByName
(
'
GTiff
'
).
CreateCopy
(
target_filename
,
gdal
.
Open
(
input_filename
))
type_
=
browse
[
'
type
'
]
if
type_
==
'
rectified_browse
'
:
size_x
,
size_y
=
ds
.
RasterXSize
,
ds
.
RasterYSize
low
,
high
=
browse
[
'
rectified
'
][
'
coord_list
'
]
minx
,
miny
=
low
maxx
,
maxy
=
high
ds
.
SetGeoTransform
([
minx
,
(
maxx
-
minx
)
/
size_x
,
0
,
maxy
,
0
,
(
miny
-
maxy
)
/
size_y
,
])
elif
type_
==
'
footprint_browse
'
:
col_rows
=
browse
[
'
footprint
'
][
'
col_row_list
'
]
coords
=
browse
[
'
footprint
'
][
'
coord_list
'
]
gcps
=
[
gdal
.
GCP
(
coord
[
0
],
coord
[
1
],
0
,
col_row
[
0
],
col_row
[
1
])
for
col_row
,
coord
in
zip
(
col_rows
,
coords
)
]
sr
=
osr
.
SpatialReference
()
sr
.
ImportFromEPSG
(
4326
)
ds
.
SetGCPs
(
gcps
,
sr
)
elif
type_
==
'
model_in_geotiff_browse
'
:
# nothing to do in this case
pass
elif
type_
==
'
regular_grid_browse
'
:
# TODO: not implemented
raise
NotImplementedError
else
:
raise
Exception
del
ds
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