Example #1
0
def test_gdaladdo_3():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    gdal.Translate('tmp/test_gdaladdo_3.tif', '../gcore/data/nodata_byte.tif', options='-outsize 1024 1024')

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' -ro tmp/test_gdaladdo_3.tif 2')

    ds = gdal.Open('tmp/test_gdaladdo_3.tif')
    cs = ds.GetRasterBand(1).GetOverview(0).Checksum()
    exp_cs = 20683

    if cs != exp_cs:
        gdaltest.post_reason('got wrong overview checksum.')
        print(exp_cs, cs)
        return 'fail'

    ds = None

    try:
        os.stat('tmp/test_gdaladdo_3.tif.ovr')
    except OSError:
        gdaltest.post_reason('no external overview.')
        return 'fail'

    return 'success'
Example #2
0
def test_gdaladdo_3():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    shutil.copyfile( '../gcore/data/nodata_byte.tif', 'tmp/test_gdaladdo_3.tif' )

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' -ro tmp/test_gdaladdo_3.tif 2')

    ds = gdal.Open('tmp/test_gdaladdo_3.tif')
    cs = ds.GetRasterBand(1).GetOverview(0).Checksum()
    exp_cs = 1152

    if cs != exp_cs:
        gdaltest.post_reason( 'got wrong overview checksum.' )
        print(exp_cs, cs)
        return 'fail'

    ds = None

    try:
        os.stat('tmp/test_gdaladdo_3.tif.ovr')
    except:
        gdaltest.post_reason( 'no external overview.' )
        return 'fail'

    return 'success'
Example #3
0
def test_gdaladdo_4():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() +
                         ' -clean tmp/test_gdaladdo_3.tif')

    ds = gdal.Open('tmp/test_gdaladdo_3.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    if cnt != 0:
        gdaltest.post_reason('did not clean overviews.')
        return 'fail'

    try:
        os.stat('tmp/test_gdaladdo_3.tif.ovr')
        gdaltest.post_reason('.ovr file still exists')
        return 'fail'
    except:
        pass

    os.remove('tmp/test_gdaladdo_3.tif')

    return 'success'
Example #4
0
def test_gdaladdo_3():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    gdal.Translate( 'tmp/test_gdaladdo_3.tif', '../gcore/data/nodata_byte.tif', options = '-outsize 1024 1024' )

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' -ro tmp/test_gdaladdo_3.tif 2')

    ds = gdal.Open('tmp/test_gdaladdo_3.tif')
    cs = ds.GetRasterBand(1).GetOverview(0).Checksum()
    exp_cs = 20683

    if cs != exp_cs:
        gdaltest.post_reason( 'got wrong overview checksum.' )
        print(exp_cs, cs)
        return 'fail'

    ds = None

    try:
        os.stat('tmp/test_gdaladdo_3.tif.ovr')
    except:
        gdaltest.post_reason( 'no external overview.' )
        return 'fail'

    return 'success'
