Python osgeo.gdal.GeneralCmdLineProcessor() Examples

The following are 2 code examples of osgeo.gdal.GeneralCmdLineProcessor(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module osgeo.gdal , or try the search function .
Example #1
Source File: gdal2tiles.py    From gdal2tiles with MIT License 5 votes vote down vote up
def main():
    # TODO: gbataille - use mkdtemp to work in a temp directory
    # TODO: gbataille - debug intermediate tiles.vrt not produced anymore?
    # TODO: gbataille - Refactor generate overview tiles to not depend on self variables
    argv = gdal.GeneralCmdLineProcessor(sys.argv)
    input_file, output_folder, options = process_args(argv[1:])
    nb_processes = options.nb_processes or 1

    if nb_processes == 1:
        single_threaded_tiling(input_file, output_folder, options)
    else:
        multi_threaded_tiling(input_file, output_folder, options) 
Example #2
Source File: gdal2tiles_parallel.py    From geopackage-python with GNU General Public License v3.0 4 votes vote down vote up
def main(argv=None):
    argv = gdal.GeneralCmdLineProcessor(sys_argv)
    if argv:
        gdal2tiles = GDAL2Tiles(argv[1:])  # handle command line options

        print("Begin metadata generation complete.")
        p = Process(target=worker_metadata, args=[argv])
        p.start()
        p.join()
        print("Metadata generation complete.")

        pool = Pool()
        #processed_tiles = 0
        print("Generating Base Tiles:")
        for cpu in range(gdal2tiles.options.processes):
            pool.apply_async(worker_base_tiles,
                             [argv, cpu],
                             callback=worker_callback)
        pool.close()
        # This progress code does not work. The queue deadlocks the pool.join() call.
        #while len(active_children()) != 0:
        #   try:
        #       total = queue.get(timeout=1)
        #       processed_tiles += 1
        #       gdal.TermProgress_nocb(processed_tiles / float(total))
        #       stdout.flush()
        #   except:
        #       pass
        pool.join()
        print("Base tile generation complete.")

        #processed_tiles = 0
        tminz, tmaxz = getZooms(gdal2tiles)
        print("Generating Overview Tiles:")
        for tz in range(tmaxz - 1, tminz - 1, -1):
            print("\tGenerating for zoom level: " + str(tz))
            pool = Pool()
            for cpu in range(gdal2tiles.options.processes):
                pool.apply_async(worker_overview_tiles, [argv, cpu, tz])
            pool.close()
            #while len(active_children()) != 0:
            #   try:
            #       total = queue.get(timeout=1)
            #       processed_tiles += 1
            #       gdal.TermProgress_nocb(processed_tiles / float(total))
            #       stdout.flush()
            #   except:
            #       pass
            pool.join()
            print("\tZoom level " + str(tz) + " complete.")
        print("Overview tile generation complete")