• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python test_py_scripts.run_py_script函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中test_py_scripts.run_py_script函数的典型用法代码示例。如果您正苦于以下问题:Python run_py_script函数的具体用法?Python run_py_script怎么用?Python run_py_script使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了run_py_script函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_ogr2ogr_py_21

def test_ogr2ogr_py_21():
    script_path = test_py_scripts.get_py_script("ogr2ogr")
    if script_path is None:
        return "skip"

    try:
        os.remove("tmp/testogr2ogr21.gtm")
    except:
        pass

    test_py_scripts.run_py_script(
        script_path,
        "ogr2ogr",
        "-f GPSTrackMaker tmp/testogr2ogr21.gtm ../utilities/data/dataforogr2ogr21.csv "
        + '-sql "SELECT comment, name FROM dataforogr2ogr21" -nlt POINT',
    )
    ds = ogr.Open("tmp/testogr2ogr21.gtm")

    if ds is None:
        return "fail"
    layer_defn = ds.GetLayer(0).GetLayerDefn()
    lyr = ds.GetLayer(0)
    feat = lyr.GetNextFeature()
    if feat.GetFieldAsString("name") != "NAME" or feat.GetFieldAsString("comment") != "COMMENT":
        print(feat.GetFieldAsString("name"))
        print(feat.GetFieldAsString("comment"))
        ds.Destroy()
        os.remove("tmp/testogr2ogr21.gtm")
        return "fail"

    ds.Destroy()
    os.remove("tmp/testogr2ogr21.gtm")

    return "success"
开发者ID:sylvainallard,项目名称:gdal,代码行数:34,代码来源:test_ogr2ogr_py.py


示例2: test_ogrmerge_11

def test_ogrmerge_11():
    script_path = test_py_scripts.get_py_script('ogrmerge')
    if script_path is None:
        return 'skip'

    test_py_scripts.run_py_script(script_path, 'ogrmerge',
        '-f VRT -o /vsimem/out.vrt ../ogr/data/poly.shp '
        '-a_srs EPSG:32630')

    ds = ogr.Open('/vsimem/out.vrt')
    if ds is None:
        gdaltest.post_reason('fail')
        return 'fail'
    ds = None

    f = gdal.VSIFOpenL('/vsimem/out.vrt', 'rb')
    content = ''
    if f is not None:
        content = gdal.VSIFReadL(1, 10000, f).decode('UTF-8')
        gdal.VSIFCloseL(f)
    gdal.Unlink('/vsimem/out.vrt')

    if content.find('<LayerSRS>EPSG:32630</LayerSRS>') < 0:
        gdaltest.post_reason('fail')
        print(content)
        return 'fail'

    return 'success'
开发者ID:jef-n,项目名称:gdal,代码行数:28,代码来源:test_ogrmerge.py


示例3: test_gdalinfo_py_8

def test_gdalinfo_py_8():
    script_path = test_py_scripts.get_py_script('gdalinfo')
    if script_path is None:
        return 'skip'

    try:
        os.remove('../gcore/data/byte.tif.aux.xml')
    except:
        pass

    ret = test_py_scripts.run_py_script(script_path, 'gdalinfo', '../gcore/data/byte.tif')
    if ret.find('0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 37 0 0 0 0 0 0 0 57 0 0 0 0 0 0 0 62 0 0 0 0 0 0 0 66 0 0 0 0 0 0 0 0 72 0 0 0 0 0 0 0 31 0 0 0 0 0 0 0 24 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1') != -1:
        gdaltest.post_reason( 'did not expect histogram.' )
        print(ret)
        return 'fail'

    ret = test_py_scripts.run_py_script(script_path, 'gdalinfo', '-hist ../gcore/data/byte.tif')
    if ret.find('0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 37 0 0 0 0 0 0 0 57 0 0 0 0 0 0 0 62 0 0 0 0 0 0 0 66 0 0 0 0 0 0 0 0 72 0 0 0 0 0 0 0 31 0 0 0 0 0 0 0 24 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1') == -1:
        gdaltest.post_reason( 'did not get expected histogram.' )
        print(ret)
        return 'fail'

    # We will blow an exception if the file does not exist now!
    os.remove('../gcore/data/byte.tif.aux.xml')

    return 'success'
开发者ID:nextgis-borsch,项目名称:tests,代码行数:26,代码来源:test_gdalinfo_py.py


