Skip to content

Commit

Permalink
use Cartesian when GeoTiff missing SRS
Browse files Browse the repository at this point in the history
in this case, the user is expected to know how the grid should be
referenced.

Applying Cartesian makes it clear enough that karta doesn't know, while
the previous behaviour (WGS84) could be misleading since it's a proper
reference system.

fixes #37
  • Loading branch information
njwilson23 committed Dec 31, 2016
1 parent 4262046 commit 775a66a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions karta/raster/_gdal.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ def read(fnm, in_memory, ibands=ALL, bandclass=CompressedBand):
"flattening": sr.GetInvFlattening(),
"name": sr.GetAttrValue('PROJCS')}
else:
hdr["srs"] = {"proj4": "+lonlat +proj=WGS84",
hdr["srs"] = {"proj4": "",
"semimajor": 6370997.0,
"flattening": 1.0 / 298.257223563,
"name": "unknown"}
"name": "NA"}

max_dtype = 0
rasterbands = [dataset.GetRasterBand(i) for i in ibands]
Expand Down
7 changes: 5 additions & 2 deletions karta/raster/read.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" Functions for reading raster data sources as RegularGrid objects """
import numpy as np
from .grid import RegularGrid
from ..crs import ProjectedCRS, GeographicalCRS
from ..crs import ProjectedCRS, GeographicalCRS, Cartesian
from . import _gdal
from . import _aai
from ..errors import GridError
Expand Down Expand Up @@ -50,7 +50,10 @@ class of band used by returned grid (default karta.band.CompressedBand)
'sx' : hdr['sx'],
'sy' : -hdr['sy']}

if proj4_isgeodetic(hdr["srs"]["proj4"]):
if len(hdr["srs"]["proj4"]) == 0:
# invalid or missing SRS information
crs = Cartesian
elif proj4_isgeodetic(hdr["srs"]["proj4"]):
geodstr = "+a={a} +f={f}".format(a=hdr["srs"]["semimajor"],
f=hdr["srs"]["flattening"])
crs = GeographicalCRS(geodstr, name=hdr["srs"]["name"])
Expand Down

0 comments on commit 775a66a

Please sign in to comment.