예제 #1
0
import dem as d
import numpy as np
import scipy.ndimage.morphology as morph

grid_name = 'gebco_bath_near'
slope_threshold_degrees = 1.0
base_elevation = -300.0

dem = d.Elevation.load(grid_name)

mask1 = d.Mask()
s = d.GeographicMaxSlope(elevation=dem)
threshold_slope = np.tan(slope_threshold_degrees * np.pi / 180.0)
mask1._copy_info_from_grid(dem, True)
mask1.dtype = np.uint8
mask1._griddata = mask1._griddata.astype(np.uint8)
mask1._griddata[np.isnan(dem._griddata)] = 1
mask1._griddata = mask1._griddata + morph.binary_dilation(mask1._griddata)
coast_mask = d.BaseSpatialGrid()
coast_mask._copy_info_from_grid(dem, True)
coast_mask.dtype = np.uint8
coast_mask._griddata = coast_mask._griddata.astype(np.uint8)
coast_mask._griddata[(mask1._griddata == 1)
                     & (dem._griddata >= base_elevation)] = 1
i = np.where(coast_mask._griddata == 1)
rc = zip(i[0].tolist(), i[1].tolist())
outlets = coast_mask._rowscols_to_xy(rc)
mask = d.Mask()
mask._copy_info_from_grid(dem, True)
i = np.where(s._griddata <= threshold_slope)
mask._griddata[i] = 1
예제 #2
0
import dem as d
import numpy as np
import scipy.ndimage.morphology as morph

grid_name = 'gebco_bath_near'
slope_threshold_degrees = 1.0
base_elevation = -300.0

dem = d.Elevation.load(grid_name)
dem.dtype = np.float32
dem._griddata = dem._griddata.astype(np.float32)

shelf_mask = d.Mask()
shelf_mask._copy_info_from_grid(dem, True)

# Need to implement tiling scheme:

x_beg = range(-180, 160, 20)
y_beg = range(-90, 70, 20)

#x_beg = [-180]
#y_beg = [-90]

for x_s in x_beg:
    for y_s in y_beg:
        extent = [x_s, x_s + 20, y_s, y_s + 20]
        coords = ((x_s, y_s), (x_s + 20, y_s + 20))
        rc_bounds = dem._xy_to_rowscols(coords)
        this_dem = dem.clip_to_extent(extent)
        mask1 = d.BaseSpatialGrid()
        mask2 = d.BaseSpatialGrid()
예제 #3
0
import dem as d
import numpy as np
import scipy.ndimage.morphology as morph

grid_name = 'gebco_bath_near'
shelf_grid_name = 'gebco_bath_near_classified'

slope_threshold_degrees = 1.0

dem = d.Elevation.load(grid_name)
dem.dtype = np.float32
dem._griddata = dem._griddata.astype(np.float32)

shelf_mask = d.Mask.load(shelf_grid_name)

slope_mask = d.Mask()
slope_mask._copy_info_from_grid(dem, True)

# Need to implement tiling scheme:

x_beg = range(-180, 160, 20)
y_beg = range(-90, 70, 20)

for x_s in x_beg:
    for y_s in y_beg:
        extent = [x_s, x_s + 20, y_s, y_s + 20]
        coords = ((x_s, y_s), (x_s + 20, y_s + 20))
        rc_bounds = dem._xy_to_rowscols(coords)
        this_dem = dem.clip_to_extent(extent)
        this_shelf = shelf_mask.clip_to_extent(extent)
        shelf_edge = d.BaseSpatialGrid()
예제 #4
0
#! /usr/bin/env python2.7

import dem as d
import scipy.ndimage.morphology as morph
import numpy as np

prefix = 'ca'

threshold = 5 * 1E6

dem = d.Elevation.load(prefix + '_dem')
mask = d.Mask.load(prefix + '_shelf')

mask2 = d.Mask()
mask2._copy_info_from_grid(mask)
mask2._griddata = mask2._griddata = morph.binary_dilation(
    mask._griddata).astype(np.float) + mask._griddata.astype(np.float)
mask2._griddata[mask2._griddata != 1] = 0
mask2._griddata[dem._griddata >= 0] = 0
mask2._griddata[np.isnan(dem._griddata)] = 0

i = np.where(mask2._griddata == 1)
rc = zip(i[0].tolist(), i[1].tolist())
outlets = dem._rowscols_to_xy(rc)

discrete_flow_terminations = d.GeographicDiscreteFlowAccumulation(
    elevation=dem,
    outlets=outlets,
    terminations_only=True,
    display_output=True)
예제 #5
0
파일: calcSlope.py 프로젝트: stgl/Submarine
dem = d.Elevation.load(grid_name)
shelf_mask = d.Mask.load(shelf_grid_name)

shelf_edge = d.BaseSpatialGrid()
shelf_edge._copy_info_from_grid(shelf_mask, True)
i = np.where(shelf_mask._griddata == 1)
shelf_edge._griddata[i] = 1
shelf_edge._griddata = shelf_edge._griddata + morph.binary_dilation(
    shelf_mask._griddata).astype(np.float64)
shelf_edge._griddata = shelf_edge._griddata + morph.binary_erosion(
    shelf_mask._griddata).astype(np.float64)
i = np.where((shelf_edge._griddata == 2) & (dem._griddata <= -50))
rc = zip(i[0].tolist(), i[1].tolist())
outlets = shelf_edge._rowscols_to_xy(rc)

s = d.GeographicMaxSlope(elevation=dem)
threshold_slope = np.tan(slope_threshold_degrees * np.pi / 180.0)

mask = d.Mask()
mask._copy_info_from_grid(dem, True)
mask._griddata = (s._griddata >= threshold_slope)
mask._griddata = morph.binary_fill_holes(mask._griddata)

slope = d.PriorityFillGrid(mask=mask, outlets=outlets)

slope._griddata[(dem._griddata > -50) & (np.isnan(dem._griddata))] = 0
slope._griddata = morph.binary_fill_holes(slope._griddata)

slope.save(grid_name + '_slope')