示例4: test_gdal_edit_py_2

def test_gdal_edit_py_2():

    script_path = test_py_scripts.get_py_script('gdal_edit')
    if script_path is None:
        return 'skip'

    shutil.copy('../gcore/data/byte.tif', 'tmp/test_gdal_edit_py.tif')

    test_py_scripts.run_py_script(script_path, 'gdal_edit', "tmp/test_gdal_edit_py.tif -unsetgt")

    ds = gdal.Open('tmp/test_gdal_edit_py.tif')
    wkt = ds.GetProjectionRef()
    gt = ds.GetGeoTransform(can_return_null = True)
    ds = None

    if gt is not None:
        gdaltest.post_reason('fail')
        print(gt)
        return 'fail'

    if wkt == '':
        gdaltest.post_reason('fail')
        print(wkt)
        return 'fail'

    return 'success'
开发者ID:jef-n,项目名称:gdal,代码行数:26,代码来源:test_gdal_edit.py


示例5: test_gdal_edit_py_7

def test_gdal_edit_py_7():

    script_path = test_py_scripts.get_py_script('gdal_edit')
    if script_path is None:
        return 'skip'

    gdal.Translate('tmp/test_gdal_edit_py.tif',
                   '../gcore/data/byte.tif',
                   options = '-b 1 -b 1 -b 1 -b 1 -co PHOTOMETRIC=RGB -co ALPHA=NO')

    test_py_scripts.run_py_script(script_path, 'gdal_edit', "tmp/test_gdal_edit_py.tif -colorinterp_4 alpha")

    ds = gdal.Open('tmp/test_gdal_edit_py.tif')
    if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_AlphaBand:
        gdaltest.post_reason('fail')
        return 'fail'

    test_py_scripts.run_py_script(script_path, 'gdal_edit', "tmp/test_gdal_edit_py.tif -colorinterp_4 undefined")

    ds = gdal.Open('tmp/test_gdal_edit_py.tif')
    if ds.GetRasterBand(4).GetColorInterpretation() != gdal.GCI_Undefined:
        gdaltest.post_reason('fail')
        return 'fail'

    return 'success'
开发者ID:jef-n,项目名称:gdal,代码行数:25,代码来源:test_gdal_edit.py


示例6: test_gdalmove_1

def test_gdalmove_1():

    script_path = test_py_scripts.get_py_script('gdalmove')
    if script_path is None:
        return 'skip'

    shutil.copy('../gcore/data/byte.tif', 'tmp/test_gdalmove_1.tif' )

    test_py_scripts.run_py_script(script_path, 'gdalmove', '-s_srs "+proj=utm +zone=11 +ellps=clrk66 +towgs84=0,0,0 +no_defs" -t_srs EPSG:32611 tmp/test_gdalmove_1.tif -et 1' )

    ds = gdal.Open('tmp/test_gdalmove_1.tif')
    got_gt = ds.GetGeoTransform()
    expected_gt = (440719.95870935748, 60.000041745067577, 1.9291142234578728e-05, 3751294.2109841029, 1.9099167548120022e-05, -60.000041705276814)
    for i in range(6):
        if abs(got_gt[i] - expected_gt[i]) / abs(got_gt[i]) > 1e-5:
            gdaltest.post_reason('bad gt')
            print(got_gt)
            print(expected_gt)
            return 'fail'
    wkt = ds.GetProjection()
    if wkt.find('32611') < 0:
        gdaltest.post_reason('bad geotransform')
        print(wkt)
        return 'fail'
    ds = None

    return 'success'
开发者ID:geo-data,项目名称:go-gdal,代码行数:27,代码来源:test_gdalmove.py


示例7: test_gdal_sieve_1

def test_gdal_sieve_1():

    script_path = test_py_scripts.get_py_script('gdal_sieve')
    if script_path is None:
        return 'skip'

    drv = gdal.GetDriverByName('GTiff')
    dst_ds = drv.Create('tmp/sieve_1.tif', 5, 7, 1, gdal.GDT_Byte)
    dst_ds = None

    test_py_scripts.run_py_script(script_path, 'gdal_sieve', '-nomask -st 2 -4 ../alg/data/sieve_src.grd tmp/sieve_1.tif')

    dst_ds = gdal.Open('tmp/sieve_1.tif')
    dst_band = dst_ds.GetRasterBand(1)

    cs_expected = 364
    cs = dst_band.Checksum()

    dst_band = None
    dst_ds = None

    if cs == cs_expected \
       or gdal.GetConfigOption('CPL_DEBUG', 'OFF') != 'ON':
        # Reload because of side effects of run_py_script()
        drv = gdal.GetDriverByName('GTiff')
        drv.Delete('tmp/sieve_1.tif')

    if cs != cs_expected:
        print('Got: ', cs)
        gdaltest.post_reason('got wrong checksum')
        return 'fail'
    return 'success'
