def main(argv): #---------------------------- global options (options, args) = parse_args(argv[1:]) logging.basicConfig(level=logging.DEBUG if options.verbose == 2 else (logging.ERROR if options.verbose == 0 else logging.INFO)) ld(os.name) ld(options) if options.list_profiles: Pyramid.profile_lst(tty=True) return if not args: logging.error('No input file(s) specified') sys.exit(1) if options.verbose == 2: set_nothreads() if options.release: options.overview_resampling, options.base_resampling = ('antialias', 'cubic') res = parallel_map(preprocess_src, args) parallel_map(process_src, flatten(res))
def main(argv): #---------------------------- global options (options, args) = parse_args(argv[1:]) logging.basicConfig(level=logging.DEBUG if options.verbose == 2 else ( logging.ERROR if options.verbose == 0 else logging.INFO)) ld(os.name) ld(options) if options.list_profiles: Pyramid.profile_lst(tty=True) return if not args: logging.error('No input file(s) specified') sys.exit(1) if options.verbose == 2: set_nothreads() if options.release: options.overview_resampling, options.base_resampling = ('antialias', 'cubic') res = parallel_map(preprocess_src, args) parallel_map(process_src, flatten(res))
def __init__(self, arguments): #---------------------------- logGdalTiler = logging.getLogger('gdaltiler.init') try: (options, args) = self.parse_args(arguments) # logging.basicConfig(level=logging.DEBUG if options.verbose == 2 else # (logging.ERROR if options.verbose == 0 else logging.INFO)) # ld(os.name) # ld(options) if options.verbose == 2: set_nothreads() if options.list_profiles: Pyramid.profile_lst(tty=True) sys.exit(0) if options.release: options.overview_resampling, options.base_resampling = ( 'antialias', 'cubic') try: sources = args except: raise Exception("No sources specified") srcOpt = [] for s in sources: srcOpt.append((s, options)) res = parallel_map(preprocess_src, srcOpt) srcDefOpt = [] for r in flatten(res): srcDefOpt.append((r[0], r[1], options)) logTile = logging.getLogger('landis.tiler') logTile.debug('Start tiling process with multiprocessing') parallel_map(process_src, srcDefOpt) logTile.debug('End tiling process with multiprocessing') except Exception as e: logGdalTiler.error('{}'.format(e)) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] logGdalTiler.debug('{}::{}::{}'.format(exc_type, fname, exc_tb.tb_lineno)) sys.exit()
def __init__(self, arguments): #---------------------------- logGdalTiler = logging.getLogger('gdaltiler.init') try: (options, args) = self.parse_args(arguments) # logging.basicConfig(level=logging.DEBUG if options.verbose == 2 else # (logging.ERROR if options.verbose == 0 else logging.INFO)) # ld(os.name) # ld(options) if options.verbose == 2: set_nothreads() if options.list_profiles: Pyramid.profile_lst(tty=True) sys.exit(0) if options.release: options.overview_resampling, options.base_resampling = ('antialias', 'cubic') try: sources = args except: raise Exception("No sources specified") srcOpt = [] for s in sources: srcOpt.append((s, options)) res = parallel_map(preprocess_src, srcOpt) srcDefOpt = [] for r in flatten(res): srcDefOpt.append((r[0], r[1], options)) logTile = logging.getLogger('landis.tiler') logTile.debug('Start tiling process with multiprocessing') parallel_map(process_src, srcDefOpt) logTile.debug('End tiling process with multiprocessing') except Exception as e: logGdalTiler.error('{}'.format(e)) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] logGdalTiler.debug('{}::{}::{}'.format(exc_type, fname, exc_tb.tb_lineno)) sys.exit()
def parse_args(arg_lst): #---------------------------- parser = OptionParser( usage = "usage: %prog <options>... source...", version=version, description='Tile cutter for GDAL-compatible raster maps') parser.add_option('-p', '--profile', '--to', dest="profile", metavar='PROFILE', default='zyx', choices=Pyramid.profile_lst(), help='output tiles profile (default: zyx)') parser.add_option("-f", "--list-profiles", action="store_true", help='list tile profiles') parser.add_option("-z", "--zoom", default=None, metavar="ZOOM_LIST", help='list of zoom ranges to generate') parser.add_option("--srs", default=None, metavar="SOURCE_SRS", help="override source's spatial reference system") parser.add_option("--tiles-srs", default=None, metavar="TILES_SRS", help="target SRS for generic profile") parser.add_option("--tile-size", default='256,256', metavar="SIZE_X,SIZE_Y", help='generic profile: tile size (default: 256,256)') parser.add_option("--zoom0-tiles", default='1,1', metavar="NTILES_X,NTILES_Y", help='generic profile: number of tiles along the axis at the zoom 0 (default: 1,1)') parser.add_option('--overview-resampling', default='nearest', metavar="METHOD1", choices=resampling_lst(), help='overview tiles resampling method (default: nearest)') parser.add_option('--base-resampling', default='nearest', metavar="METHOD2", choices=base_resampling_lst(), help='base image resampling method (default: nearest)') parser.add_option('-r', '--release', action="store_true", help='set resampling options to (antialias,bilinear)') parser.add_option('--tps', action="store_true", help='Force use of thin plate spline transformer based on available GCPs)') parser.add_option("-c", "--cut", action="store_true", help='cut the raster as per cutline provided either by source or by "--cutline" option') parser.add_option("--cutline", default=None, metavar="DATASOURCE", help='cutline data: OGR datasource') parser.add_option("--cutline-match-name", action="store_true", help='match OGR feature field "Name" against source name') parser.add_option("--cutline-blend", dest="blend_dist", default=None, metavar="N", help='CUTLINE_BLEND_DIST in pixels') parser.add_option("--src-nodata", dest="src_nodata", metavar='N[,N]...', help='Nodata values for input bands') parser.add_option("--dst-nodata", dest="dst_nodata", metavar='N', help='Assign nodata value for output paletted band') parser.add_option("--tiles-prefix", default='', metavar="URL", help='prefix for tile URLs at googlemaps.hml') parser.add_option("--tile-format", default='png', metavar="FMT", help='tile image format (default: png)') parser.add_option("--paletted", action="store_true", help='convert tiles to paletted format (8 bit/pixel)') parser.add_option("-t", "--dest-dir", dest="dest_dir", default=None, help='destination directory (default: source)') parser.add_option("--noclobber", action="store_true", help='skip processing if the target pyramid already exists') parser.add_option("-s", "--strip-dest-ext", action="store_true", help='do not add a default extension suffix from a destination directory') # parser.add_option("--viewer-copy", action="store_true", # help='on POSIX systems copy html viewer instead of hardlinking to the original location') parser.add_option("-q", "--quiet", action="store_const", const=0, default=1, dest="verbose") parser.add_option("-d", "--debug", action="store_const", const=2, dest="verbose") parser.add_option("-l", "--long-name", action="store_true", help='give an output file a long name') parser.add_option("-n", "--after-name", action="store_true", help='give an output file name after a map name (from metadata)') parser.add_option("-m", "--after-map", action="store_true", help='give an output file name after name of a map file, otherwise after a name of an image file') parser.add_option("--skip-invalid", action="store_true", help='skip invalid/unrecognized source') (options, args) = parser.parse_args(arg_lst) return (options, args)
def parse_args(arg_lst): #---------------------------- parser = OptionParser( usage="usage: %prog <options>... source...", version=version, description='Tile cutter for GDAL-compatible raster maps') parser.add_option('-p', '--profile', '--to', dest="profile", metavar='PROFILE', default='zyx', choices=Pyramid.profile_lst(), help='output tiles profile (default: zyx)') parser.add_option("-f", "--list-profiles", action="store_true", help='list tile profiles') parser.add_option("-z", "--zoom", default=None, metavar="ZOOM_LIST", help='list of zoom ranges to generate') parser.add_option("--srs", default=None, metavar="SOURCE_SRS", help="override source's spatial reference system") parser.add_option("--tiles-srs", default=None, metavar="TILES_SRS", help="target SRS for generic profile") parser.add_option("--tile-size", default='256,256', metavar="SIZE_X,SIZE_Y", help='generic profile: tile size (default: 256,256)') parser.add_option( "--zoom0-tiles", default='1,1', metavar="NTILES_X,NTILES_Y", help= 'generic profile: number of tiles along the axis at the zoom 0 (default: 1,1)' ) parser.add_option( '--overview-resampling', default='nearest', metavar="METHOD1", choices=resampling_lst(), help='overview tiles resampling method (default: nearest)') parser.add_option('--base-resampling', default='nearest', metavar="METHOD2", choices=base_resampling_lst(), help='base image resampling method (default: nearest)') parser.add_option('-r', '--release', action="store_true", help='set resampling options to (antialias,bilinear)') parser.add_option( '--tps', action="store_true", help= 'Force use of thin plate spline transformer based on available GCPs)') parser.add_option( "-c", "--cut", action="store_true", help= 'cut the raster as per cutline provided either by source or by "--cutline" option' ) parser.add_option("--cutline", default=None, metavar="DATASOURCE", help='cutline data: OGR datasource') parser.add_option( "--cutline-match-name", action="store_true", help='match OGR feature field "Name" against source name') parser.add_option("--cutline-blend", dest="blend_dist", default=None, metavar="N", help='CUTLINE_BLEND_DIST in pixels') parser.add_option("--src-nodata", dest="src_nodata", metavar='N[,N]...', help='Nodata values for input bands') parser.add_option("--dst-nodata", dest="dst_nodata", metavar='N', help='Assign nodata value for output paletted band') parser.add_option("--tiles-prefix", default='', metavar="URL", help='prefix for tile URLs at googlemaps.hml') parser.add_option("--tile-format", default='png', metavar="FMT", help='tile image format (default: png)') parser.add_option("--paletted", action="store_true", help='convert tiles to paletted format (8 bit/pixel)') parser.add_option("-t", "--dest-dir", dest="dest_dir", default=None, help='destination directory (default: source)') parser.add_option( "--noclobber", action="store_true", help='skip processing if the target pyramid already exists') parser.add_option( "-s", "--strip-dest-ext", action="store_true", help= 'do not add a default extension suffix from a destination directory') # parser.add_option("--viewer-copy", action="store_true", # help='on POSIX systems copy html viewer instead of hardlinking to the original location') parser.add_option("-q", "--quiet", action="store_const", const=0, default=1, dest="verbose") parser.add_option("-d", "--debug", action="store_const", const=2, dest="verbose") parser.add_option("-l", "--long-name", action="store_true", help='give an output file a long name') parser.add_option( "-n", "--after-name", action="store_true", help='give an output file name after a map name (from metadata)') parser.add_option( "-m", "--after-map", action="store_true", help= 'give an output file name after name of a map file, otherwise after a name of an image file' ) parser.add_option("--skip-invalid", action="store_true", help='skip invalid/unrecognized source') (options, args) = parser.parse_args(arg_lst) return (options, args)