Example #5
0
def test_gdaladdo_5():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    shutil.copyfile('../gcore/data/nodata_byte.tif', 'tmp/test_gdaladdo_5.tif')

    # Will not do anything given than the file is smaller than 256x256 already
    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() +
                         ' tmp/test_gdaladdo_5.tif')

    ds = gdal.Open('tmp/test_gdaladdo_5.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    if cnt != 0:
        gdaltest.post_reason('fail')
        print(cnt)
        return 'fail'

    # Will generate overviews of size 10 5 3 2 1
    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() +
                         ' -minsize 1 tmp/test_gdaladdo_5.tif')

    ds = gdal.Open('tmp/test_gdaladdo_5.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    if cnt != 5:
        gdaltest.post_reason('fail')
        print(cnt)
        return 'fail'

    gdal.Translate('tmp/test_gdaladdo_5.tif',
                   '../gcore/data/nodata_byte.tif',
                   options='-outsize 257 257')

    # Will generate overviews of size 129x129
    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() +
                         ' tmp/test_gdaladdo_5.tif')

    ds = gdal.Open('tmp/test_gdaladdo_5.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    if cnt != 1:
        gdaltest.post_reason('fail')
        print(cnt)
        return 'fail'

    os.remove('tmp/test_gdaladdo_5.tif')

    return 'success'
Example #6
0
def test_gdaladdo_4():
    if test_cli_utilities.get_gdaladdo_path() is None:
        pytest.skip()

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() +
                         ' -clean tmp/test_gdaladdo_3.tif')

    ds = gdal.Open('tmp/test_gdaladdo_3.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    assert cnt == 0, 'did not clean overviews.'

    assert not os.path.exists('tmp/test_gdaladdo_3.tif.ovr')

    os.remove('tmp/test_gdaladdo_3.tif')
Example #7
0
def test_gdaladdo_5():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    shutil.copyfile('../gcore/data/nodata_byte.tif', 'tmp/test_gdaladdo_5.tif')

    # Will not do anything given than the file is smaller than 256x256 already
    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' tmp/test_gdaladdo_5.tif')

    ds = gdal.Open('tmp/test_gdaladdo_5.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    if cnt != 0:
        gdaltest.post_reason('fail')
        print(cnt)
        return 'fail'

    # Will generate overviews of size 10 5 3 2 1
    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' -minsize 1 tmp/test_gdaladdo_5.tif')

    ds = gdal.Open('tmp/test_gdaladdo_5.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    if cnt != 5:
        gdaltest.post_reason('fail')
        print(cnt)
        return 'fail'

    gdal.Translate('tmp/test_gdaladdo_5.tif', '../gcore/data/nodata_byte.tif', options='-outsize 257 257')

    # Will generate overviews of size 129x129
    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' tmp/test_gdaladdo_5.tif')

    ds = gdal.Open('tmp/test_gdaladdo_5.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    if cnt != 1:
        gdaltest.post_reason('fail')
        print(cnt)
        return 'fail'

    os.remove('tmp/test_gdaladdo_5.tif')

    return 'success'
Example #8
0
def test_gdaladdo_4():
    if test_cli_utilities.get_gdaladdo_path() is None:
        pytest.skip()

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() +
                         ' -clean tmp/test_gdaladdo_3.tif')

    ds = gdal.Open('tmp/test_gdaladdo_3.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    assert cnt == 0, 'did not clean overviews.'

    with pytest.raises(OSError, message='.ovr file still exists'):
        os.stat('tmp/test_gdaladdo_3.tif.ovr')

    os.remove('tmp/test_gdaladdo_3.tif')
Example #9
0
def test_gdaladdo_2():
    if test_cli_utilities.get_gdaladdo_path() is None:
        pytest.skip()

    shutil.copyfile('../gcore/data/nodata_byte.tif', 'tmp/ovr5.tif')

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' -r average tmp/ovr5.tif 2')

    ds = gdal.Open('tmp/ovr5.tif')
    cs = ds.GetRasterBand(1).GetOverview(0).Checksum()
    exp_cs = 1130

    assert cs == exp_cs, 'got wrong overview checksum.'

    ds = None

    os.remove('tmp/ovr5.tif')
Example #10
0
def test_gdaladdo_4():
    if test_cli_utilities.get_gdaladdo_path() is None:
        pytest.skip()

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' -clean tmp/test_gdaladdo_3.tif')

    ds = gdal.Open('tmp/test_gdaladdo_3.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    assert cnt == 0, 'did not clean overviews.'

    with pytest.raises(OSError, message='.ovr file still exists'):
        os.stat('tmp/test_gdaladdo_3.tif.ovr')
    

    os.remove('tmp/test_gdaladdo_3.tif')
Example #11
0
def test_gdaladdo_2():
    if test_cli_utilities.get_gdaladdo_path() is None:
        pytest.skip()

    shutil.copyfile('../gcore/data/nodata_byte.tif', 'tmp/ovr5.tif')

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() +
                         ' -r average tmp/ovr5.tif 2')

    ds = gdal.Open('tmp/ovr5.tif')
    cs = ds.GetRasterBand(1).GetOverview(0).Checksum()
    exp_cs = 1130

    assert cs == exp_cs, 'got wrong overview checksum.'

    ds = None

    os.remove('tmp/ovr5.tif')
Example #12
0
def test_gdaladdo_1():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    shutil.copy('../gcore/data/mfloat32.vrt', 'tmp/mfloat32.vrt')
    shutil.copy('../gcore/data/float32.tif', 'tmp/float32.tif')

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' tmp/mfloat32.vrt 2 4')

    ds = gdal.Open('tmp/mfloat32.vrt')
    ret = tiff_ovr.tiff_ovr_check(ds)
    ds = None

    os.remove('tmp/mfloat32.vrt')
    os.remove('tmp/mfloat32.vrt.ovr')
    os.remove('tmp/float32.tif')

    return ret