开发者ID:hdfeos,项目名称:gdal,代码行数:32,代码来源:test_gdal_sieve.py


示例8: test_gdal_edit_py_4

def test_gdal_edit_py_4():

    script_path = test_py_scripts.get_py_script('gdal_edit')
    if script_path is None:
        return 'skip'

    shutil.copy('../gcore/data/byte.tif', 'tmp/test_gdal_edit_py.tif')
    ds = gdal.Open( 'tmp/test_gdal_edit_py.tif', gdal.GA_Update )
    ds.GetRasterBand(1).ComputeStatistics(False)
    ds = None

    ds = gdal.Open('tmp/test_gdal_edit_py.tif')
    if ds.GetRasterBand(1).GetMetadataItem('STATISTICS_MINIMUM') is None:
        gdaltest.post_reason('fail')
        return 'fail'
    ds = None
    
    test_py_scripts.run_py_script(script_path, 'gdal_edit', "tmp/test_gdal_edit_py.tif -unsetstats")

    ds = gdal.Open('tmp/test_gdal_edit_py.tif')
    if ds.GetRasterBand(1).GetMetadataItem('STATISTICS_MINIMUM') is not None:
        gdaltest.post_reason('fail')
        return 'fail'
    ds = None
    
    try:
        os.stat('tmp/test_gdal_edit_py.tif.aux.xml')
        gdaltest.post_reason('fail')
        return 'fail'
    except:
        pass

    return 'success'
开发者ID:samalone,项目名称:gdal-ios,代码行数:33,代码来源:test_gdal_edit.py


示例9: test_ogr2ogr_py_26

def test_ogr2ogr_py_26():
    script_path = test_py_scripts.get_py_script("ogr2ogr")
    if script_path is None:
        return "skip"

    if not ogrtest.have_geos():
        return "skip"

    try:
        os.stat("tmp/poly.shp")
        ogr.GetDriverByName("ESRI Shapefile").DeleteDataSource("tmp/poly.shp")
    except:
        pass

    test_py_scripts.run_py_script(
        script_path,
        "ogr2ogr",
        'tmp/poly.shp ../ogr/data/poly.shp -clipdst "POLYGON((479609 4764629,479609 4764817,479764 4764817,479764 4764629,479609 4764629))"',
    )

    ds = ogr.Open("tmp/poly.shp")
    if ds is None or ds.GetLayer(0).GetFeatureCount() != 4:
        return "fail"

    if ds.GetLayer(0).GetExtent() != (479609, 479764, 4764629, 4764817):
        print(ds.GetLayer(0).GetExtent())
        gdaltest.post_reason("unexpected extent")
        return "fail"

    ds.Destroy()

    ogr.GetDriverByName("ESRI Shapefile").DeleteDataSource("tmp/poly.shp")

    return "success"
开发者ID:sylvainallard,项目名称:gdal,代码行数:34,代码来源:test_ogr2ogr_py.py


示例10: test_ogr2ogr_py_22

def test_ogr2ogr_py_22():
    script_path = test_py_scripts.get_py_script("ogr2ogr")
    if script_path is None:
        return "skip"

    test_py_scripts.run_py_script(
        script_path,
        "ogr2ogr",
        '-f "MapInfo File" tmp/testogr2ogr22.mif ../utilities/data/dataforogr2ogr21.csv '
        + '-sql "SELECT comment, name FROM dataforogr2ogr21" -nlt POINT',
    )
    ds = ogr.Open("tmp/testogr2ogr22.mif")

    if ds is None:
        return "fail"
    layer_defn = ds.GetLayer(0).GetLayerDefn()
    lyr = ds.GetLayer(0)
    feat = lyr.GetNextFeature()
    if feat.GetFieldAsString("name") != "NAME" or feat.GetFieldAsString("comment") != "COMMENT":
        print(feat.GetFieldAsString("name"))
        print(feat.GetFieldAsString("comment"))
        ds.Destroy()
        ogr.GetDriverByName("MapInfo File").DeleteDataSource("tmp/testogr2ogr22.mif")
        return "fail"

    ds.Destroy()
    ogr.GetDriverByName("MapInfo File").DeleteDataSource("tmp/testogr2ogr22.mif")

    return "success"
