cat ) viewshed_name = basename + '_' + viewshed_id gscript. VectorTopo ( output_points, mode = 'w', tab_cols = columns ) as output : for point in points : viewshed_id = str ( point.
extend () columns = with VectorTopo ( input_points, mode = 'r' ) as points, \ getpid ()) + '_' tmp_viewshed_name = tmp_prefix + 'viewshed' tmp_viewshed_vector_name = tmp_prefix + 'viewshed_vector' tmp_visible_points = tmp_prefix + 'points' tmp_point = tmp_prefix + 'current_point' TMP_MAPS. parser () elevation = options input_points = options basename = options output_points = options observer_elev = options max_distance = float ( options ) flag_curvature = 'c' if flags else '' tmp_prefix = 'tmp_r_viewshed_points_' + str ( os. By default infinity (-1) #% answer: -1 #% multiple: no #% required: no #%end #%flag #% key: c #% description: Consider the curvature of the earth (current ellipsoid) #%end import os import atexit import grass.script as gscript from import VectorTopo TMP_MAPS = def main (): options, flags = gscript. py #!/usr/bin/env python #%module #% description: Compute and analyze viewsheds #% keyword: raster #% keyword: viewshed #%end #%option G_OPT_R_INPUT #% key: elevation #%end #%option G_OPT_V_INPUT #% key: points #%end #%option G_OPT_V_OUTPUT #% key: output_points #%end #%option G_OPT_R_BASENAME_OUTPUT #% key: viewshed_basename #%end #%option #% key: observer_elevation #% type: double #% required: no #% multiple: no #% key_desc: value #% description: Viewing elevation above the ground #% answer: 1.75 #%end #%option #% key: max_distance #% key_desc: value #% type: double #% description: Maximum visibility radius. Also, there can be only one value provided for this option, so we set multiple to no as well. The user is not required to provide this option, so we set required to no. Our max_distance parameter option has as default value -1 which stands for infinity in the case of viewsheds. Again, the existing GRASS GIS Python scripts may help to quickly understand the best practice. In addition to the description we add also key_desc which is a short hint for a proper syntax. In case we would need a longer description we may use the label key for a short and concise description and the description key for more lengthy and wordy description. We use additionally description to document the meaning of this option. In our example, we introduce a non-standard key with name max_distance which has its type set to double. However, for other cases, we have to define the options completely from scratch. When using standard options, all items are predefined by the parser but we can modify e.g.