当前位置: 首页>>代码示例>>Python>>正文


Python test_py_scripts.get_py_script函数代码示例

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


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

示例1: run_gdal_ls

def run_gdal_ls(argv):
    script_path = test_py_scripts.get_py_script('gdal_ls')
    if script_path is None:
        return ('skip', None)

    saved_syspath = sys.path
    sys.path.append(script_path)
    try:
        import gdal_ls
    except ImportError:
        sys.path = saved_syspath
        return ('fail', None)

    sys.path = saved_syspath

    from sys import version_info
    if version_info >= (3, 0, 0):
        import io
        outstr = io.StringIO()
    else:
        import StringIO
        outstr = StringIO.StringIO()
    ret = gdal_ls.gdal_ls(argv, outstr)
    retstr = outstr.getvalue()
    outstr.close()

    if ret != 0:
        gdaltest.post_reason('got error code : %d' % ret)
        return ('fail', 'None')

    return ('success', retstr)
开发者ID:normanb,项目名称:gdal,代码行数:31,代码来源:test_gdal_ls_py.py

示例2: test_ogrinfo_py_5

def test_ogrinfo_py_5():
    script_path = test_py_scripts.get_py_script('ogrinfo')
    if script_path is None:
        pytest.skip()

    ret = test_py_scripts.run_py_script(script_path, 'ogrinfo', '../ogr/data/poly.shp -sql "select * from poly"')
    assert ret.find('Feature Count: 10') != -1
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:7,代码来源:test_ogrinfo_py.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_ogrinfo_py_9

def test_ogrinfo_py_9():
    script_path = test_py_scripts.get_py_script('ogrinfo')
    if script_path is None:
        pytest.skip()

    ret = test_py_scripts.run_py_script(script_path, 'ogrinfo', '../ogr/data/poly.shp poly -where "EAS_ID=171"')
    assert ret.find('Feature Count: 1') != -1
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:7,代码来源:test_ogrinfo_py.py

示例5: test_ogrinfo_py_2

def test_ogrinfo_py_2():
    script_path = test_py_scripts.get_py_script('ogrinfo')
    if script_path is None:
        pytest.skip()

    ret = test_py_scripts.run_py_script(script_path, 'ogrinfo', '-ro ../ogr/data/poly.shp')
    assert ret.find('ESRI Shapefile') != -1
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:7,代码来源:test_ogrinfo_py.py

示例6: 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

示例7: 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

示例8: test_gdal_calc_py_6

def test_gdal_calc_py_6():

    if gdalnumeric_not_available:
        gdaltest.post_reason('gdalnumeric is not available, skipping all tests')
        return 'skip'

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

    backup_sys_path = sys.path
    sys.path.insert(0, script_path)
    import gdal_calc

    gdal.Translate('tmp/test_gdal_calc_py.tif', '../gcore/data/byte.tif', options='-a_nodata 74')

    gdal_calc.Calc('A', A='tmp/test_gdal_calc_py.tif', overwrite=True, quiet=True, outfile='tmp/test_gdal_calc_py_6.tif', NoDataValue=1)

    sys.path = backup_sys_path

    ds = gdal.Open('tmp/test_gdal_calc_py_6.tif')
    cs = ds.GetRasterBand(1).Checksum()
    if cs != 4673:
        gdaltest.post_reason('failure')
        print(cs)
        return 'fail'
    result = ds.GetRasterBand(1).ComputeRasterMinMax()
    if result != (90, 255):
        gdaltest.post_reason('failure')
        print(result)
        return 'fail'

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

示例9: 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

示例10: 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

示例11: 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

示例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_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

示例14: 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

示例15: test_ogrinfo_py_10

def test_ogrinfo_py_10():
    script_path = test_py_scripts.get_py_script('ogrinfo')
    if script_path is None:
        pytest.skip()

    ret = test_py_scripts.run_py_script(script_path, 'ogrinfo', '../ogr/data/poly.shp poly -fid 9')
    assert ret.find('OGRFeature(poly):9') != -1
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:7,代码来源:test_ogrinfo_py.py


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