def test_gcps2gt_1(): gt = gdal.GCPsToGeoTransform( _list2gcps([(0.0, 0.0, 400000, 370000), (100.0, 0.0, 410000, 370000), (100.0, 200.0, 410000, 368000)])) assert gdaltest.geotransform_equals( gt, (400000.0, 100.0, 0.0, 370000.0, 0.0, -10.0), 0.000001)
def test_gdalwarp_32(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' (out, err) = gdaltest.runexternal_out_and_err( test_cli_utilities.get_gdalwarp_path() + ' -tap ../gcore/data/byte.tif tmp/testgdalwarp32.tif', check_memleak=False) if err.find('-tap option cannot be used without using -tr') == -1: gdaltest.post_reason('expected error') return 'fail' gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' -tr 100 50 -tap ../gcore/data/byte.tif tmp/testgdalwarp32.tif') ds = gdal.Open('tmp/testgdalwarp32.tif') if ds is None: return 'fail' expected_gt = (440700.0, 100.0, 0.0, 3751350.0, 0.0, -50.0) got_gt = ds.GetGeoTransform() if not gdaltest.geotransform_equals(expected_gt, got_gt, 1e-9): gdaltest.post_reason('Bad geotransform') print(got_gt) return 'fail' if ds.RasterXSize != 13 or ds.RasterYSize != 25: gdaltest.post_reason('Wrong raster dimensions : %d x %d' % (ds.RasterXSize, ds.RasterYSize)) return 'fail' ds = None return 'success'
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"
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"
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'
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'
def test_gdalwarp_32(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' (out, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalwarp_path() + ' -tap ../gcore/data/byte.tif tmp/testgdalwarp32.tif', check_memleak = False) if err.find('-tap option cannot be used without using -tr') == -1: gdaltest.post_reason('expected error') return 'fail' gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -tr 100 50 -tap ../gcore/data/byte.tif tmp/testgdalwarp32.tif') ds = gdal.Open('tmp/testgdalwarp32.tif') if ds is None: return 'fail' expected_gt = (440700.0, 100.0, 0.0, 3751350.0, 0.0, -50.0) got_gt = ds.GetGeoTransform() if not gdaltest.geotransform_equals(expected_gt, got_gt, 1e-9) : gdaltest.post_reason('Bad geotransform') print(got_gt) return 'fail' if ds.RasterXSize != 13 or ds.RasterYSize != 25: gdaltest.post_reason('Wrong raster dimensions : %d x %d' % (ds.RasterXSize, ds.RasterYSize) ) return 'fail' ds = None return 'success'
def test_gdalwarp_lib_32(): ds = gdal.Warp('', '../gcore/data/byte.tif', format='MEM', targetAlignedPixels=True, xRes=100, yRes=50) if ds is None: return 'fail' expected_gt = (440700.0, 100.0, 0.0, 3751350.0, 0.0, -50.0) got_gt = ds.GetGeoTransform() if not gdaltest.geotransform_equals(expected_gt, got_gt, 1e-9): gdaltest.post_reason('Bad geotransform') print(got_gt) return 'fail' if ds.RasterXSize != 13 or ds.RasterYSize != 25: gdaltest.post_reason('Wrong raster dimensions : %d x %d' % (ds.RasterXSize, ds.RasterYSize)) return 'fail' ds = None return 'success'
def test_gdalwarp_lib_5(): ds = gdal.Open('../gcore/data/byte.tif') gcpList = [ gdal.GCP(440720.000, 3751320.000, 0, 0, 0), gdal.GCP(441920.000, 3751320.000, 0, 20, 0), gdal.GCP(441920.000, 3750120.000, 0, 20, 20), gdal.GCP(440720.000, 3750120.000, 0, 0, 20) ] ds1 = gdal.Translate('tmp/testgdalwarp_gcp.tif', ds, outputSRS='EPSG:26711', GCPs=gcpList) dstDS = gdal.Warp('', ds1, format='MEM', tps=True) if dstDS.GetRasterBand(1).Checksum() != 4672: gdaltest.post_reason('Bad checksum') return 'fail' if not gdaltest.geotransform_equals(ds.GetGeoTransform(), dstDS.GetGeoTransform(), 1e-9): gdaltest.post_reason('Bad geotransform') return 'fail' dstDS = None return 'success'
def test_gdalwarp_32(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() (_, err) = gdaltest.runexternal_out_and_err( test_cli_utilities.get_gdalwarp_path() + ' -tap ../gcore/data/byte.tif tmp/testgdalwarp32.tif', check_memleak=False) assert err.find('-tap option cannot be used without using -tr') != -1, \ 'expected error' gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' -tr 100 50 -tap ../gcore/data/byte.tif tmp/testgdalwarp32.tif') ds = gdal.Open('tmp/testgdalwarp32.tif') assert ds is not None expected_gt = (440700.0, 100.0, 0.0, 3751350.0, 0.0, -50.0) got_gt = ds.GetGeoTransform() assert gdaltest.geotransform_equals(expected_gt, got_gt, 1e-9), 'Bad geotransform' assert ds.RasterXSize == 13 and ds.RasterYSize == 25, \ ('Wrong raster dimensions : %d x %d' % (ds.RasterXSize, ds.RasterYSize)) ds = None
def test_gdalwarp_6(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' -tps tmp/testgdalwarp_gcp.tif tmp/testgdalwarp6.tif') ds = gdal.Open('tmp/testgdalwarp6.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'
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-6): gdaltest.post_reason('Bad geotransform') return 'fail' ds = None return 'success'
def test_gcps2gt_5(): gt = gdal.GCPsToGeoTransform(_list2gcps([ (0.0, 0.0, 400000, 370000), (100.0, 200.0, 410000, 368000), ])) assert gdaltest.geotransform_equals( gt, (400000.0, 100.0, 0.0, 370000.0, 0.0, -10.0), 0.000001)
def test_gcps2gt_2(): gt = gdal.GCPsToGeoTransform( _list2gcps([(0.0, 0.0, 400000, 370000), (100.0, 0.0, 410000, 370000), (100.0, 200.0, 410000, 368000), (0.0, 200.0, 400000, 368000.01)])) assert gdaltest.geotransform_equals( gt, (400000.0, 100.0, 0.0, 370000.0025, -5e-05, -9.999975), 0.000001)
def test_gdal_translate_lib_103(): ds = gdal.Translate('', '../gcore/data/byte.tif', format='MEM', projWin=[440730, 3751310, 441910, 3750140]) assert ds is not None assert ds.GetRasterBand(1).Checksum() == 4672, 'Bad checksum' assert gdaltest.geotransform_equals(gdal.Open('../gcore/data/byte.tif').GetGeoTransform(), ds.GetGeoTransform(), 1e-9), \ 'Bad geotransform'
def test_gcps2gt_2(): gt = gdal.GCPsToGeoTransform(_list2gcps([ (0.0, 0.0, 400000, 370000), (100.0, 0.0, 410000, 370000), (100.0, 200.0, 410000, 368000), (0.0, 200.0, 400000, 368000.01) ])) assert gdaltest.geotransform_equals( gt, (400000.0, 100.0, 0.0, 370000.0025, -5e-05, -9.999975), 0.000001)
def gcps2gt_1(): gt = gdal.GCPsToGeoTransform( _list2gcps([(0.0, 0.0, 400000, 370000), (100.0, 0.0, 410000, 370000), (100.0, 200.0, 410000, 368000)])) if not gdaltest.geotransform_equals( gt, (400000.0, 100.0, 0.0, 370000.0, 0.0, -10.0), 0.000001): return 'failure' return 'success'
def test_gdalwarp_lib_9(): ds = gdal.Warp('', '../gcore/data/byte.tif', format = 'MEM', outputBounds = [440720.000, 3750120.000, 441920.000, 3751320.000]) 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'
def gcps2gt_5(): gt = gdal.GCPsToGeoTransform(_list2gcps([ ( 0.0, 0.0, 400000, 370000), (100.0, 200.0, 410000, 368000), ])) if not gdaltest.geotransform_equals( gt, (400000.0, 100.0, 0.0, 370000.0, 0.0, -10.0), 0.000001): return 'failure' return 'success'
def gcps2gt_2(): gt = gdal.GCPsToGeoTransform( _list2gcps([(0.0, 0.0, 400000, 370000), (100.0, 0.0, 410000, 370000), (100.0, 200.0, 410000, 368000), (0.0, 200.0, 400000, 368000.01)])) if not gdaltest.geotransform_equals( gt, (400000.0, 100.0, 0.0, 370000.0025, -5e-05, -9.999975), 0.000001): return 'fail' return 'success'
def test_gdal_translate_lib_12(): ds = gdal.Open('../gcore/data/byte.tif') ds = gdal.Translate('tmp/test12.tif', ds, outputBounds=[440720.000, 3751320.000, 441920.000, 3750120.000]) assert ds is not None assert ds.GetRasterBand(1).Checksum() == 4672, 'Bad checksum' assert gdaltest.geotransform_equals(gdal.Open('../gcore/data/byte.tif').GetGeoTransform(), ds.GetGeoTransform(), 1e-9), \ 'Bad geotransform' ds = None
def test_gdalwarp_36(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -tr 60 60 -te 440720.000 3750120.000 441920.000 3751320.000 ../gcore/data/byte.tif tmp/testgdalwarp36.tif') ds = gdal.Open('tmp/testgdalwarp36.tif') assert ds is not None assert gdaltest.geotransform_equals(gdal.Open('../gcore/data/byte.tif').GetGeoTransform(), ds.GetGeoTransform(), 1e-9), \ 'Bad geotransform' ds = None
def test_gcps2gt_8(): gt = gdal.GCPsToGeoTransform(_list2gcps([ (0.01, 0.04, -87.05528672907, 39.22759504228), (0.01, 2688.02, -86.97079900719, 39.27075713986), (4031.99, 2688.04, -87.05960736744, 39.37569137000), (1988.16, 1540.80, -87.055069186699924, 39.304963106777514), (1477.41, 2400.83, -87.013419295885001, 39.304705030894979), (1466.02, 2376.92, -87.013906298363295, 39.304056190007913), ])) gt_expected = (-87.056612873288, -2.232795668658e-05, 3.178617809303e-05, 39.227856615716, 2.6091510188921e-05, 1.596921026218e-05) assert gdaltest.geotransform_equals(gt, gt_expected, 0.00001)
def gcps2gt_7(): gt = gdal.GCPsToGeoTransform(_list2gcps([ (400000, 370000, 400000, 370000), (410000, 368000, 410000, 368000), (410000, 370000, 410000, 370000), (400000, 368000, 400000, 368000), ])) if not gdaltest.geotransform_equals( gt, (0.0, 1.0, 0.0, 0.0, 0.0, 1.0), 0.000001): return 'fail' return 'success'
def gcps2gt_2(): gt = gdal.GCPsToGeoTransform(_list2gcps([ (0.0, 0.0, 400000, 370000), (100.0, 0.0, 410000, 370000), (100.0, 200.0, 410000, 368000), (0.0, 200.0, 400000, 368000.01) ])) if not gdaltest.geotransform_equals( gt, (400000.0, 100.0, 0.0, 370000.0025, -5e-05, -9.999975), 0.000001): return 'fail' return 'success'
def test_gdalwarp_8(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -ts 10 10 tmp/testgdalwarp_gcp.tif tmp/testgdalwarp8.tif') ds = gdal.Open('tmp/testgdalwarp8.tif') assert ds is not None expected_gt = (440720.0, 120.0, 0.0, 3751320.0, 0.0, -120.0) assert gdaltest.geotransform_equals(expected_gt, ds.GetGeoTransform(), 1e-9), \ 'Bad geotransform' ds = None
def test_gdalwarp_6(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -tps tmp/testgdalwarp_gcp.tif tmp/testgdalwarp6.tif') ds = gdal.Open('tmp/testgdalwarp6.tif') assert ds is not None assert ds.GetRasterBand(1).Checksum() == 4672, 'Bad checksum' assert gdaltest.geotransform_equals(gdal.Open('../gcore/data/byte.tif').GetGeoTransform(), ds.GetGeoTransform(), 1e-9), \ 'Bad geotransform' ds = None
def test_gdal_translate_12(): if test_cli_utilities.get_gdal_translate_path() is None: pytest.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') assert ds is not None assert ds.GetRasterBand(1).Checksum() == 4672, 'Bad checksum' assert gdaltest.geotransform_equals(gdal.Open('../gcore/data/byte.tif').GetGeoTransform(), ds.GetGeoTransform(), 1e-9), \ 'Bad geotransform' ds = None
def test_gdalwarp_lib_8(): ds1 = gdal.Open('tmp/testgdalwarp_gcp.tif') dstDS = gdal.Warp('',[ds1], format = 'MEM',width = 10,height = 10) if dstDS is None: return 'fail' expected_gt = (440720.0, 120.0, 0.0, 3751320.0, 0.0, -120.0) if not gdaltest.geotransform_equals(expected_gt, dstDS.GetGeoTransform(), 1e-9) : gdaltest.post_reason('Bad geotransform') return 'fail' dstDS = None return 'success'
def test_gdal_translate_31(): if test_cli_utilities.get_gdal_translate_path() is None: pytest.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') assert ds is not None assert ds.GetRasterBand(1).Checksum() == 4672, 'Bad checksum' assert gdaltest.geotransform_equals(gdal.Open('../gcore/data/byte.tif').GetGeoTransform(), ds.GetGeoTransform(), 1e-6), \ 'Bad geotransform' ds = None
def test_gdal_translate_lib_103(): ds = gdal.Translate('', '../gcore/data/byte.tif', format='MEM', projWin=[440730, 3751310, 441910, 3750140]) 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' return 'success'
def test_gdalwarp_lib_6(): ds1 = gdal.Open('tmp/testgdalwarp_gcp.tif') dstDS = gdal.Warp('',ds1, format = 'MEM', tps = True) if dstDS.GetRasterBand(1).Checksum() != 4672: gdaltest.post_reason('Bad checksum') return 'fail' if not gdaltest.geotransform_equals(gdal.Open('../gcore/data/byte.tif').GetGeoTransform(), dstDS.GetGeoTransform(), 1e-9) : gdaltest.post_reason('Bad geotransform') return 'fail' dstDS = None return 'success'
def test_gdalwarp_35(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -ts 20 20 -te 440720.000 3750120.000 441920.000 3751320.000 ../gcore/data/byte.tif tmp/testgdalwarp35.tif') ds = gdal.Open('tmp/testgdalwarp35.tif') if ds is None: 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'
def test_gdalwarp_lib_5(): ds = gdal.Open('../gcore/data/byte.tif') gcpList = [gdal.GCP(440720.000,3751320.000,0,0,0), gdal.GCP(441920.000,3751320.000,0,20,0), gdal.GCP(441920.000,3750120.000,0,20,20), gdal.GCP(440720.000,3750120.000,0,0,20)] ds1 = gdal.Translate('tmp/testgdalwarp_gcp.tif',ds,outputSRS = 'EPSG:26711',GCPs = gcpList) dstDS = gdal.Warp('', ds1, format = 'MEM', tps = True) if dstDS.GetRasterBand(1).Checksum() != 4672: gdaltest.post_reason('Bad checksum') return 'fail' if not gdaltest.geotransform_equals(ds.GetGeoTransform(), dstDS.GetGeoTransform(), 1e-9) : gdaltest.post_reason('Bad geotransform') return 'fail' dstDS = None return 'success'
def test_gdalwarp_8(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -ts 10 10 tmp/testgdalwarp_gcp.tif tmp/testgdalwarp8.tif') ds = gdal.Open('tmp/testgdalwarp8.tif') if ds is None: return 'fail' expected_gt = (440720.0, 120.0, 0.0, 3751320.0, 0.0, -120.0) if not gdaltest.geotransform_equals(expected_gt, ds.GetGeoTransform(), 1e-9) : gdaltest.post_reason('Bad geotransform') return 'fail' ds = None return 'success'
def test_gdal_translate_lib_12(): ds = gdal.Open('../gcore/data/byte.tif') ds = gdal.Translate('tmp/test12.tif', ds, outputBounds=[440720.000, 3751320.000, 441920.000, 3750120.000]) 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'
def test_gdal_translate_lib_11(): ds = gdal.Open("../gcore/data/byte.tif") ds = gdal.Translate("tmp/test11.tif", ds, projWin=[440720.000, 3751320.000, 441920.000, 3750120.000]) 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"
def test_gdalwarp_lib_32(): ds = gdal.Warp('', '../gcore/data/byte.tif', format = 'MEM', targetAlignedPixels = True, xRes = 100, yRes = 50) if ds is None: return 'fail' expected_gt = (440700.0, 100.0, 0.0, 3751350.0, 0.0, -50.0) got_gt = ds.GetGeoTransform() if not gdaltest.geotransform_equals(expected_gt, got_gt, 1e-9) : gdaltest.post_reason('Bad geotransform') print(got_gt) return 'fail' if ds.RasterXSize != 13 or ds.RasterYSize != 25: gdaltest.post_reason('Wrong raster dimensions : %d x %d' % (ds.RasterXSize, ds.RasterYSize) ) return 'fail' ds = None return 'success'
def test_gdalwarp_6(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -tps tmp/testgdalwarp_gcp.tif tmp/testgdalwarp6.tif') ds = gdal.Open('tmp/testgdalwarp6.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'
def test_gdalwarp_8(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' -ts 10 10 tmp/testgdalwarp_gcp.tif tmp/testgdalwarp8.tif') ds = gdal.Open('tmp/testgdalwarp8.tif') if ds is None: return 'fail' expected_gt = (440720.0, 120.0, 0.0, 3751320.0, 0.0, -120.0) if not gdaltest.geotransform_equals(expected_gt, ds.GetGeoTransform(), 1e-9): gdaltest.post_reason('Bad geotransform') return 'fail' ds = None return 'success'
def test_gdalwarp_32(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() (_, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalwarp_path() + ' -tap ../gcore/data/byte.tif tmp/testgdalwarp32.tif', check_memleak=False) assert err.find('-tap option cannot be used without using -tr') != -1, \ 'expected error' gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -tr 100 50 -tap ../gcore/data/byte.tif tmp/testgdalwarp32.tif') ds = gdal.Open('tmp/testgdalwarp32.tif') assert ds is not None expected_gt = (440700.0, 100.0, 0.0, 3751350.0, 0.0, -50.0) got_gt = ds.GetGeoTransform() assert gdaltest.geotransform_equals(expected_gt, got_gt, 1e-9), 'Bad geotransform' assert ds.RasterXSize == 13 and ds.RasterYSize == 25, \ ('Wrong raster dimensions : %d x %d' % (ds.RasterXSize, ds.RasterYSize)) ds = None
def test_gdalwarp_9(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' -te 440720.000 3750120.000 441920.000 3751320.000 tmp/testgdalwarp_gcp.tif tmp/testgdalwarp9.tif' ) ds = gdal.Open('tmp/testgdalwarp9.tif') if ds is None: 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'