def test_rasterValuesAtPoints(self): # We need to make a .tif to test this function. self.make_me_a_tif() # Get the range of the tif tifRange = su.getRasterExtent('PointData_TestData.tif') # Now try to get some point values -- note they will be rounded to the # nearest cell xA = numpy.array([0., 10.3, 50.9, 100.])+tifRange[0]+0.5 yA = numpy.array([0., 20.1, 75.1, 100.])+tifRange[2]+0.5 z_predicted = numpy.round(xA)+numpy.round(yA) - \ tifRange[0]-tifRange[2]-1.0 InDat = numpy.vstack([xA, yA]).transpose() z_fitted = su.rasterValuesAtPoints( InDat, rasterFile='PointData_TestData.tif') try: assert(numpy.allclose(z_fitted, z_predicted)) except: raise Exception( 'Error could be in rasterValuesAtPoints or in Make_Geotif') # Try with bilinear interpolation z_fitted = su.rasterValuesAtPoints(InDat, rasterFile='PointData_TestData.tif', interpolation='bilinear') z_predicted = xA + yA - tifRange[0] - tifRange[2] - 1.0 try: assert(numpy.allclose(z_fitted, z_predicted)) except: raise Exception( 'Error could be in rasterValuesAtPoints or in Make_Geotif') return
def test_rasterValuesAtPoints(self): # We need to make a .tif to test this function. self.make_me_a_tif() # Get the range of the tif tifRange=su.getRasterExtent('PointData_TestData.tif') # Now try to get some point values -- note they will be rounded to the # nearest cell xA=numpy.array([0., 10.3, 50.9, 100.])+tifRange[0]+0.5 yA=numpy.array([0., 20.1, 75.1, 100.])+tifRange[2]+0.5 z_predicted=numpy.round(xA)+numpy.round(yA)-tifRange[0]-tifRange[2]-1.0 InDat=numpy.vstack([xA,yA]).transpose() z_fitted=su.rasterValuesAtPoints(InDat, rasterFile='PointData_TestData.tif') try: assert(numpy.allclose(z_fitted,z_predicted)) except: raise Exception, 'Error could be in rasterValuesAtPoints or in Make_Geotif' # Try with bilinear interpolation z_fitted=su.rasterValuesAtPoints(InDat, rasterFile='PointData_TestData.tif', interpolation='bilinear') z_predicted = xA + yA - tifRange[0] - tifRange[2] - 1.0 try: assert(numpy.allclose(z_fitted,z_predicted)) except: raise Exception, 'Error could be in rasterValuesAtPoints or in Make_Geotif' return
def QFun(x, y): xll = domain.geo_reference.xllcorner yll = domain.geo_reference.yllcorner inDat = scipy.vstack([x + xll, y + yll]).transpose() return rasterValuesAtPoints(xy=inDat, rasterFile=rasterFile, interpolation=interpolation)
def QFun(x,y): xll=domain.geo_reference.xllcorner yll=domain.geo_reference.yllcorner inDat=scipy.vstack([x+xll,y+yll]).transpose() return rasterValuesAtPoints(xy=inDat,rasterFile=rasterFile, interpolation=interpolation)