开发者ID:sylvainallard,项目名称:gdal,代码行数:29,代码来源:test_ogr2ogr_py.py


示例11: test_gdal_proximity_1

def test_gdal_proximity_1():

    script_path = test_py_scripts.get_py_script('gdal_proximity')
    if script_path is None:
        return 'skip'
    
    drv = gdal.GetDriverByName( 'GTiff' )
    dst_ds = drv.Create('tmp/proximity_1.tif', 25, 25, 1, gdal.GDT_Byte )
    dst_ds = None

    test_py_scripts.run_py_script(script_path, 'gdal_proximity', '../alg/data/pat.tif tmp/proximity_1.tif' )

    dst_ds = gdal.Open('tmp/proximity_1.tif')
    dst_band = dst_ds.GetRasterBand(1)

    cs_expected = 1941
    cs = dst_band.Checksum()
    
    dst_band = None
    dst_ds = None

    if cs != cs_expected:
        print('Got: ', cs)
        gdaltest.post_reason( 'got wrong checksum' )
        return 'fail'
    else:
        return 'success' 
开发者ID:geo-data,项目名称:go-gdal,代码行数:27,代码来源:test_gdal_proximity.py


示例12: test_gdal_retile_2

def test_gdal_retile_2():

    script_path = test_py_scripts.get_py_script('gdal_retile')
    if script_path is None:
        return 'skip'

    try:
        os.mkdir('tmp/outretile2')
    except:
        pass

    test_py_scripts.run_py_script(script_path, 'gdal_retile', '-v -levels 2 -r bilinear -targetDir tmp/outretile2 ../gcore/data/rgba.tif' )

    ds = gdal.Open('tmp/outretile2/2/rgba_1_1.tif')
    if ds.GetRasterBand(1).Checksum() != 35:
        gdaltest.post_reason('wrong checksum for band 1')
        print(ds.GetRasterBand(1).Checksum())
        return 'fail'
    if ds.GetRasterBand(4).Checksum() != 35:
        gdaltest.post_reason('wrong checksum for band 4')
        print(ds.GetRasterBand(4).Checksum())
        return 'fail'
    ds = None

    return 'success'
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:25,代码来源:test_gdal_retile.py


示例13: test_gdal_pansharpen_1

def test_gdal_pansharpen_1():

    script_path = test_py_scripts.get_py_script('gdal_pansharpen')
    if script_path is None:
        return 'skip'

    src_ds = gdal.Open('../gdrivers/data/small_world.tif')
    src_data = src_ds.GetRasterBand(1).ReadRaster()
    gt = src_ds.GetGeoTransform()
    wkt = src_ds.GetProjectionRef()
    src_ds = None
    pan_ds = gdal.GetDriverByName('GTiff').Create('tmp/small_world_pan.tif', 800, 400)
    gt = [ gt[i] for i in range(len(gt)) ]
    gt[1] *= 0.5
    gt[5] *= 0.5
    pan_ds.SetGeoTransform(gt)
    pan_ds.SetProjection(wkt)
    pan_ds.GetRasterBand(1).WriteRaster(0,0,800,400,src_data,400,200)
    pan_ds = None

    test_py_scripts.run_py_script(script_path, 'gdal_pansharpen', ' tmp/small_world_pan.tif ../gdrivers/data/small_world.tif tmp/out.tif')

    ds = gdal.Open('tmp/out.tif')
    cs = [ ds.GetRasterBand(i+1).Checksum() for i in range(ds.RasterCount) ]
    ds = None
    gdal.GetDriverByName('GTiff').Delete('tmp/out.tif')

    if cs != [4735, 10000, 9742]:
        gdaltest.post_reason('fail')
        print(cs)
        return 'fail'

    return 'success'
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:33,代码来源:test_gdal_pansharpen.py


示例14: test_pct2rgb_4

