Skip to content

Commit

Permalink
adding logger message to local op function in Raster class
Browse files Browse the repository at this point in the history
  • Loading branch information
wbierbower committed Apr 23, 2015
1 parent 3cd5cc6 commit ce2de9c
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions fauxgeo/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import shutil
import functools
import logging

import gdal
import ogr
Expand All @@ -18,6 +19,10 @@

import pygeoprocessing as pygeo

LOGGER = logging.getLogger('Raster Class')
logging.basicConfig(format='%(asctime)s %(name)-15s %(levelname)-8s \
%(message)s', level=logging.DEBUG, datefmt='%m/%d/%Y %H/%M/%S')


class Raster(object):
# any global variables here
Expand Down Expand Up @@ -528,23 +533,6 @@ def get_aoi(self):
def get_aoi_as_shapefile(self, uri):
'''May only be suited for non-rotated rasters'''
raise NotImplementedError
bb = self.get_bounding_box()
u_x = max(bb[0::2])
l_x = min(bb[0::2])
u_y = max(bb[1::2])
l_y = min(bb[1::2])
aoi = Polygon([(l_x, l_y), (l_x, u_y), (u_x, u_y), (u_x, l_y)])
# wkb = aoi.wkb

# shpDriver = ogr.GetDriverByName("ESRI Shapefile")
# if os.path.exists(uri):
# shpDriver.DeleteDataSource(uri)
# outDataSource = shpDriver.CreateDataSource(uri)
# outLayer = outDataSource.CreateLayer(uri, geom_type=ogr.wkbPolygon)
# featureDefn = outLayer.GetLayerDefn()
# outFeature = ogr.Feature(featureDefn)
# outFeature.SetGeometry(wkb)
# outLayer.CreateFeature(outFeature)

def get_cell_area(self):
a = self.get_affine()
Expand Down Expand Up @@ -796,7 +784,7 @@ def reclass(self, reclass_table, out_nodata=None, out_datatype=None):
dataset_out_uri,
out_datatype,
out_nodata,
assert_datasets_projected=False)
assert_dataset_projected=False)

return Raster.from_tempfile(dataset_out_uri)

Expand All @@ -812,7 +800,12 @@ def local_op(self, raster, pixel_op_closure, broadcast=False):

if not broadcast:
assert(self.is_aligned(raster))
assert(self.get_nodata(1) == raster.get_nodata(1))
try:
assert(self.get_nodata(1) == raster.get_nodata(1))
except:
LOGGER.error("Rasters have different nodata values: %f, %f" % (
self.get_nodata(1), raster.get_nodata(1)))
raise AssertionError
dataset_uri_list = [self.uri, raster.uri]
resample_list = [resample_method]*2
else:
Expand Down

0 comments on commit ce2de9c

Please sign in to comment.