Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
 def test_other_raster_aspect(self):
     with rasopen(self.raster) as src:
         profile = src.profile
     bound_box = RasterBounds(affine_transform=profile['affine'],
                              profile=profile)
     dem = AwsDem(zoom=10, target_profile=profile, bounds=bound_box)
     dem.terrain(attribute='aspect',
                 out_file='/home/dgketchum/IrrigationGIS/tests/mapzen_'
                 'image_clip_aspect.tif')
Esempio n. 4
0
    def test_dem(self):
        l8 = Landsat8(self.dir_name_LC8)
        polygon = l8.get_tile_geometry()
        profile = l8.rasterio_geometry
        bb = RasterBounds(affine_transform=profile['affine'],
                          profile=profile,
                          latlon=True)

        dem = AwsDem(zoom=10,
                     target_profile=profile,
                     bounds=bb,
                     clip_object=polygon)

        elev = dem.terrain(
            attribute='slope',
            out_file='/home/dgketchum/IrrigationGIS/tests/mapzen_'
            '{}_{}.tif'.format(l8.target_wrs_path, l8.target_wrs_row))
        self.assertEqual(elev.shape, (1, 7429, 8163))

        aspect = dem.terrain(attribute='aspect')
        self.assertEqual(aspect.shape, (7429, 8163))

        slope = dem.terrain(attribute='slope')
        self.assertEqual(slope.shape, (1, 7429, 8163))
Esempio n. 5
0
 def fetch_dem(self):
     dem = AwsDem(bounds=self.bounds, clip_object=self.clip_geo,
                  target_profile=self.profile, zoom=8)
     var = dem.terrain(attribute='elevation', out_file=self.file_path,
                       save_and_return=True)
     return var