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 vrtwarp_11(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' src_ds = gdal.Open('../gcore/data/byte.tif') tmp_ds = gdal.GetDriverByName('GTiff').CreateCopy('tmp/vrtwarp_11.tif', src_ds) tmp_ds.BuildOverviews( 'NEAR', overviewlist = [2] ) tmp_ds = None gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' tmp/vrtwarp_11.tif tmp/vrtwarp_11.vrt -dstalpha -of VRT') ds = gdal.Open('tmp/vrtwarp_11.vrt') cs1 = ds.GetRasterBand(1).GetOverview(0).Checksum() cs2 = ds.GetRasterBand(2).GetOverview(0).Checksum() ds = None gdal.Unlink('tmp/vrtwarp_11.tif') gdal.Unlink('tmp/vrtwarp_11.vrt') if cs1 != 1087 or cs2 != 1218: gdaltest.post_reason('fail') print(cs1) print(cs2) return 'fail' return 'success'
def test_gdalwarp_33(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() if test_cli_utilities.get_gdal_translate_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -dstalpha ../gcore/data/ycbcr_with_mask.tif tmp/testgdalwarp33.tif') src_ds = gdal.Open('../gcore/data/ycbcr_with_mask.tif') ds = gdal.Open('tmp/testgdalwarp33.tif') assert ds is not None # There are expected diffs because of the artifacts due to JPEG compression in 8x8 blocks # that are partially masked. gdalwarp will remove those artifacts max_diff = gdaltest.compare_ds(src_ds, ds) assert max_diff <= 40 src_ds = None gdaltest.runexternal(test_cli_utilities.get_gdal_translate_path() + ' -expand gray GTIFF_DIR:2:../gcore/data/ycbcr_with_mask.tif tmp/testgdalwarp33_mask.tif') mask_ds = gdal.Open('tmp/testgdalwarp33_mask.tif') expected_cs = mask_ds.GetRasterBand(1).Checksum() mask_ds = None cs = ds.GetRasterBand(4).Checksum() ds = None assert cs == expected_cs, 'did not get expected checksum on alpha band'
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_28(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -t_srs "+proj=aeqd +lat_0=45 +lon_0=90" data/w_jpeg.tiff tmp/testgdalwarp28.tif') ds = gdal.Open('tmp/testgdalwarp28.tif') if ds is None: return 'fail' # First is GCC; Second is MSVC 6.0. Thid is jpeg8 cs = ds.GetRasterBand(1).Checksum() if cs != 47506 and cs != 46728 and cs != 43789: print(cs) gdaltest.post_reason('Bad checksum') return 'fail' gt = ds.GetGeoTransform() # First is GCC; Second is MSVC 6.0 expected_gt1 = [-10009026.853177125, 43693.733128680084, 0.0, 5024463.6669970695, 0.0, -43693.733128680084] expected_gt2 = [-10009026.853177125, 43691.280523668691, 0.0, 5022121.8610583926, 0.0, -43691.280523668691] for i in range(6): if abs(gt[i] - expected_gt1[i]) > 1 and abs(gt[i] - expected_gt2[i]) > 1: print(gt) gdaltest.post_reason('Bad gt') return 'fail' ds = None return 'success'
def test_gdalwarp_44(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() # Without -wo SRC_COORD_PRECISION gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -q ../gcore/data/byte.tif tmp/test_gdalwarp_44.tif -wm 10 -overwrite -ts 500 500 -r cubic -ot float32 -t_srs EPSG:4326') ds = gdal.Open('tmp/test_gdalwarp_44.tif') cs1 = ds.GetRasterBand(1).Checksum() ds = None gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -q ../gcore/data/byte.tif tmp/test_gdalwarp_44.tif -wm 0.1 -overwrite -ts 500 500 -r cubic -ot float32 -t_srs EPSG:4326') ds = gdal.Open('tmp/test_gdalwarp_44.tif') cs2 = ds.GetRasterBand(1).Checksum() ds = None if cs1 == cs2: print('Unexpected cs1 == cs2') # With -wo SRC_COORD_PRECISION gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -q ../gcore/data/byte.tif tmp/test_gdalwarp_44.tif -wm 10 -et 0.01 -wo SRC_COORD_PRECISION=0.1 -overwrite -ts 500 500 -r cubic -ot float32 -t_srs EPSG:4326') ds = gdal.Open('tmp/test_gdalwarp_44.tif') cs3 = ds.GetRasterBand(1).Checksum() ds = None gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -q ../gcore/data/byte.tif tmp/test_gdalwarp_44.tif -wm 0.1 -et 0.01 -wo SRC_COORD_PRECISION=0.1 -overwrite -ts 500 500 -r cubic -ot float32 -t_srs EPSG:4326') ds = gdal.Open('tmp/test_gdalwarp_44.tif') cs4 = ds.GetRasterBand(1).Checksum() ds = None assert cs3 == cs4
def test_gdalwarp_46(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() if test_cli_utilities.get_ogr2ogr_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' ../gcore/data/utmsmall.tif tmp/test_gdalwarp_46.tif -cutline data/cutline.vrt -crop_to_cutline -overwrite') ds = gdal.Open('tmp/test_gdalwarp_46.tif') assert ds is not None assert ds.GetRasterBand(1).Checksum() == 18837, 'Bad checksum' ds = None # With explicit -s_srs and -t_srs gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' ../gcore/data/utmsmall.tif tmp/test_gdalwarp_46.tif -cutline data/cutline.vrt -crop_to_cutline -overwrite -s_srs EPSG:26711 -t_srs EPSG:26711') ds = gdal.Open('tmp/test_gdalwarp_46.tif') assert ds is not None assert ds.GetRasterBand(1).Checksum() == 18837, 'Bad checksum' ds = None # With cutline in another SRS gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' tmp/cutline_4326.shp data/cutline.vrt -s_srs EPSG:26711 -t_srs EPSG:4326') gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' ../gcore/data/utmsmall.tif tmp/test_gdalwarp_46.tif -cutline tmp/cutline_4326.shp -crop_to_cutline -overwrite -t_srs EPSG:32711') ds = gdal.Open('tmp/test_gdalwarp_46.tif') assert ds is not None assert ds.GetRasterBand(1).Checksum() == 19582, 'Bad checksum' ds = None
def test_gdalwarp_25(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -t_srs "+proj=sinu" data/w_jpeg.tiff tmp/testgdalwarp25.tif') ds = gdal.Open('tmp/testgdalwarp25.tif') if ds is None: return 'fail' cs = ds.GetRasterBand(1).Checksum() if cs != 8016 and cs != 6157: print(cs) gdaltest.post_reason('Bad checksum') return 'fail' gt = ds.GetGeoTransform() expected_gt = [-20037508.342789248, 78245.302611923355, 0.0, 10001965.729313632, 0.0, -77939.656898595524] for i in range(6): if abs(gt[i] - expected_gt[i]) > 1: print(gt) gdaltest.post_reason('Bad gt') return 'fail' ds = None return 'success'
def test_gdalwarp_31(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + " ../gcore/data/byte.tif tmp/testgdalwarp31.tif") ds = gdal.Open('tmp/testgdalwarp31.tif') cs1 = ds.GetRasterBand(1).Checksum() ds = None (out, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalwarp_path() + " ../gcore/data/byte.tif tmp/testgdalwarp31.tif -t_srs EPSG:4326") ds = gdal.Open('tmp/testgdalwarp31.tif') cs2 = ds.GetRasterBand(1).Checksum() ds = None (out, err2) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalwarp_path() + " ../gcore/data/byte.tif tmp/testgdalwarp31.tif -t_srs EPSG:4326 -overwrite") ds = gdal.Open('tmp/testgdalwarp31.tif') cs3 = ds.GetRasterBand(1).Checksum() ds = None if cs1 != 4672 or cs2 != 4672 or cs3 != 4727 or err == '' or err2 != '': print(cs1,cs2,cs3) print(err) print(err2) return 'fail' return 'success'
def test_gdalwarp_26(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -t_srs "+proj=eck4" data/w_jpeg.tiff tmp/testgdalwarp26.tif') ds = gdal.Open('tmp/testgdalwarp26.tif') if ds is None: return 'fail' cs = ds.GetRasterBand(1).Checksum() if cs != 8582 and cs != 3938: print(cs) gdaltest.post_reason('Bad checksum') return 'fail' gt = ds.GetGeoTransform() expected_gt = [-16921202.922943164, 41752.719393322564, 0.0, 8460601.4614715818, 0.0, -41701.109109770863] for i in range(6): if abs(gt[i] - expected_gt[i]) > 1: print(gt) gdaltest.post_reason('Bad gt') return 'fail' ds = None return 'success'
def test_gdalwarp_27(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -t_srs "+proj=vandg" data/w_jpeg.tiff tmp/testgdalwarp27.tif') ds = gdal.Open('tmp/testgdalwarp27.tif') if ds is None: return 'fail' cs = ds.GetRasterBand(1).Checksum() if cs != 22006 and cs != 22615: print(cs) gdaltest.post_reason('Bad checksum') return 'fail' gt = ds.GetGeoTransform() expected_gt = [-20015109.356056381, 98651.645855415176, 0.0, 20015109.356056374, 0.0, -98651.645855415176] for i in range(6): if abs(gt[i] - expected_gt[i]) > 1: print(gt) gdaltest.post_reason('Bad gt') return 'fail' ds = None return 'success'
def test_gdalwarp_37(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -tr 60 60 ./data/utmsmall.tif tmp/testgdalwarp37.tif') ds = gdal.Open('tmp/testgdalwarp37.tif') if ds is None: return 'fail' md = ds.GetRasterBand(1).GetMetadata() # basic metadata test if 'testkey' not in md or md['testkey'] != 'test value': gdaltest.post_reason('Output file metadata is wrong : { %s }' % md) return 'fail' # make sure stats not copied if 'STATISTICS_MEAN' in md : gdaltest.post_reason('Output file contains statistics metadata') return 'fail' min = ds.GetRasterBand(1).GetMinimum() if min is not None: gdaltest.post_reason('Output file has statistics') return 'fail' ds = None return 'success'
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'
def test_gdalwarp_29(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -t_srs EPSG:3785 data/w_jpeg.tiff tmp/testgdalwarp29.tif') ds = gdal.Open('tmp/testgdalwarp29.tif') if ds is None: return 'fail' cs = ds.GetRasterBand(1).Checksum() if cs != 55149 and cs != 56054: print(cs) gdaltest.post_reason('Bad checksum') return 'fail' gt = ds.GetGeoTransform() expected_gt = [ -20037508.342789248, 90054.726863985939, 0.0, 16213801.067583967, 0.0, -90056.750611190684 ] for i in range(6): if abs(gt[i] - expected_gt[i]) > 1: print(gt) gdaltest.post_reason('Bad gt') return 'fail' ds = None return 'success'
def test_gdalwarp_39(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' ../gdrivers/data/float64.asc tmp/test_gdalwarp_39.tif -oo DATATYPE=Float64 -overwrite') ds = gdal.Open('tmp/test_gdalwarp_39.tif') assert ds.GetRasterBand(1).DataType == gdal.GDT_Float64 ds = None
def test_gdalwarp_38(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' data/withnodata.asc tmp/testgdalwarp38.tif') ds = gdal.Open('tmp/testgdalwarp38.tif') assert ds.GetRasterBand(1).Checksum() == 65531 assert ds.GetRasterBand(1).GetNoDataValue() == -999 ds = None
def test_gdalwarp_10(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -ts 40 40 -rn tmp/testgdalwarp_gcp.tif tmp/testgdalwarp10.tif') ds = gdal.Open('tmp/testgdalwarp10.tif') assert ds is not None assert ds.GetRasterBand(1).Checksum() == 18784, 'Bad checksum' ds = None
def test_gdalwarp_4(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -t_srs EPSG:32611 ../gcore/data/byte.tif tmp/testgdalwarp4.tif') ds = gdal.Open('tmp/testgdalwarp4.tif') assert ds is not None assert ds.GetRasterBand(1).Checksum() == 4672, 'Bad checksum' ds = None
def test_gdalwarp_23(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -wo CUTLINE_ALL_TOUCHED=TRUE ../gcore/data/utmsmall.tif tmp/testgdalwarp23.tif -cutline data/cutline.vrt -cl cutline') ds = gdal.Open('tmp/testgdalwarp23.tif') assert ds is not None assert ds.GetRasterBand(1).Checksum() == 20123, 'Bad checksum' ds = None
def test_gdalwarp_22(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' ../gcore/data/utmsmall.tif tmp/testgdalwarp22.tif -cutline data/cutline.vrt -cl cutline -tr 30 30') ds = gdal.Open('tmp/testgdalwarp22.tif') assert ds is not None assert ds.GetRasterBand(1).Checksum() == 14047, 'Bad checksum' ds = None
def test_gdalwarp_20(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -of VRT -et 0 tmp/testgdalwarp_gcp.tif tmp/testgdalwarp20.vrt') ds = gdal.Open('tmp/testgdalwarp20.vrt') assert ds is not None assert ds.GetRasterBand(1).Checksum() == 4672, 'Bad checksum' ds = None
def test_gdalwarp_17(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -dstalpha ../gcore/data/rgbsmall.tif tmp/testgdalwarp17.tif') ds = gdal.Open('tmp/testgdalwarp17.tif') assert ds is not None assert ds.GetRasterBand(4) is not None, 'No alpha band generated' ds = None
def warp_22(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' # Generate source image with non uniform data w = 1001 h = 1001 ds = gdal.GetDriverByName('GTiff').Create("tmp/warp_22_src.tif", w,h, 1) ds.SetGeoTransform([2,0.01,0,49,0,-0.01]) sr = osr.SpatialReference() sr.ImportFromEPSG(4326) ds.SetProjection(sr.ExportToWkt()) for j in range(h): line = '' for i in range(w): line = line + '%c' % ((i*i+h*j/(i+1))%256) ds.GetRasterBand(1).WriteRaster(0,j,w,1,line) expected_cs = ds.GetRasterBand(1).Checksum() ds = None ret = 'success' failures = '' # warp with various options for option1 in ['', '-wo OPTIMIZE_SIZE=TRUE']: for option2 in ['', '-co TILED=YES', '-co TILED=YES -co BLOCKXSIZE=16 -co BLOCKYSIZE=16']: option = option1 + ' ' + option2 try: os.remove('tmp/warp_22_dst.tif') except: pass # -wm should not be greater than 2 * w * h. Let's put it at its minimum value gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' tmp/warp_22_src.tif tmp/warp_22_dst.tif -wm 100000 ' + option) ds = gdal.Open('tmp/warp_22_dst.tif') cs = ds.GetRasterBand(1).Checksum() if cs != expected_cs: if failures != '': failures = failures + '\n' failures = failures + 'failed for %s. Checksum : got %d, expected %d' % (option, cs, expected_cs) ret = 'fail' ds = None if failures != '': gdaltest.post_reason(failures) os.remove('tmp/warp_22_src.tif') os.remove('tmp/warp_22_dst.tif') return ret
def vrtwarp_7(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' src_ds = gdal.Open('../gcore/data/byte.tif') tmp_ds = gdal.GetDriverByName('GTiff').CreateCopy('tmp/vrtwarp_7.tif', src_ds) cs_main = tmp_ds.GetRasterBand(1).Checksum() tmp_ds.SetGeoTransform([0,1,0,0,0,1]) # cancel geotransform gcp1 = gdal.GCP() gcp1.GCPPixel = 0 gcp1.GCPLine = 0 gcp1.GCPX = 440720.000 gcp1.GCPY = 3751320.000 gcp2 = gdal.GCP() gcp2.GCPPixel = 0 gcp2.GCPLine = 20 gcp2.GCPX = 440720.000 gcp2.GCPY = 3750120.000 gcp3 = gdal.GCP() gcp3.GCPPixel = 20 gcp3.GCPLine = 0 gcp3.GCPX = 441920.000 gcp3.GCPY = 3751320.000 src_gcps = (gcp1, gcp2, gcp3) tmp_ds.SetGCPs(src_gcps, src_ds.GetProjectionRef()) tmp_ds.BuildOverviews( 'NEAR', overviewlist = [2, 4] ) cs_ov0 = tmp_ds.GetRasterBand(1).GetOverview(0).Checksum() cs_ov1 = tmp_ds.GetRasterBand(1).GetOverview(1).Checksum() tmp_ds = None gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' tmp/vrtwarp_7.tif tmp/vrtwarp_7.vrt -overwrite -of VRT -tps') vrtwarp_ds = gdal.Open( 'tmp/vrtwarp_7.vrt' ) if vrtwarp_ds.GetRasterBand(1).GetOverviewCount() != 2: gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).Checksum() != cs_main: print(cs_main) return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum() != cs_ov0: gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(1).Checksum() != cs_ov1: gdaltest.post_reason('fail') return 'fail' vrtwarp_ds = None gdal.Unlink('tmp/vrtwarp_7.vrt') gdal.Unlink('tmp/vrtwarp_7.tif') return 'success'
def test_gdalwarp_1(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() (_, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalwarp_path() + ' ../gcore/data/byte.tif tmp/testgdalwarp1.tif') assert (err is None or err == ''), 'got error/warning' ds = gdal.Open('tmp/testgdalwarp1.tif') assert ds is not None assert ds.GetRasterBand(1).Checksum() == 4672, 'Bad checksum' ds = None
def test_gdalwarp_47_append_subdataset(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() tmpfilename = 'tmp/test_gdalwarp_47_append_subdataset.tif' gdal.Translate(tmpfilename, '../gcore/data/byte.tif') gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -co APPEND_SUBDATASET=YES ../gcore/data/utmsmall.tif ' + tmpfilename) ds = gdal.Open('GTIFF_DIR:2:' + tmpfilename) assert ds.GetRasterBand(1).Checksum() == 50054 ds = None gdal.Unlink(tmpfilename)
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_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_15(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -dstnodata 1 -t_srs EPSG:32610 tmp/testgdalwarp_gcp.tif tmp/testgdalwarp15.tif') ds = gdal.Open('tmp/testgdalwarp15.tif') assert ds is not None assert ds.GetRasterBand(1).GetNoDataValue() == 1, 'Bad nodata value' assert ds.GetRasterBand(1).Checksum() == 4523, 'Bad checksum' ds = None
def test_gdalwarp_3(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -ot Int16 ../gcore/data/byte.tif tmp/testgdalwarp3.tif') ds = gdal.Open('tmp/testgdalwarp3.tif') assert ds is not None assert ds.GetRasterBand(1).DataType == gdal.GDT_Int16, 'Bad data type' assert ds.GetRasterBand(1).Checksum() == 4672, 'Bad checksum' ds = None
def warp_23(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' gcp1 = gdal.GCP() gcp1.GCPPixel = 3213 gcp1.GCPLine = 2225 gcp1.GCPX = -88.834495 gcp1.GCPY = 29.979959 gcp2 = gdal.GCP() gcp2.GCPPixel = 2804 gcp2.GCPLine = 2236 gcp2.GCPX = -88.836706 gcp2.GCPY = 29.979516 gcp3 = gdal.GCP() gcp3.GCPPixel = 3157 gcp3.GCPLine = 4344 gcp3.GCPX = -88.833389 gcp3.GCPY = 29.969519 gcp4 = gdal.GCP() gcp4.GCPPixel = 3768 gcp4.GCPLine = 5247 gcp4.GCPX = -88.830168 gcp4.GCPY = 29.964958 gcp5 = gdal.GCP() gcp5.GCPPixel = 2697 gcp5.GCPLine = 9225 gcp5.GCPX = -88.83516 gcp5.GCPY = 29.945386 gcp6 = gdal.GCP() gcp6.GCPPixel = 4087 gcp6.GCPLine = 12360 gcp6.GCPX = -88.827899 gcp6.GCPY = 29.929807 gcp7 = gdal.GCP() gcp7.GCPPixel = 4629 gcp7.GCPLine = 11258 gcp7.GCPX = -88.825102 gcp7.GCPY = 29.93527 gcp8 = gdal.GCP() gcp8.GCPPixel = 4480 gcp8.GCPLine = 7602 gcp8.GCPX = -88.826733 gcp8.GCPY = 29.95304 gcps = [gcp1,gcp2,gcp3,gcp4,gcp5,gcp6,gcp7,gcp8] sr = osr.SpatialReference() sr.ImportFromEPSG(4326) ds = gdal.GetDriverByName('GTiff').Create('tmp/test3582.tif', 70, 170, 4, options = ['SPARSE_OK=YES']) for i in range(len(gcps)): gcps[i].GCPPixel = gcps[i].GCPPixel / 10 gcps[i].GCPLine = gcps[i].GCPLine / 10 ds.SetGCPs(gcps, sr.ExportToWkt()) ds = None gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' tmp/test3582.tif tmp/test3582_warped.tif') ds = gdal.Open('tmp/test3582_warped.tif') ret = 'success' if ds is None: gdaltest.post_reason('could not open output dataset') ret = 'fail' ds = None os.remove('tmp/test3582.tif') try: os.remove('tmp/test3582_warped.tif') except: pass return ret
def warp_27(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' # Open source dataset src_ds = gdal.Open('../gcore/data/byte.tif') # Desfine target SRS dst_srs = osr.SpatialReference() dst_srs.ImportFromEPSG(4326) dst_wkt = dst_srs.ExportToWkt() error_threshold = 0.125 # error threshold --> use same value as in gdalwarp resampling = gdal.GRA_Bilinear # Call AutoCreateWarpedVRT() to fetch default values for target raster dimensions and geotransform tmp_ds = gdal.AutoCreateWarpedVRT( src_ds, \ None, # src_wkt : left to default value --> will use the one from source \ dst_wkt, \ resampling, \ error_threshold ) dst_xsize = tmp_ds.RasterXSize dst_ysize = tmp_ds.RasterYSize dst_gt = tmp_ds.GetGeoTransform() tmp_ds = None # Now create the true target dataset dst_ds = gdal.GetDriverByName('GTiff').Create('tmp/warp_27.tif', dst_xsize, dst_ysize, src_ds.RasterCount) dst_ds.SetProjection(dst_wkt) dst_ds.SetGeoTransform(dst_gt) # And run the reprojection cbk = warp_27_progress_callback cbk_user_data = None # value for last parameter of above warp_27_progress_callback gdal.ReprojectImage( src_ds, \ dst_ds, \ None, # src_wkt : left to default value --> will use the one from source \ None, # dst_wkt : left to default value --> will use the one from destination \ resampling, \ 0, # WarpMemoryLimit : left to default value \ error_threshold, cbk, # Progress callback : could be left to None or unspecified for silent progress cbk_user_data) # Progress callback user data # Done ! dst_ds = None # Check that we have the same result as produced by 'gdalwarp -rb -t_srs EPSG:4326 ../gcore/data/byte.tif tmp/warp_27.tif' ds = gdal.Open('tmp/warp_27.tif') cs = ds.GetRasterBand(1).Checksum() ds = None gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -rb -t_srs EPSG:4326 ../gcore/data/byte.tif tmp/warp_27_ref.tif') ds = gdal.Open('tmp/warp_27_ref.tif') ref_cs = ds.GetRasterBand(1).Checksum() ds = None if cs != ref_cs: return 'fail' gdal.Unlink('tmp/warp_27.tif') gdal.Unlink('tmp/warp_27_ref.tif') return 'success'
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. ############################################################################### from osgeo import gdal import gdaltest import test_cli_utilities import pytest pytestmark = pytest.mark.skipif( test_cli_utilities.get_gdalwarp_path() is None or test_cli_utilities.get_gdal_viewshed_path() is None, reason="gdal_viewshed not available") ############################################################################### def test_gdal_viewshed(): gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' -t_srs EPSG:32617 -overwrite ../gdrivers/data/n43.dt0 tmp/test_gdal_viewshed_in.tif' ) _, err = gdaltest.runexternal_out_and_err( test_cli_utilities.get_gdal_viewshed_path() + ' -oz 100 -ox 621528 -oy 4817617 tmp/test_gdal_viewshed_in.tif tmp/test_gdal_viewshed_out.tif'
def test_gdalwarp_40(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() src_ds = gdal.Open('../gcore/data/byte.tif') out_ds = gdal.GetDriverByName('GTiff').CreateCopy( 'tmp/test_gdalwarp_40_src.tif', src_ds) cs_main = out_ds.GetRasterBand(1).Checksum() out_ds.BuildOverviews('NONE', overviewlist=[2, 4]) out_ds.GetRasterBand(1).GetOverview(0).Fill(127) cs_ov0 = out_ds.GetRasterBand(1).GetOverview(0).Checksum() out_ds.GetRasterBand(1).GetOverview(1).Fill(255) cs_ov1 = out_ds.GetRasterBand(1).GetOverview(1).Checksum() out_ds = None # Should select main resolution gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif tmp/test_gdalwarp_40.tif -overwrite') ds = gdal.Open('tmp/test_gdalwarp_40.tif') assert ds.GetRasterBand(1).Checksum() == cs_main ds = None # Test -ovr AUTO. Should select main resolution gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif tmp/test_gdalwarp_40.tif -overwrite -ovr AUTO' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') assert ds.GetRasterBand(1).Checksum() == cs_main ds = None gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' ../gcore/data/byte.tif tmp/test_gdalwarp_40.tif -overwrite -ts 5 5') ds = gdal.Open('tmp/test_gdalwarp_40.tif') expected_cs = ds.GetRasterBand(1).Checksum() ds = None # Test -ovr NONE. Should select main resolution too gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif tmp/test_gdalwarp_40.tif -overwrite -ovr NONE -ts 5 5' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') assert ds.GetRasterBand(1).Checksum() == expected_cs ds = None gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' ../gcore/data/byte.tif tmp/test_gdalwarp_40.tif -overwrite -ts 15 15' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') expected_cs = ds.GetRasterBand(1).Checksum() ds = None # Should select main resolution too gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif tmp/test_gdalwarp_40.tif -overwrite -ts 15 15' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') assert ds.GetRasterBand(1).Checksum() == expected_cs ds = None # Should select overview 0 gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif tmp/test_gdalwarp_40.tif -overwrite -ts 10 10' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') assert ds.GetRasterBand(1).Checksum() == cs_ov0 ds = None # Should select overview 0 through VRT gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif tmp/test_gdalwarp_40.vrt -overwrite -ts 10 10 -of VRT' ) ds = gdal.Open('tmp/test_gdalwarp_40.vrt') assert ds.GetRasterBand(1).Checksum() == cs_ov0 ds = None gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif -oo OVERVIEW_LEVEL=0 tmp/test_gdalwarp_40.tif -overwrite -ts 7 7' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') expected_cs = ds.GetRasterBand(1).Checksum() ds = None # Should select overview 0 too gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif tmp/test_gdalwarp_40.tif -overwrite -ts 7 7' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') assert ds.GetRasterBand(1).Checksum() == expected_cs ds = None gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif -ovr NONE -oo OVERVIEW_LEVEL=0 tmp/test_gdalwarp_40.tif -overwrite -ts 5 5' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') expected_cs = ds.GetRasterBand(1).Checksum() ds = None # Test AUTO-n. Should select overview 0 too gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif tmp/test_gdalwarp_40.tif -overwrite -ts 5 5 -ovr AUTO-1' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') assert ds.GetRasterBand(1).Checksum() == expected_cs ds = None # Should select overview 1 gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif tmp/test_gdalwarp_40.tif -overwrite -ts 5 5' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') assert ds.GetRasterBand(1).Checksum() == cs_ov1 ds = None gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif -oo OVERVIEW_LEVEL=1 tmp/test_gdalwarp_40.tif -overwrite -ts 3 3' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') expected_cs = ds.GetRasterBand(1).Checksum() ds = None # Should select overview 1 too gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif tmp/test_gdalwarp_40.tif -overwrite -ts 3 3' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') assert ds.GetRasterBand(1).Checksum() == expected_cs ds = None gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif -oo OVERVIEW_LEVEL=1 tmp/test_gdalwarp_40.tif -overwrite -ts 20 20' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') expected_cs = ds.GetRasterBand(1).Checksum() ds = None # Specify a level >= number of overviews. Should select overview 1 too gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/test_gdalwarp_40_src.tif tmp/test_gdalwarp_40.tif -overwrite -ovr 5' ) ds = gdal.Open('tmp/test_gdalwarp_40.tif') assert ds.GetRasterBand(1).Checksum() == expected_cs ds = None
def test_gdalwarp_42(): if test_cli_utilities.get_gdalwarp_path() is None: pytest.skip() if test_cli_utilities.get_gdal_translate_path() is None: pytest.skip() gdaltest.runexternal( test_cli_utilities.get_gdal_translate_path() + ' ../gdrivers/data/small_world.tif tmp/small_world_left.tif -srcwin 0 0 200 200 -a_nodata 255' ) gdaltest.runexternal( test_cli_utilities.get_gdal_translate_path() + ' ../gdrivers/data/small_world.tif tmp/small_world_right.tif -srcwin 200 0 200 200 -a_nodata 255' ) gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/small_world_left.tif tmp/test_gdalwarp_42.tif -overwrite -te -180 -90 180 90 -dstalpha -wo UNIFIED_SRC_NODATA=YES' ) gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/small_world_right.tif tmp/test_gdalwarp_42.tif -wo UNIFIED_SRC_NODATA=YES' ) ds = gdal.Open('tmp/test_gdalwarp_42.tif') got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] expected_cs = [25382, 27573, 35297, 59540] assert got_cs == expected_cs ds = None # In one step gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/small_world_left.tif tmp/small_world_right.tif tmp/test_gdalwarp_42.tif -overwrite -te -180 -90 180 90 -dstalpha -wo UNIFIED_SRC_NODATA=YES' ) ds = gdal.Open('tmp/test_gdalwarp_42.tif') got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] expected_cs = [25382, 27573, 35297, 59540] assert got_cs == expected_cs ds = None # In one step with -wo INIT_DEST=255,255,255,0 gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/small_world_left.tif tmp/small_world_right.tif tmp/test_gdalwarp_42.tif -wo INIT_DEST=255,255,255,0 -overwrite -te -180 -90 180 90 -dstalpha -wo UNIFIED_SRC_NODATA=YES' ) ds = gdal.Open('tmp/test_gdalwarp_42.tif') got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] expected_cs = [30111, 32302, 40026, 59540] assert got_cs == expected_cs ds = None # In one step with -wo INIT_DEST=0,0,0,0 # Different checksum since there are source pixels at 255, so they get remap to 0 gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/small_world_left.tif tmp/small_world_right.tif tmp/test_gdalwarp_42.tif -wo INIT_DEST=0,0,0,0 -overwrite -te -180 -90 180 90 -dstalpha -wo UNIFIED_SRC_NODATA=YES' ) ds = gdal.Open('tmp/test_gdalwarp_42.tif') got_cs = [ds.GetRasterBand(i + 1).Checksum() for i in range(4)] expected_cs = [25382, 27573, 35297, 59540] assert got_cs == expected_cs ds = None
def vrtwarp_9(): if test_cli_utilities.get_gdalwarp_path() is None: return 'skip' import shutil shutil.copy('../gcore/data/sstgeo.tif', 'tmp/sstgeo.tif') f = open('tmp/sstgeo.vrt', 'wb') f.write('''<VRTDataset rasterXSize="60" rasterYSize="39"> <Metadata domain="GEOLOCATION"> <MDI key="SRS">GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AXIS["Lat",NORTH],AXIS["Long",EAST],AUTHORITY["EPSG","4326"]]</MDI> <MDI key="X_DATASET">tmp/sstgeo.tif</MDI> <MDI key="X_BAND">1</MDI> <MDI key="PIXEL_OFFSET">0</MDI> <MDI key="PIXEL_STEP">1</MDI> <MDI key="Y_DATASET">tmp/sstgeo.tif</MDI> <MDI key="Y_BAND">2</MDI> <MDI key="LINE_OFFSET">0</MDI> <MDI key="LINE_STEP">1</MDI> </Metadata> <VRTRasterBand dataType="Int16" band="1"> <ColorInterp>Gray</ColorInterp> <NoDataValue>-32767</NoDataValue> <SimpleSource> <SourceFilename relativeToVRT="1">sstgeo.tif</SourceFilename> <SourceBand>3</SourceBand> <SrcRect xOff="0" yOff="0" xSize="60" ySize="39"/> <DstRect xOff="0" yOff="0" xSize="60" ySize="39"/> </SimpleSource> </VRTRasterBand> </VRTDataset> '''.encode('ascii')) f.close() ds = gdal.Open('tmp/sstgeo.vrt', gdal.GA_Update) ds.BuildOverviews('NEAR', overviewlist=[2]) ds = None gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/sstgeo.vrt tmp/vrtwarp_9_tmp.tif -overwrite -geoloc') ds = gdal.Open('tmp/vrtwarp_9_tmp.tif') expected_cs_main = ds.GetRasterBand(1).Checksum() ds = None gdal.Unlink('tmp/vrtwarp_9_tmp.tif') gdaltest.runexternal( test_cli_utilities.get_gdalwarp_path() + ' tmp/sstgeo.vrt tmp/vrtwarp_9.vrt -overwrite -of VRT -geoloc') vrtwarp_ds = gdal.Open('tmp/vrtwarp_9.vrt') if vrtwarp_ds.GetRasterBand(1).GetOverviewCount() != 1: gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).Checksum() != expected_cs_main: gdaltest.post_reason('fail') return 'fail' if vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum() != 63972: gdaltest.post_reason('fail') print(vrtwarp_ds.GetRasterBand(1).GetOverview(0).XSize) print(vrtwarp_ds.GetRasterBand(1).GetOverview(0).YSize) print(vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum()) return 'fail' vrtwarp_ds = None gdal.Unlink('tmp/vrtwarp_9.vrt') gdal.Unlink('tmp/sstgeo.vrt') gdal.Unlink('tmp/sstgeo.vrt.ovr') gdal.Unlink('tmp/sstgeo.tif') return 'success'
def make_viewshed_input(output=viewshed_in): gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -t_srs EPSG:32617 -overwrite ../gdrivers/data/n43.dt0 '+output)
# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. ############################################################################### from osgeo import gdal import gdaltest import test_cli_utilities import pytest pytestmark = pytest.mark.skipif(test_cli_utilities.get_gdalwarp_path() is None or test_cli_utilities.get_gdal_viewshed_path() is None, reason="gdal_viewshed not available") ############################################################################### viewshed_in = 'tmp/test_gdal_viewshed_in.tif' viewshed_out = 'tmp/test_gdal_viewshed_out.tif' ox = [621528] oy = [4817617] oz = [100, 10] def make_viewshed_input(output=viewshed_in): gdaltest.runexternal(test_cli_utilities.get_gdalwarp_path() + ' -t_srs EPSG:32617 -overwrite ../gdrivers/data/n43.dt0 '+output) def test_gdal_viewshed(): make_viewshed_input()