本文整理汇总了Python中test_cli_utilities.get_gdal_translate_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_gdal_translate_path函数的具体用法?Python get_gdal_translate_path怎么用?Python get_gdal_translate_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_gdal_translate_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_gdalwarp_34
def test_gdalwarp_34():
if test_cli_utilities.get_gdalwarp_path() is None:
pytest.skip()
if test_cli_utilities.get_gdal_translate_path() is None:
pytest.skip()
try:
os.remove('tmp/testgdalwarp34.tif')
except OSError:
pass
gdaltest.runexternal(test_cli_utilities.get_gdal_translate_path() + ' ../gcore/data/byte.tif tmp/testgdalwarp34src_1.tif -srcwin 0 0 10 20')
gdaltest.runexternal(test_cli_utilities.get_gdal_translate_path() + ' ../gcore/data/byte.tif tmp/testgdalwarp34src_2.tif -srcwin 10 0 10 20')
gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' tmp/testgdalwarp34src_1.tif tmp/testgdalwarp34src_2.tif tmp/testgdalwarp34.tif')
os.remove('tmp/testgdalwarp34src_1.tif')
os.remove('tmp/testgdalwarp34src_2.tif')
ds = gdal.Open('tmp/testgdalwarp34.tif')
cs = ds.GetRasterBand(1).Checksum()
gt = ds.GetGeoTransform()
xsize = ds.RasterXSize
ysize = ds.RasterYSize
ds = None
os.remove('tmp/testgdalwarp34.tif')
assert xsize == 20 and ysize == 20, 'bad dimensions'
assert cs == 4672, 'bad checksum'
expected_gt = (440720.0, 60.0, 0.0, 3751320.0, 0.0, -60.0)
for i in range(6):
assert abs(gt[i] - expected_gt[i]) <= 1e-5, 'bad gt'
示例2: test_gdal_translate_23
def test_gdal_translate_23():
if test_cli_utilities.get_gdal_translate_path() is None:
return 'skip'
gdaltest.runexternal(test_cli_utilities.get_gdal_translate_path() + ' -stats ../gcore/data/byte.tif tmp/test_gdal_translate_23.tif')
ds = gdal.Open('tmp/test_gdal_translate_23.tif')
md = ds.GetRasterBand(1).GetMetadata()
ds = None
if md['STATISTICS_MINIMUM'] != '74':
gdaltest.post_reason('STATISTICS_MINIMUM is wrong.')
print(md['STATISTICS_MINIMUM'])
return 'fail'
try:
os.stat('tmp/test_gdal_translate_23.tif.aux.xml')
gdaltest.post_reason('did not expect .aux.xml file presence')
return 'fail'
except OSError:
pass
gdal.Unlink('../gcore/data/byte.tif.aux.xml')
return 'success'
示例3: test_gdal_translate_32
def test_gdal_translate_32():
if test_cli_utilities.get_gdal_translate_path() is None:
return 'skip'
gdaltest.runexternal(test_cli_utilities.get_gdal_translate_path() + ' ../gcore/data/byte_rpc.tif tmp/test_gdal_translate_32.tif -srcwin 1 2 13 14 -outsize 150% 300%')
ds = gdal.Open('tmp/test_gdal_translate_32.tif')
md = ds.GetMetadata('RPC')
if abs(float(md['LINE_OFF']) - 47496) > 1e-5 or \
abs(float(md['LINE_SCALE']) - 47502) > 1e-5 or \
abs(float(md['SAMP_OFF']) - 19676.6923076923) > 1e-5 or \
abs(float(md['SAMP_SCALE']) - 19678.1538461538) > 1e-5:
gdaltest.post_reason('fail')
print(md)
return 'fail'
gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdal_translate_path() + ' ../gcore/data/byte_rpc.tif tmp/test_gdal_translate_32.tif -srcwin -10 -5 20 20')
ds = gdal.Open('tmp/test_gdal_translate_32.tif')
md = ds.GetMetadata('RPC')
if abs(float(md['LINE_OFF']) - (15834 - -5)) > 1e-5 or \
abs(float(md['LINE_SCALE']) - 15834) > 1e-5 or \
abs(float(md['SAMP_OFF']) - (13464 - -10)) > 1e-5 or \
abs(float(md['SAMP_SCALE']) - 13464) > 1e-5:
gdaltest.post_reason('fail')
print(md)
return 'fail'
return 'success'
示例4: test_gdal_translate_38
def test_gdal_translate_38():
if test_cli_utilities.get_gdal_translate_path() is None:
return 'skip'
gdaltest.runexternal(test_cli_utilities.get_gdal_translate_path() + ' -q -of hfa tmp/test_gdal_translate_37.tif tmp/test_gdal_translate_38.img')
ds = gdal.Open('tmp/test_gdal_translate_38.img')
if ds is None:
return 'fail'
rat = ds.GetRasterBand(1).GetDefaultRAT()
if not rat:
gdaltest.post_reason('Did not get RAT')
return 'fail'
if not rat.GetRowCount() == 256:
gdaltest.post_reason('RAT has incorrect row count')
return 'fail'
if rat.GetTableType() != 0:
gdaltest.post_reason('RAT not thematic')
return 'fail'
rat = None
ds = None
return 'success'
示例5: test_gdal_translate_8
def test_gdal_translate_8():
if test_cli_utilities.get_gdal_translate_path() is None:
return 'skip'
gdaltest.runexternal(test_cli_utilities.get_gdal_translate_path() + ' -a_srs EPSG:26711 -gcp 0 0 440720.000 3751320.000 -gcp 20 0 441920.000 3751320.000 -gcp 20 20 441920.000 3750120.000 0 -gcp 0 20 440720.000 3750120.000 ../gcore/data/byte.tif tmp/test8.tif')
ds = gdal.Open('tmp/test8.tif')
if ds is None:
return 'fail'
if ds.GetRasterBand(1).Checksum() != 4672:
gdaltest.post_reason('Bad checksum')
return 'fail'
gcps = ds.GetGCPs()
if len(gcps) != 4:
gdaltest.post_reason('GCP count wrong.')
return 'fail'
if ds.GetGCPProjection().find('26711') == -1:
gdaltest.post_reason('Bad GCP projection.')
return 'fail'
ds = None
return 'success'
示例6: vrtmisc_9
def vrtmisc_9():
import test_cli_utilities
if test_cli_utilities.get_gdal_translate_path() is None:
return 'skip'
# -scale and -exponent repeated as many times as output band number
gdaltest.runexternal(test_cli_utilities.get_gdal_translate_path() + ' -of VRT data/byte.tif tmp/vrtmisc_9.vrt -scale 0 255 0 255 -scale 74 255 0 255 -exponent 1 -exponent 2.2 -b 1 -b 1')
ds = gdal.Open('tmp/vrtmisc_9.vrt')
cs1 = ds.GetRasterBand(1).Checksum()
cs2 = ds.GetRasterBand(2).Checksum()
ds = None
os.remove('tmp/vrtmisc_9.vrt')
if cs1 != 4672:
gdaltest.post_reason('did not get expected checksum')
print(cs1)
return 'fail'
if cs2 != 4159:
gdaltest.post_reason('did not get expected checksum')
print(cs2)
return 'fail'
return 'success'
示例7: test_gdalbuildvrt_14
def test_gdalbuildvrt_14():
if test_cli_utilities.get_gdalbuildvrt_path() is None:
return "skip"
if test_cli_utilities.get_gdal_translate_path() is None:
return "skip"
gdaltest.runexternal(
test_cli_utilities.get_gdalbuildvrt_path()
+ " tmp/test_gdalbuildvrt_14.vrt ../gcore/data/byte.tif -r cubic -tr 30 30"
)
gdaltest.runexternal(
test_cli_utilities.get_gdal_translate_path()
+ " -of VRT ../gcore/data/byte.tif tmp/test_gdalbuildvrt_14_ref.vrt -r cubic -outsize 40 40"
)
ds = gdal.Open("tmp/test_gdalbuildvrt_14.vrt")
ds_ref = gdal.Open("tmp/test_gdalbuildvrt_14_ref.vrt")
cs = ds.GetRasterBand(1).Checksum()
cs_ref = ds_ref.GetRasterBand(1).Checksum()
ds = None
ds_ref = None
if cs != cs_ref:
gdaltest.post_reason("fail")
print(cs)
print(cs_ref)
return "fail"
return "success"
示例8: test_gdal_translate_8
def test_gdal_translate_8():
if test_cli_utilities.get_gdal_translate_path() is None:
return "skip"
gdaltest.runexternal(
test_cli_utilities.get_gdal_translate_path()
+ " -a_srs EPSG:26711 -gcp 0 0 440720.000 3751320.000 -gcp 20 0 441920.000 3751320.000 -gcp 20 20 441920.000 3750120.000 0 -gcp 0 20 440720.000 3750120.000 ../gcore/data/byte.tif tmp/test8.tif"
)
ds = gdal.Open("tmp/test8.tif")
if ds is None:
return "fail"
if ds.GetRasterBand(1).Checksum() != 4672:
gdaltest.post_reason("Bad checksum")
return "fail"
gcps = ds.GetGCPs()
if len(gcps) != 4:
gdaltest.post_reason("GCP count wrong.")
return "fail"
if ds.GetGCPProjection().find("26711") == -1:
gdaltest.post_reason("Bad GCP projection.")
return "fail"
ds = None
return "success"
示例9: test_gdal_translate_12
def test_gdal_translate_12():
if test_cli_utilities.get_gdal_translate_path() is None:
return "skip"
gdaltest.runexternal(
test_cli_utilities.get_gdal_translate_path()
+ " -a_ullr 440720.000 3751320.000 441920.000 3750120.000 ../gcore/data/byte.tif tmp/test12.tif"
)
ds = gdal.Open("tmp/test12.tif")
if ds is None:
return "fail"
if ds.GetRasterBand(1).Checksum() != 4672:
gdaltest.post_reason("Bad checksum")
return "fail"
if not gdaltest.geotransform_equals(
gdal.Open("../gcore/data/byte.tif").GetGeoTransform(), ds.GetGeoTransform(), 1e-9
):
gdaltest.post_reason("Bad geotransform")
return "fail"
ds = None
return "success"
示例10: test_gdal_translate_35
def test_gdal_translate_35():
if test_cli_utilities.get_gdal_translate_path() is None:
return "skip"
(out, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdal_translate_path())
if err.find("No source dataset specified") < 0:
gdaltest.post_reason("fail")
print(err)
return "fail"
(out, err) = gdaltest.runexternal_out_and_err(
test_cli_utilities.get_gdal_translate_path() + " ../gcore/data/byte.tif"
)
if err.find("No target dataset specified") < 0:
gdaltest.post_reason("fail")
print(err)
return "fail"
(out, err) = gdaltest.runexternal_out_and_err(
test_cli_utilities.get_gdal_translate_path() + " /non_existing_path/non_existing.tif /vsimem/out.tif"
)
if err.find("does not exist in the file system") < 0:
gdaltest.post_reason("fail")
print(err)
return "fail"
(out, err) = gdaltest.runexternal_out_and_err(
test_cli_utilities.get_gdal_translate_path() + " ../gcore/data/byte.tif /non_existing_path/non_existing.tif"
)
if err.find("Attempt to create new tiff file") < 0:
gdaltest.post_reason("fail")
print(err)
return "fail"
return "success"
示例11: test_gdal_translate_4
def test_gdal_translate_4():
if test_cli_utilities.get_gdal_translate_path() is None:
return "skip"
gdaltest.runexternal(
test_cli_utilities.get_gdal_translate_path() + " -b 3 -b 2 -b 1 ../gcore/data/rgbsmall.tif tmp/test4.tif"
)
ds = gdal.Open("tmp/test4.tif")
if ds is None:
return "fail"
if ds.GetRasterBand(1).Checksum() != 21349:
gdaltest.post_reason("Bad checksum")
return "fail"
if ds.GetRasterBand(2).Checksum() != 21053:
gdaltest.post_reason("Bad checksum")
return "fail"
if ds.GetRasterBand(3).Checksum() != 21212:
gdaltest.post_reason("Bad checksum")
return "fail"
ds = None
return "success"
示例12: test_gdal_translate_31
def test_gdal_translate_31():
if test_cli_utilities.get_gdal_translate_path() is None:
return "skip"
gdaltest.runexternal(
test_cli_utilities.get_gdal_translate_path()
+ " -projwin_srs EPSG:4267 -projwin -117.641168620797 33.9023526904262 -117.628110837847 33.8915970129613 ../gcore/data/byte.tif tmp/test_gdal_translate_31.tif"
)
ds = gdal.Open("tmp/test_gdal_translate_31.tif")
if ds is None:
return "fail"
if ds.GetRasterBand(1).Checksum() != 4672:
gdaltest.post_reason("Bad checksum")
return "fail"
if not gdaltest.geotransform_equals(
gdal.Open("../gcore/data/byte.tif").GetGeoTransform(), ds.GetGeoTransform(), 1e-7
):
gdaltest.post_reason("Bad geotransform")
return "fail"
ds = None
return "success"
示例13: test_gdalwarp_5
def test_gdalwarp_5():
if test_cli_utilities.get_gdalwarp_path() is None:
return 'skip'
if test_cli_utilities.get_gdal_translate_path() is None:
return 'skip'
gdaltest.runexternal(test_cli_utilities.get_gdal_translate_path() + ' -a_srs EPSG:26711 -gcp 0 0 440720.000 3751320.000 -gcp 20 0 441920.000 3751320.000 -gcp 20 20 441920.000 3750120.000 0 -gcp 0 20 440720.000 3750120.000 ../gcore/data/byte.tif tmp/testgdalwarp_gcp.tif')
gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' tmp/testgdalwarp_gcp.tif tmp/testgdalwarp5.tif')
ds = gdal.Open('tmp/testgdalwarp5.tif')
if ds is None:
return 'fail'
if ds.GetRasterBand(1).Checksum() != 4672:
gdaltest.post_reason('Bad checksum')
return 'fail'
if not gdaltest.geotransform_equals(gdal.Open('../gcore/data/byte.tif').GetGeoTransform(), ds.GetGeoTransform(), 1e-9) :
gdaltest.post_reason('Bad geotransform')
return 'fail'
ds = None
return 'success'
示例14: test_gdaldem_color_relief_from_float32
def test_gdaldem_color_relief_from_float32():
if test_cli_utilities.get_gdaldem_path() is None:
return 'skip'
if test_cli_utilities.get_gdal_translate_path() is None:
return 'skip'
gdaltest.runexternal(test_cli_utilities.get_gdal_translate_path() + ' -ot Float32 ../gdrivers/data/n43.dt0 tmp/n43_float32.tif')
gdaltest.runexternal(test_cli_utilities.get_gdaldem_path() + ' color-relief tmp/n43_float32.tif data/color_file.txt tmp/n43_colorrelief_from_float32.tif')
ds = gdal.Open('tmp/n43_colorrelief_from_float32.tif')
if ds is None:
return 'fail'
if ds.GetRasterBand(1).Checksum() != 55009:
print(ds.GetRasterBand(1).Checksum())
gdaltest.post_reason('Bad checksum')
return 'fail'
if ds.GetRasterBand(2).Checksum() != 37543:
print(ds.GetRasterBand(2).Checksum())
gdaltest.post_reason('Bad checksum')
return 'fail'
if ds.GetRasterBand(3).Checksum() != 47711:
print(ds.GetRasterBand(3).Checksum())
gdaltest.post_reason('Bad checksum')
return 'fail'
ds = None
return 'success'
示例15: vrtmisc_4
def vrtmisc_4():
import test_cli_utilities
if test_cli_utilities.get_gdal_translate_path() is None:
return 'skip'
# -scale specified once applies to all bands
gdaltest.runexternal(test_cli_utilities.get_gdal_translate_path() + ' -of VRT data/byte.tif tmp/vrtmisc_4.vrt -scale 74 255 0 255 -b 1 -b 1')
ds = gdal.Open('tmp/vrtmisc_4.vrt')
cs1 = ds.GetRasterBand(1).Checksum()
cs2 = ds.GetRasterBand(2).Checksum()
ds = None
os.remove('tmp/vrtmisc_4.vrt')
if cs1 != 4323:
gdaltest.post_reason('did not get expected checksum')
print(cs1)
return 'fail'
if cs2 != 4323:
gdaltest.post_reason('did not get expected checksum')
print(cs2)
return 'fail'
return 'success'