Example #13
0
def test_gdaladdo_1():
    if test_cli_utilities.get_gdaladdo_path() is None:
        pytest.skip()

    shutil.copy('../gcore/data/mfloat32.vrt', 'tmp/mfloat32.vrt')
    shutil.copy('../gcore/data/float32.tif', 'tmp/float32.tif')

    (_, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaladdo_path() + ' tmp/mfloat32.vrt 2 4')
    assert (err is None or err == ''), 'got error/warning'

    ds = gdal.Open('tmp/mfloat32.vrt')
    ret = tiff_ovr.tiff_ovr_check(ds)
    ds = None

    os.remove('tmp/mfloat32.vrt')
    os.remove('tmp/mfloat32.vrt.ovr')
    os.remove('tmp/float32.tif')

    return ret
Example #14
0
def test_gdaladdo_1():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    shutil.copy('../gcore/data/mfloat32.vrt', 'tmp/mfloat32.vrt')
    shutil.copy('../gcore/data/float32.tif', 'tmp/float32.tif')

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() +
                         ' tmp/mfloat32.vrt 2 4')

    ds = gdal.Open('tmp/mfloat32.vrt')
    ret = tiff_ovr.tiff_ovr_check(ds)
    ds = None

    os.remove('tmp/mfloat32.vrt')
    os.remove('tmp/mfloat32.vrt.ovr')
    os.remove('tmp/float32.tif')

    return ret
Example #15
0
def test_gdaladdo_3():
    if test_cli_utilities.get_gdaladdo_path() is None:
        pytest.skip()

    gdal.Translate('tmp/test_gdaladdo_3.tif', '../gcore/data/nodata_byte.tif', options='-outsize 1024 1024')

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' -ro tmp/test_gdaladdo_3.tif 2')

    ds = gdal.Open('tmp/test_gdaladdo_3.tif')
    cs = ds.GetRasterBand(1).GetOverview(0).Checksum()
    exp_cs = 20683

    assert cs == exp_cs, 'got wrong overview checksum.'

    ds = None

    try:
        os.stat('tmp/test_gdaladdo_3.tif.ovr')
    except OSError:
        pytest.fail('no external overview.')
Example #16
0
def test_gdaladdo_1():
    if test_cli_utilities.get_gdaladdo_path() is None:
        pytest.skip()

    shutil.copy('../gcore/data/mfloat32.vrt', 'tmp/mfloat32.vrt')
    shutil.copy('../gcore/data/float32.tif', 'tmp/float32.tif')

    (_, err) = gdaltest.runexternal_out_and_err(
        test_cli_utilities.get_gdaladdo_path() + ' tmp/mfloat32.vrt 2 4')
    assert (err is None or err == ''), 'got error/warning'

    ds = gdal.Open('tmp/mfloat32.vrt')
    ret = tiff_ovr.tiff_ovr_check(ds)
    ds = None

    os.remove('tmp/mfloat32.vrt')
    os.remove('tmp/mfloat32.vrt.ovr')
    os.remove('tmp/float32.tif')

    return ret
Example #17
0
def test_gdaladdo_5():
    if test_cli_utilities.get_gdaladdo_path() is None:
        pytest.skip()

    shutil.copyfile('../gcore/data/nodata_byte.tif', 'tmp/test_gdaladdo_5.tif')

    # Will not do anything given than the file is smaller than 256x256 already
    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() +
                         ' tmp/test_gdaladdo_5.tif')

    ds = gdal.Open('tmp/test_gdaladdo_5.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    assert cnt == 0

    # Will generate overviews of size 10 5 3 2 1
    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() +
                         ' -minsize 1 tmp/test_gdaladdo_5.tif')

    ds = gdal.Open('tmp/test_gdaladdo_5.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    assert cnt == 5

    gdal.Translate('tmp/test_gdaladdo_5.tif',
                   '../gcore/data/nodata_byte.tif',
                   options='-outsize 257 257')

    # Will generate overviews of size 129x129
    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() +
                         ' tmp/test_gdaladdo_5.tif')

    ds = gdal.Open('tmp/test_gdaladdo_5.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    assert cnt == 1

    os.remove('tmp/test_gdaladdo_5.tif')
Example #18
0
def test_gdaladdo_2():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    shutil.copyfile('../gcore/data/nodata_byte.tif', 'tmp/ovr5.tif')

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' -r average tmp/ovr5.tif 2')

    ds = gdal.Open('tmp/ovr5.tif')
    cs = ds.GetRasterBand(1).GetOverview(0).Checksum()
    exp_cs = 1130

    if cs != exp_cs:
        gdaltest.post_reason('got wrong overview checksum.')
        print(exp_cs, cs)
        return 'fail'

    ds = None

    os.remove('tmp/ovr5.tif')

    return 'success'
