Skip to content

blm.py

BLM

BLM(dataspec=None, yamlspec='utilities/blm.yaml')

Bases: object

Parameters:

Name Type Description Default
dataspec str

The input data to convert

None
yamlspec str

The YAML config file for converting data

'utilities/blm.yaml'

Returns:

Type Description
LocalRoads

An instance of this class

Source code in osm_merge/utilities/blm.py
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(self,
             dataspec: str = None,
             yamlspec: str = "utilities/blm.yaml",
             ):
    """
    This class processes the dataset.

    Args:
        dataspec (str): The input data to convert
        yamlspec (str): The YAML config file for converting data

    Returns:
        (LocalRoads): An instance of this class
    """
    self.file = None
    if dataspec is not None:
        self.file = open(dataspec, "r")

    yaml = f"{rootdir}/{yamlspec}"
    if not os.path.exists(yaml):
        log.error(f"{yaml} does not exist!")
        quit()

    file = open(yaml, "r")
    self.yaml = YamlFile(f"{yaml}")

main

main()

This main function lets this class be run standalone by a bash script

Source code in osm_merge/utilities/blm.py
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
def main():
    """This main function lets this class be run standalone by a bash script"""
    parser = argparse.ArgumentParser(
        prog="local-roads",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        description="This program converts BLM road/trail into OSM",
        epilog="""
This program processes the state highway data. It will convert the 
dataset to using OSM tagging schema so it can be conflated. Abbreviations
are discouraged in OSM, so they are expanded. Most entries in the
dataset fields are ignored. There often isn't much here beyond state
nand county highway name, but it is another dataset.

    For Example: 
        local-roads.py -v --convert --infile LocalRoads.geojson
        """,
    )
    parser.add_argument("-v", "--verbose", action="store_true", help="verbose output")
    parser.add_argument("-i", "--infile", required=True, help="Output file from the conflation")
    parser.add_argument("-c", "--convert", default=True, action="store_true", help="Convert BLM feature to OSM feature")
    parser.add_argument("-o", "--outfile", default="out.geojson", help="Output file")

    args = parser.parse_args()

    # if verbose, dump to the terminal.
    log_level = os.getenv("LOG_LEVEL", default="INFO")
    if args.verbose is not None:
        log_level = logging.DEBUG

    logging.basicConfig(
        level=log_level,
        format=("%(asctime)s.%(msecs)03d [%(levelname)s] " "%(name)s | %(funcName)s:%(lineno)d | %(message)s"),
        datefmt="%y-%m-%d %H:%M:%S",
        stream=sys.stdout,
    )

    roads = BLM()
    if args.convert and args.convert:
        data = roads.convert(args.infile)

        file = open(args.outfile, "w")
        geojson.dump(data, file, indent=4)
        log.info(f"Wrote {args.outfile}")

options: show_source: false heading_level: 3