kopia lustrzana https://github.com/OpenDroneMap/ODM
Add kmz output (#1268)
* Add flag check for kmz * Add generate_kmz * remove osparam from systemrun * Remove extra aaarg * Add orthophoto-kmz argument to parserpull/1273/head
rodzic
dbcc656b13
commit
38434e9184
|
@ -542,6 +542,14 @@ def config(argv=None, parser=None):
|
||||||
default=False,
|
default=False,
|
||||||
help='Set this parameter if you want to generate a PNG rendering of the orthophoto. '
|
help='Set this parameter if you want to generate a PNG rendering of the orthophoto. '
|
||||||
'Default: %(default)s')
|
'Default: %(default)s')
|
||||||
|
|
||||||
|
parser.add_argument('--orthophoto-kmz',
|
||||||
|
action=StoreTrue,
|
||||||
|
nargs=0,
|
||||||
|
default=False,
|
||||||
|
help='Set this parameter if you want to generate a Google Earth (KMZ) rendering of the orthophoto. '
|
||||||
|
'Default: %(default)s')
|
||||||
|
|
||||||
|
|
||||||
parser.add_argument('--orthophoto-compression',
|
parser.add_argument('--orthophoto-compression',
|
||||||
metavar='<string>',
|
metavar='<string>',
|
||||||
|
|
|
@ -54,7 +54,20 @@ def generate_png(orthophoto_file, output_file=None, outsize=None):
|
||||||
system.run('gdal_translate -of png "%s" "%s" %s %s '
|
system.run('gdal_translate -of png "%s" "%s" %s %s '
|
||||||
'--config GDAL_CACHEMAX %s%% ' % (orthophoto_file, output_file, osparam, bandparam, get_max_memory()))
|
'--config GDAL_CACHEMAX %s%% ' % (orthophoto_file, output_file, osparam, bandparam, get_max_memory()))
|
||||||
|
|
||||||
|
def generate_kmz(orthophoto_file, output_file=None, outsize=None):
|
||||||
|
if output_file is None:
|
||||||
|
base, ext = os.path.splitext(orthophoto_file)
|
||||||
|
output_file = base + '.kmz'
|
||||||
|
|
||||||
|
# See if we need to select top three bands
|
||||||
|
bandparam = ""
|
||||||
|
gtif = gdal.Open(orthophoto_file)
|
||||||
|
if gtif.RasterCount > 4:
|
||||||
|
bandparam = "-b 1 -b 2 -b 3 -a_nodata 0"
|
||||||
|
|
||||||
|
system.run('gdal_translate -of KMLSUPEROVERLAY -co FORMAT=JPEG "%s" "%s" %s '
|
||||||
|
'--config GDAL_CACHEMAX %s%% ' % (orthophoto_file, output_file, bandparam, get_max_memory()))
|
||||||
|
|
||||||
def post_orthophoto_steps(args, bounds_file_path, orthophoto_file, orthophoto_tiles_dir):
|
def post_orthophoto_steps(args, bounds_file_path, orthophoto_file, orthophoto_tiles_dir):
|
||||||
if args.crop > 0:
|
if args.crop > 0:
|
||||||
Cropper.crop(bounds_file_path, orthophoto_file, get_orthophoto_vars(args), keep_original=not args.optimize_disk_space, warp_options=['-dstalpha'])
|
Cropper.crop(bounds_file_path, orthophoto_file, get_orthophoto_vars(args), keep_original=not args.optimize_disk_space, warp_options=['-dstalpha'])
|
||||||
|
@ -64,6 +77,9 @@ def post_orthophoto_steps(args, bounds_file_path, orthophoto_file, orthophoto_ti
|
||||||
|
|
||||||
if args.orthophoto_png:
|
if args.orthophoto_png:
|
||||||
generate_png(orthophoto_file)
|
generate_png(orthophoto_file)
|
||||||
|
|
||||||
|
if args.orthophoto_kmz:
|
||||||
|
generate_kmz(orthophoto_file)
|
||||||
|
|
||||||
if args.tiles:
|
if args.tiles:
|
||||||
generate_orthophoto_tiles(orthophoto_file, orthophoto_tiles_dir, args.max_concurrency)
|
generate_orthophoto_tiles(orthophoto_file, orthophoto_tiles_dir, args.max_concurrency)
|
||||||
|
|
Ładowanie…
Reference in New Issue