Skip to content

Commit

Permalink
Fix pylint errors by explicitly returning None (#3)
Browse files Browse the repository at this point in the history
* Explicitly return None in resample_grid if not to file

* Explicitly return None in rasterize_shapefile

* Update epsg method to pass RuntimeError if not able to find epsg code

* Removed unused _epsg and trailing whitespace
  • Loading branch information
snowman2 committed Jul 15, 2018
1 parent a74ea34 commit 7f6d049
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 8 additions & 6 deletions gazar/grid.py
Expand Up @@ -135,8 +135,6 @@ def __init__(self, grid_file, prj_file=None):
self.projection = osr.SpatialReference()
self.projection.ImportFromWkt(self.dataset.GetProjection())

# identify EPSG code where applicable
self.projection.AutoIdentifyEPSG()
# set affine from geotransform
self.affine = Affine.from_gdal(*self.dataset.GetGeoTransform())

Expand Down Expand Up @@ -178,11 +176,14 @@ def proj(self):
@property
def epsg(self):
""":obj:`str`: EPSG code"""
try:
# identify EPSG code where applicable
self.projection.AutoIdentifyEPSG()
except RuntimeError:
pass
epsg = self.projection.GetAuthorityCode(None)
if epsg:
return epsg
# attempt online lookup
return lookupSpatialReferenceID(self.wkt)
# return or attempt online lookup if not found
return epsg or lookupSpatialReferenceID(self.wkt)

def bounds(self, as_geographic=False, as_utm=False, as_projection=None):
"""Returns bounding coordinates for the dataset.
Expand Down Expand Up @@ -821,6 +822,7 @@ def resample_grid(original_grid,
return GDALGrid(dst)
return dst
del dst
return None


def gdal_reproject(src,
Expand Down
1 change: 1 addition & 0 deletions gazar/shape.py
Expand Up @@ -297,3 +297,4 @@ def rasterize_shapefile(shapefile_path,

if as_gdal_grid:
return GDALGrid(target_ds)
return None

0 comments on commit 7f6d049

Please sign in to comment.