parameters: (sh_file)
return_statement: return feature_list
docstring: Get a list of polygon lines (polylines)
      from shapefile
  
      Arguments:
          sh_file {[string]} -- the shapefile name
  
      Returns:
          [list] -- list of polylines
docstring_summary: Get a list of polygon lines (polylines)
      from shapefile
docstring_tokens: Get a list of polygon lines ( polylines ) from shapefile
function: def get_polylines_from_shape_file(sh_file):
      """
      Get a list of polygon lines (polylines)
      from shapefile
  
      Arguments:
          sh_file {[string]} -- the shapefile name
  
      Returns:
          [list] -- list of polylines
      """
      shpfile = shapefile.Reader(sh_file)
      feature_list = []
      field_names = []
      index = 0
      if shpfile.fields:
          for fld in shpfile.fields[1:]:
              if fld:
                  fname = fld[0]
              else:
                  fname = "field_{}".format(index)
              field_names.append(fname)
              index += 1
      else:
          field_names = []
  
      index = 0
      for shape_rec in shpfile.shapeRecords():
          if shape_rec.shape.shapeType != shapefile.POLYLINE:
              print("ERROR: The function reads only polylines. The input indicates"
                    " some other shape (shapeType={}). Skipping this shape."
                    .format(shape_rec.shape.shapeType))
              continue
  
          pt_list = []
          # End point is repeated in the end. Omit it
          for point in shape_rec.shape.points:
              pt_list.append(point)
  
          fielddict = {"points": pt_list}
          fielddict.update({field_names[i]: shape_rec.record[i]
                            for i in range(len(field_names))})
          feature_list.append(fielddict)
          index += 1
  
      return feature_list
function_tokens: def get_polylines_from_shape_file ( sh_file ) : shpfile = shapefile . Reader ( sh_file ) feature_list = [ ] field_names = [ ] index = 0 if shpfile . fields : for fld in shpfile . fields [ 1 : ] : if fld : fname = fld [ 0 ] else : fname = "field_{}" . format ( index ) field_names . append ( fname ) index += 1 else : field_names = [ ] index = 0 for shape_rec in shpfile . shapeRecords ( ) : if shape_rec . shape . shapeType != shapefile . POLYLINE : print ( "ERROR: The function reads only polylines. The input indicates" " some other shape (shapeType={}). Skipping this shape." . format ( shape_rec . shape . shapeType ) ) continue pt_list = [ ] # End point is repeated in the end. Omit it for point in shape_rec . shape . points : pt_list . append ( point ) fielddict = { "points" : pt_list } fielddict . update ( { field_names [ i ] : shape_rec . record [ i ] for i in range ( len ( field_names ) ) } ) feature_list . append ( fielddict ) index += 1 return feature_list