def test_pct2rgb_4():
    try:
        from osgeo import gdalnumeric
        gdalnumeric.BandRasterIONumPy
    except:
        return 'skip'

    script_path = test_py_scripts.get_py_script('pct2rgb')
    if script_path is None:
        return 'skip'

    test_py_scripts.run_py_script(script_path, 'pct2rgb', '-rgba ../gcore/data/rat.img tmp/test_pct2rgb_4.tif')

    ds = gdal.Open('tmp/test_pct2rgb_4.tif')
    ori_ds = gdal.Open('../gcore/data/rat.img')

    ori_data = struct.unpack('H', ori_ds.GetRasterBand(1).ReadRaster(1990, 1990, 1, 1, 1, 1))[0]
    data = (struct.unpack('B', ds.GetRasterBand(1).ReadRaster(1990, 1990, 1, 1, 1, 1))[0],
            struct.unpack('B', ds.GetRasterBand(2).ReadRaster(1990, 1990, 1, 1, 1, 1))[0],
            struct.unpack('B', ds.GetRasterBand(3).ReadRaster(1990, 1990, 1, 1, 1, 1))[0],
            struct.unpack('B', ds.GetRasterBand(4).ReadRaster(1990, 1990, 1, 1, 1, 1))[0],)

    ct = ori_ds.GetRasterBand(1).GetRasterColorTable()
    entry = ct.GetColorEntry(ori_data)

    if entry != data:
        return 'fail'

    ds = None
    ori_ds = None

    return 'success'
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:32,代码来源:test_rgb2pct.py


示例15: test_pct2rgb_1

def test_pct2rgb_1():
    try:
        from osgeo import gdalnumeric
        gdalnumeric.BandRasterIONumPy
    except:
        return 'skip'

    script_path = test_py_scripts.get_py_script('pct2rgb')
    if script_path is None:
        return 'skip'

    test_py_scripts.run_py_script(script_path, 'pct2rgb', 'tmp/test_rgb2pct_1.tif tmp/test_pct2rgb_1.tif' )

    ds = gdal.Open('tmp/test_pct2rgb_1.tif')
    if ds.GetRasterBand(1).Checksum() != 20963:
        print(ds.GetRasterBand(1).Checksum())
        return 'fail'

    ori_ds = gdal.Open('../gcore/data/rgbsmall.tif')
    max_diff = gdaltest.compare_ds(ori_ds, ds)
    if max_diff > 18:
        return 'fail'

    ds = None
    ori_ds = None

    return 'success'
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:27,代码来源:test_rgb2pct.py


示例16: test_ogrmerge_5

def test_ogrmerge_5():
    script_path = test_py_scripts.get_py_script('ogrmerge')
    if script_path is None:
        return 'skip'

    test_py_scripts.run_py_script(script_path, 'ogrmerge',
        '-f VRT -o /vsimem/out.vrt ../ogr/data/poly.shp ../ogr/data/testpoly.shp -nln '
        '"foo_{DS_NAME}_{DS_BASENAME}_{DS_INDEX}_{LAYER_NAME}_{LAYER_INDEX}"')

    ds = ogr.Open('/vsimem/out.vrt')
    lyr = ds.GetLayer(0)
    if lyr.GetName() != 'foo_../ogr/data/poly.shp_poly_0_poly_0':
        gdaltest.post_reason('fail')
        print(lyr.GetName())
        return 'fail'
    if lyr.GetFeatureCount() != 10:
        gdaltest.post_reason('fail')
        return 'fail'
    lyr = ds.GetLayer(1)
    if lyr.GetName() != 'foo_../ogr/data/testpoly.shp_testpoly_1_testpoly_0':
        gdaltest.post_reason('fail')
        print(lyr.GetName())
        return 'fail'
    if lyr.GetFeatureCount() != 14:
        gdaltest.post_reason('fail')
        return 'fail'
    ds = None

    gdal.Unlink('/vsimem/out.vrt')

    return 'success'
开发者ID:jef-n,项目名称:gdal,代码行数:31,代码来源:test_ogrmerge.py


示例17: test_gdal_calc_py_3

