Skip to content

Commit

Permalink
Bug testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sambowers committed Apr 9, 2018
1 parent a723040 commit 58177c0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion biota/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ def maskRaster(tile, tif, classes = [], buffer_size = 0.):

assert tif.rstrip('/').split('.')[-1] == 'tif' or tif.rstrip('/').split('.')[-1] == 'tiff', "tif input must be a GeoTiff file."

tif = os.path.expanduser(tif)
assert os.path.exists(tif), "GeoTiff file %s does not exist in the file system."%tif

# Open GeoTiff and get metadata
ds_source = gdal.Open(tif)
proj_source = biota.IO.loadProjection(tif)
Expand Down Expand Up @@ -232,7 +235,10 @@ def maskShapefile(tile, shp, buffer_size = 0., field = None, value = None, locat
from osgeo import gdalnumeric

assert np.logical_or(np.logical_and(field == None, value == None), np.logical_and(field != None, value != None)), "If specifying field or value, both must be defined. At present, field = %s and value = %s"%(str(field), str(value))


shp = os.path.expanduser(shp)
assert os.path.exists(shp), "Shapefile %s does not exist in the file system."%shp

# Determine the size of the buffer in degrees
buffer_size_degrees = buffer_size / (((tile.xRes * tile.xSize) + (tile.yRes * tile.ySize)) / 2.)

Expand Down

0 comments on commit 58177c0

Please sign in to comment.