File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -277,9 +277,15 @@ def read_raster(raster_file):
277277 geotrans = ds .GetGeoTransform ()
278278 dttype = band .DataType
279279
280- srs = osr_SpatialReference ()
281- srs .ImportFromWkt (ds .GetProjection ())
282- # print(srs.ExportToProj4())
280+ srs = ds .GetSpatialRef ()
281+ if srs is None :
282+ wkt = ds .GetProjection ()
283+ srs = osr_SpatialReference ()
284+ if wkt :
285+ # print(wkt)
286+ srs .ImportFromWkt (wkt ) # srs may still be empty if file has no SRS
287+ # print(srs.ExportToProj4())
288+
283289 if nodata_value is None :
284290 nodata_value = DEFAULT_NODATA
285291 band = None
@@ -738,9 +744,9 @@ def closing(input_rasterfilename, times):
738744
739745if __name__ == '__main__' :
740746 # Run doctest in docstrings of Google code style
741- # python -m doctest raster.py (only when doctest. ELLIPSIS is not specified)
742- # or python raster.py -v
743- # or py.test --doctest-modules raster.py
747+ # (Recommended) python -m doctest -o ELLIPSIS -v pygeoc/raster.py
748+ # or python pygeoc/ raster.py -v
749+ # or py.test --doctest-modules pygeoc/ raster.py
744750 import doctest
745751
746752 doctest .testmod (optionflags = doctest .ELLIPSIS )
You can’t perform that action at this time.
0 commit comments