Example #19
0
def test_gdaladdo_1():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    shutil.copy('../gcore/data/mfloat32.vrt', 'tmp/mfloat32.vrt')
    shutil.copy('../gcore/data/float32.tif', 'tmp/float32.tif')

    (_, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaladdo_path() + ' tmp/mfloat32.vrt 2 4')
    if not (err is None or err == ''):
        gdaltest.post_reason('got error/warning')
        print(err)
        return 'fail'

    ds = gdal.Open('tmp/mfloat32.vrt')
    ret = tiff_ovr.tiff_ovr_check(ds)
    ds = None

    os.remove('tmp/mfloat32.vrt')
    os.remove('tmp/mfloat32.vrt.ovr')
    os.remove('tmp/float32.tif')

    return ret
Example #20
0
def test_gdaladdo_1():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    shutil.copy('../gcore/data/mfloat32.vrt', 'tmp/mfloat32.vrt')
    shutil.copy('../gcore/data/float32.tif', 'tmp/float32.tif')

    (out, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaladdo_path() + ' tmp/mfloat32.vrt 2 4')
    if not (err is None or err == '') :
        gdaltest.post_reason('got error/warning')
        print(err)
        return 'fail'

    ds = gdal.Open('tmp/mfloat32.vrt')
    ret = tiff_ovr.tiff_ovr_check(ds)
    ds = None

    os.remove('tmp/mfloat32.vrt')
    os.remove('tmp/mfloat32.vrt.ovr')
    os.remove('tmp/float32.tif')

    return ret
Example #21
0
def test_gdaladdo_2():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    shutil.copyfile( '../gcore/data/nodata_byte.tif', 'tmp/ovr5.tif' )

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' -r average tmp/ovr5.tif 2')

    ds = gdal.Open('tmp/ovr5.tif')
    cs = ds.GetRasterBand(1).GetOverview(0).Checksum()
    exp_cs = 1130

    if cs != exp_cs:
        gdaltest.post_reason( 'got wrong overview checksum.' )
        print(exp_cs, cs)
        return 'fail'

    ds = None

    os.remove('tmp/ovr5.tif')

    return 'success'
Example #22
0
def test_gdaladdo_3():
    if test_cli_utilities.get_gdaladdo_path() is None:
        pytest.skip()

    gdal.Translate('tmp/test_gdaladdo_3.tif',
                   '../gcore/data/nodata_byte.tif',
                   options='-outsize 1024 1024')

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() +
                         ' -ro tmp/test_gdaladdo_3.tif 2')

    ds = gdal.Open('tmp/test_gdaladdo_3.tif')
    cs = ds.GetRasterBand(1).GetOverview(0).Checksum()
    exp_cs = 20683

    assert cs == exp_cs, 'got wrong overview checksum.'

    ds = None

    try:
        os.stat('tmp/test_gdaladdo_3.tif.ovr')
    except OSError:
        pytest.fail('no external overview.')
Example #23
0
def test_gdaladdo_5():
    if test_cli_utilities.get_gdaladdo_path() is None:
        pytest.skip()

    shutil.copyfile('../gcore/data/nodata_byte.tif', 'tmp/test_gdaladdo_5.tif')

    # Will not do anything given than the file is smaller than 256x256 already
    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' tmp/test_gdaladdo_5.tif')

    ds = gdal.Open('tmp/test_gdaladdo_5.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    assert cnt == 0

    # Will generate overviews of size 10 5 3 2 1
    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' -minsize 1 tmp/test_gdaladdo_5.tif')

    ds = gdal.Open('tmp/test_gdaladdo_5.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    assert cnt == 5

    gdal.Translate('tmp/test_gdaladdo_5.tif', '../gcore/data/nodata_byte.tif', options='-outsize 257 257')

    # Will generate overviews of size 129x129
    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' tmp/test_gdaladdo_5.tif')

    ds = gdal.Open('tmp/test_gdaladdo_5.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    assert cnt == 1

    os.remove('tmp/test_gdaladdo_5.tif')
Example #24
0
def test_gdaladdo_4():
    if test_cli_utilities.get_gdaladdo_path() is None:
        return 'skip'

    gdaltest.runexternal(test_cli_utilities.get_gdaladdo_path() + ' -clean tmp/test_gdaladdo_3.tif')

    ds = gdal.Open('tmp/test_gdaladdo_3.tif')
    cnt = ds.GetRasterBand(1).GetOverviewCount()
    ds = None

    if cnt != 0:
        gdaltest.post_reason('did not clean overviews.')
        return 'fail'

    try:
        os.stat('tmp/test_gdaladdo_3.tif.ovr')
        gdaltest.post_reason('.ovr file still exists')
        return 'fail'
    except OSError:
        pass

    os.remove('tmp/test_gdaladdo_3.tif')

    return 'success'