def test_gdal_calc_py_3():

    if gdalnumeric_not_available:
        return 'skip'

    script_path = test_py_scripts.get_py_script('gdal_calc')
    if script_path is None:
        return 'skip'

    test_py_scripts.run_py_script(script_path, 'gdal_calc', '-A tmp/test_gdal_calc_py.tif --allBands A --calc=A --overwrite --outfile tmp/test_gdal_calc_py_3.tif')

    ds = gdal.Open('tmp/test_gdal_calc_py_3.tif')

    if ds is None:
        gdaltest.post_reason('ds not found')
        return 'fail'
    if ds.GetRasterBand(1).Checksum() != 12603:
        gdaltest.post_reason('band 1 wrong checksum')
        return 'fail'
    if ds.GetRasterBand(2).Checksum() != 58561:
        gdaltest.post_reason('band 2 wrong checksum')
        return 'fail'
    if ds.GetRasterBand(3).Checksum() != 36064:
        gdaltest.post_reason('band 3 wrong checksum')
        return 'fail'
    if ds.GetRasterBand(4).Checksum() != 10807:
        gdaltest.post_reason('band 4 wrong checksum')
        return 'fail'

    ds = None

    return 'success'
开发者ID:ksshannon,项目名称:gdal,代码行数:32,代码来源:test_gdal_calc.py


示例18: test_gdalinfo_py_5

def test_gdalinfo_py_5():
    script_path = test_py_scripts.get_py_script('gdalinfo')
    if script_path is None:
        return 'skip'

    try:
        os.remove('../gcore/data/byte.tif.aux.xml')
    except:
        pass

    ret = test_py_scripts.run_py_script(script_path, 'gdalinfo', '../gcore/data/byte.tif')
    if ret.find('STATISTICS_MINIMUM=74') != -1:
        gdaltest.post_reason( 'got wrong minimum.' )
        print(ret)
        return 'fail'

    ret = test_py_scripts.run_py_script(script_path, 'gdalinfo', '-stats ../gcore/data/byte.tif')
    if ret.find('STATISTICS_MINIMUM=74') == -1:
        gdaltest.post_reason( 'got wrong minimum (2).' )
        print(ret)
        return 'fail'

    # We will blow an exception if the file does not exist now!
    os.remove('../gcore/data/byte.tif.aux.xml')

    return 'success'
开发者ID:nextgis-borsch,项目名称:tests,代码行数:26,代码来源:test_gdalinfo_py.py


示例19: test_gdal_edit_py_3

def test_gdal_edit_py_3():

    script_path = test_py_scripts.get_py_script('gdal_edit')
    if script_path is None:
        return 'skip'

    shutil.copy('../gcore/data/byte.tif', 'tmp/test_gdal_edit_py.tif')

    test_py_scripts.run_py_script(script_path, 'gdal_edit', "tmp/test_gdal_edit_py.tif -a_srs ''")

    ds = gdal.Open('tmp/test_gdal_edit_py.tif')
    wkt = ds.GetProjectionRef()
    gt = ds.GetGeoTransform()
    ds = None

    if gt == (0.0, 1.0, 0.0, 0.0, 0.0, 1.0):
        gdaltest.post_reason('fail')
        print(gt)
        return 'fail'

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

    return 'success'
开发者ID:drons,项目名称:gdal,代码行数:26,代码来源:test_gdal_edit.py


示例20: test_ogr2ogr_py_16

def test_ogr2ogr_py_16():
    script_path = test_py_scripts.get_py_script("ogr2ogr")
    if script_path is None:
        return "skip"

    try:
        os.stat("tmp/poly.shp")
        ogr.GetDriverByName("ESRI Shapefile").DeleteDataSource("tmp/poly.shp")
    except:
        pass

    test_py_scripts.run_py_script(script_path, "ogr2ogr", "-fid 8 tmp/poly.shp ../ogr/data/poly.shp")

    src_ds = ogr.Open("../ogr/data/poly.shp")
    ds = ogr.Open("tmp/poly.shp")
    if ds is None or ds.GetLayer(0).GetFeatureCount() != 1:
        return "fail"
    src_feat = src_ds.GetLayer(0).GetFeature(8)
    feat = ds.GetLayer(0).GetNextFeature()
    if feat.GetField("EAS_ID") != src_feat.GetField("EAS_ID"):
        return "fail"
    ds.Destroy()
    src_ds.Destroy()

    ogr.GetDriverByName("ESRI Shapefile").DeleteDataSource("tmp/poly.shp")
    return "success"
开发者ID:sylvainallard,项目名称:gdal,代码行数:26,代码来源:test_ogr2ogr_py.py



注:本文中的test_py_scripts.run_py_script函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_qgspallabeling_base.runSuite函数代码示例发布时间:2022-05-27
下一篇:
Python test_py_scripts.get_py_script函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap