def get_terrain(self): slope_name = os.path.join(self.root, 'slope.tif') aspect_name = os.path.join(self.root, 'aspect.tif') dif_elev = os.path.join(self.root, 'elevation_diff.tif') check = [ os.path.isfile(x) for x in [slope_name, aspect_name, dif_elev] ] if False in check: polygon = self.landsat.get_tile_geometry() bb = RasterBounds(affine_transform=self.profile['transform'], profile=self.profile, latlon=True) dem = AwsDem(zoom=10, target_profile=self.profile, bounds=bb, clip_object=polygon) dem.terrain(attribute='slope', out_file=slope_name, save_and_return=True) dem.terrain(attribute='aspect', out_file=aspect_name, save_and_return=True) elev = dem.terrain(attribute='elevation') elev = elev - mean(elev) dem.save(elev, geometry=dem.target_profile, output_filename=dif_elev)
def get_terrain(self): """ Get digital elevation maps from amazon web services save in the project root directory with filenames enumerated in the next three lines. """ slope_name = os.path.join(self.root, 'slope.tif') aspect_name = os.path.join(self.root, 'aspect.tif') dif_elev = os.path.join(self.root, 'elevation_diff.tif') check = [os.path.isfile(x) for x in [slope_name, aspect_name, dif_elev]] if False in check: polygon = self.landsat.get_tile_geometry() bb = RasterBounds(affine_transform=self.profile['transform'], profile=self.profile, latlon=True) dem = AwsDem(zoom=10, target_profile=self.profile, bounds=bb, clip_object=polygon) dem.terrain(attribute='slope', out_file=slope_name, save_and_return=True) dem.terrain(attribute='aspect', out_file=aspect_name, save_and_return=True) elev = dem.terrain(attribute='elevation') elev = elev - mean(elev) dem.save(elev, geometry=dem.target_profile, output_filename=dif_elev)