# distance to forest edges
name_forest = ''
dist_edge(input_maps=maps_forest,
          classify_edge_as_zero=False,
          prepare_biodim=False,
          remove_trash=True,
          prefix=name_forest,
          add_counter_name=False,
          export=False,
          dirout='')

maps_forest[56]

# patch size
patch_size(input_maps=maps_forest, remove_trash=True, export=False)

# distance to roads
road_maps = grass.list_grouped(type='raster', pattern='*roads*')['PERMANENT']
road_maps = [i for i in road_maps if 'dist' not in i]

for i in road_maps:

    g.region(raster=i, flags='p')
    r.grow_distance(input=i, distance=i + '_road_dist_m', overwrite=True)

# distance to water
water_maps1 = grass.list_grouped(type='raster',
                                 pattern='*Drainage*')['PERMANENT']
water_maps2 = grass.list_grouped(type='raster',
                                 pattern='*Water_presence*')['PERMANENT']
Ejemplo n.º 2
0
    grass.run_command('r.grow.distance',
                      input=water_1_null,
                      distance=name_water,
                      overwrite=True)

    # patch size
    lsmetrics_dir = r'H:\_neojaguardatabase\LS_METRICS\_LSMetrics_v1_0_0'
    os.chdir(lsmetrics_dir)

    # Run LSMetrics
    from LSMetrics_v1_0_0 import rulesreclass, patch_size

    name_patchsize = 'local_'

    patch_size(input_maps=[
        'Neotropic_Hansen_forest1_0_95percenttreecover_2000_30_tif_exp'
    ],
               prefix=name_patchsize)

    # List of raster to be exported
    list_rast_export = grass.list_grouped(type='rast',
                                          pattern='*exp*')['PERMANENT']

    # Outpt folder
    os.chdir(output_folder)

    buffer_dir = i.replace('_shp', '')

    # Create output folder
    if not os.path.exists(buffer_dir):
        os.mkdir(buffer_dir)
        print "Directory " + buffer_dir + " Created "
Ejemplo n.º 3
0
from LSMetrics_v1_0_0 import create_binary, createtxt, create_TXTinputBIODIM, lsmetrics_run, patch_size

# 0) Calculate binary maps
list_of_maps = ['SP_RioClaro_use_raster', 'APA_Sao_Joao_RJ_cut_SIRGAS_UTM23S']
habitat_is = ['4', '5', '6']

# Create binary 0/1 maps
bin_map_list = create_binary(list_maps=list_of_maps,
                             list_habitat_classes=habitat_is,
                             zero=True,
                             prefix='zero_')

# 1) For only one map

# With zero
patch_size(input_maps=[bin_map_list[0]], zero=True, prefix='zero_')

# With null
patch_size(input_maps=[bin_map_list[0]], prefix='null_')

# 2) For more than one map

# With null
patch_size(input_maps=bin_map_list)

# 3) Test export, calculate statistics, and create output for biodim
patch_size(input_maps=bin_map_list,
           calc_statistics=True,
           prepare_biodim=True,
           export=True,
           dirout=output_dir)