Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Ale
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
aflab
astrogeology
Ale
Commits
0d2afda2
Unverified
Commit
0d2afda2
authored
4 months ago
by
Adam Paquette
Committed by
GitHub
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Address gdal warning (#626)
parent
9c17b060
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ale/base/base.py
+31
-39
31 additions, 39 deletions
ale/base/base.py
with
31 additions
and
39 deletions
ale/base/base.py
+
31
−
39
View file @
0d2afda2
...
...
@@ -423,44 +423,50 @@ class Driver():
return
self
.
__module__
.
split
(
'
.
'
)[
-
1
].
split
(
'
_
'
)[
0
]
@property
def
projection
(
self
):
"""
Return projection information generated by osgeo.
Returns
-------
str
A string representation of the projection information.
"""
if
not
hasattr
(
self
,
"
_projection
"
):
def
read_geodata
(
self
):
if
not
hasattr
(
self
,
"
_geodata
"
):
try
:
from
osgeo
import
gdal
gdal
.
UseExceptions
()
except
:
self
.
_projection
=
""
return
self
.
_projection
geodata
=
None
self
.
_
geodata
=
None
if
isinstance
(
self
.
_file
,
pvl
.
PVLModule
):
# save it to a temp folder
with
tempfile
.
NamedTemporaryFile
()
as
tmp
:
tmp
.
write
(
pvl
.
dumps
(
self
.
_file
))
geodata
=
gdal
.
Open
(
tempfile
.
name
)
self
.
_
geodata
=
gdal
.
Open
(
tempfile
.
name
)
else
:
# should be a path
if
not
os
.
path
.
exists
(
self
.
_file
):
self
.
_
projection
=
""
self
.
_
geodata
=
None
else
:
geodata
=
gdal
.
Open
(
self
.
_file
)
self
.
_geodata
=
gdal
.
Open
(
self
.
_file
)
return
self
.
_geodata
@property
def
projection
(
self
):
"""
Return projection information generated by osgeo.
Returns
-------
str
A string representation of the projection information.
"""
if
not
hasattr
(
self
,
"
_projection
"
):
# Try to get the projection, if we are unsuccessful set it
# to empty
try
:
self
.
_projection
=
geodata
.
GetSpatialRef
().
ExportToProj4
()
self
.
_projection
=
self
.
read_
geodata
.
GetSpatialRef
().
ExportToProj4
()
except
:
self
.
_projection
=
""
return
self
.
_projection
@property
...
...
@@ -475,25 +481,11 @@ class Driver():
"""
if
not
hasattr
(
self
,
"
_geotransform
"
):
# Try to get the geotransform, if we are unsuccessful set it
# to the identity
try
:
from
osgeo
import
gdal
self
.
_geotransform
=
self
.
read_geodata
.
GetGeoTransform
()
except
:
self
.
_geotransform
=
(
0.0
,
1.0
,
0.0
,
0.0
,
0.0
,
1.0
)
return
self
.
_geotransform
if
isinstance
(
self
.
_file
,
pvl
.
PVLModule
):
# save it to a temp folder
with
tempfile
.
NamedTemporaryFile
()
as
tmp
:
tmp
.
write
(
pvl
.
dumps
(
self
.
_file
))
geodata
=
gdal
.
Open
(
tempfile
.
name
)
self
.
_geotransform
=
geodata
.
GetGeoTransform
()
else
:
# should be a path
if
not
os
.
path
.
exists
(
self
.
_file
):
self
.
_geotransform
=
(
0.0
,
1.0
,
0.0
,
0.0
,
0.0
,
1.0
)
else
:
geodata
=
gdal
.
Open
(
self
.
_file
)
self
.
_geotransform
=
geodata
.
GetGeoTransform
()
return
self
.
_geotransform
\ No newline at end of file
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