本文整理汇总了Python中test_cli_utilities.get_ogr2ogr_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_ogr2ogr_path函数的具体用法?Python get_ogr2ogr_path怎么用?Python get_ogr2ogr_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_ogr2ogr_path函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_gdalwarp_46
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
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:35,代码来源:test_gdalwarp.py
示例2: test_ogr2ogr_py_23
def test_ogr2ogr_py_23():
script_path = test_py_scripts.get_py_script("ogr2ogr")
if script_path is None:
return "skip"
if test_cli_utilities.get_ogr2ogr_path() is None:
return "skip"
gdaltest.runexternal(
test_cli_utilities.get_ogr2ogr_path()
+ ' -f "MapInfo File" tmp/testogr2ogr23.mif ../utilities/data/dataforogr2ogr21.csv '
+ '-sql "SELECT comment, name FROM dataforogr2ogr21" -select comment,name -nlt POINT'
)
ds = ogr.Open("tmp/testogr2ogr23.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/testogr2ogr23.mif")
return "fail"
ds.Destroy()
ogr.GetDriverByName("MapInfo File").DeleteDataSource("tmp/testogr2ogr23.mif")
return "success"
开发者ID:sylvainallard,项目名称:gdal,代码行数:30,代码来源:test_ogr2ogr_py.py
示例3: ogr_fgdb_3
def ogr_fgdb_3():
if ogrtest.fgdb_drv is None:
return 'skip'
import test_cli_utilities
if test_cli_utilities.get_ogr2ogr_path() is None:
return 'skip'
if test_cli_utilities.get_test_ogrsf_path() is None:
return 'skip'
try:
shutil.rmtree("tmp/poly.gdb")
except:
pass
gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' -f filegdb tmp/poly.gdb data/poly.shp -nlt MULTIPOLYGON -a_srs None')
ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' tmp/poly.gdb')
#print ret
if ret.find('INFO') == -1 or ret.find('ERROR') != -1:
print(ret)
return 'fail'
return 'success'
开发者ID:Joe-xXx,项目名称:gdal,代码行数:25,代码来源:ogr_fgdb.py
示例4: ogr_fgdb_3
def ogr_fgdb_3():
if ogrtest.fgdb_drv is None:
return 'skip'
import test_cli_utilities
if test_cli_utilities.get_ogr2ogr_path() is None:
return 'skip'
try:
shutil.rmtree("tmp/poly.gdb")
except:
pass
gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' -f filegdb tmp/poly.gdb data/poly.shp -nlt MULTIPOLYGON -a_srs None')
ds = ogr.Open('tmp/poly.gdb')
if ds is None or ds.GetLayerCount() == 0:
gdaltest.post_reason('ogr2ogr failed')
return 'fail'
ds = None
if test_cli_utilities.get_test_ogrsf_path() is None:
return 'skip'
ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' tmp/poly.gdb')
#print ret
if ret.find('INFO') == -1 or ret.find('ERROR') != -1:
print(ret)
return 'fail'
return 'success'
开发者ID:afarnham,项目名称:gdal,代码行数:32,代码来源:ogr_fgdb.py
示例5: ogr_osm_3
def ogr_osm_3(options = None):
try:
drv = ogr.GetDriverByName('OSM')
except:
drv = None
if drv is None:
return 'skip'
import test_cli_utilities
if test_cli_utilities.get_ogr2ogr_path() is None:
return 'skip'
try:
os.stat('tmp/ogr_osm_3')
ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource('tmp/ogr_osm_3')
except:
pass
if options is not None:
options = ' ' + options
else:
options = ''
gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' tmp/ogr_osm_3 data/test.pbf points lines polygons multipolygons multilinestrings -progress' + options)
ret = ogr_osm_1('tmp/ogr_osm_3')
ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource('tmp/ogr_osm_3')
return ret
开发者ID:afarnham,项目名称:gdal,代码行数:30,代码来源:ogr_osm.py
示例6: test_ogr_osm_6
def test_ogr_osm_6():
if ogrtest.osm_drv is None:
pytest.skip()
import test_cli_utilities
if test_cli_utilities.get_ogr2ogr_path() is None:
pytest.skip()
try:
os.stat('tmp/ogr_osm_6')
ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource('tmp/ogr_osm_6')
except (OSError, AttributeError):
pass
gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' tmp/ogr_osm_6 data/test.pbf -sql "select * from multipolygons" -progress')
ds = ogr.Open('tmp/ogr_osm_6')
lyr = ds.GetLayer(0)
count = lyr.GetFeatureCount()
ds = None
ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource('tmp/ogr_osm_6')
assert count == 3
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:25,代码来源:ogr_osm.py
示例7: ogr_osm_6
def ogr_osm_6():
if ogrtest.osm_drv is None:
return 'skip'
import test_cli_utilities
if test_cli_utilities.get_ogr2ogr_path() is None:
return 'skip'
try:
os.stat('tmp/ogr_osm_6')
ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource('tmp/ogr_osm_6')
except:
pass
gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' tmp/ogr_osm_6 data/test.pbf -sql "select * from multipolygons" -progress')
ds = ogr.Open('tmp/ogr_osm_6')
lyr = ds.GetLayer(0)
count = lyr.GetFeatureCount()
ds = None
ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource('tmp/ogr_osm_6')
if count != 3:
gdaltest.post_reason('fail')
print(count)
return 'fail'
return 'success'
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:30,代码来源:ogr_osm.py
示例8: ogr_gft_ogr2ogr_non_spatial
def ogr_gft_ogr2ogr_non_spatial():
if ogrtest.gft_drv is None:
return "skip"
if not ogrtest.gft_can_write:
return "skip"
import test_cli_utilities
if test_cli_utilities.get_ogr2ogr_path() is None:
return "skip"
layer_name = "no_geometry_table_%d" % ogrtest.gft_rand_val
f = open("tmp/no_geometry_table.csv", "wt")
f.write("foo,bar\n")
f.write('"baz","foo"\n')
f.write('"baz2","foo2"\n')
f.write('"baz\'3","foo3"\n')
f.close()
gdaltest.runexternal(
test_cli_utilities.get_ogr2ogr_path()
+ ' -f GFT "GFT:refresh='
+ ogrtest.gft_refresh
+ '" tmp/no_geometry_table.csv -nln '
+ layer_name
+ " -overwrite"
)
os.unlink("tmp/no_geometry_table.csv")
ds = ogr.Open("GFT:refresh=%s" % ogrtest.gft_refresh, update=1)
lyr = ds.GetLayerByName(layer_name)
if lyr.GetLayerDefn().GetFieldCount() != 2:
gdaltest.post_reason("did not get expected field count")
ds.ExecuteSQL("DELLAYER:" + layer_name)
return "fail"
if lyr.GetGeomType() != ogr.wkbNone:
gdaltest.post_reason("did not get expected layer geometry type")
ds.ExecuteSQL("DELLAYER:" + layer_name)
return "fail"
if lyr.GetFeatureCount() != 3:
gdaltest.post_reason("did not get expected feature count")
ds.ExecuteSQL("DELLAYER:" + layer_name)
return "fail"
ds.ExecuteSQL("DELLAYER:" + layer_name)
ds = None
return "success"
开发者ID:nextgis-borsch,项目名称:tests,代码行数:53,代码来源:ogr_gft.py
示例9: ogr_mitab_14
def ogr_mitab_14():
if gdaltest.mapinfo_drv is None:
return 'skip'
import ogr_gml_read
if ogr_gml_read.ogr_gml_1() != 'success':
return 'skip'
if test_cli_utilities.get_ogr2ogr_path() is None:
return 'skip'
try:
os.stat('tmp/testlyrdef.mif')
ogr.GetDriverByName('MapInfo File').DeleteDataSource('tmp/testlyrdef.mif')
except:
pass
gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' -f "MapInfo File" -dsco FORMAT=MIF tmp/testlyrdef.mif ../ogr/data/testlyrdef.gml')
ds = ogr.Open('tmp/testlyrdef.mif')
#Check if the width and precision are as preserved.
lyr = ds.GetLayer('testlyrdef')
if lyr is None:
gdaltest.post_reason( 'Layer missing.' )
return 'fail'
defn = lyr.GetLayerDefn()
data = [['AREA', ogr.OFTReal, 7, 4],
['VOLUME',ogr.OFTReal, 0, 0],
['LENGTH',ogr.OFTInteger,254,0],
['WIDTH', ogr.OFTInteger,254,0]]
for field in data:
fld = defn.GetFieldDefn(defn.GetFieldIndex(field[0]))
expected_with = field[2]
if fld.GetType() == ogr.OFTInteger:
expected_with = 0
if fld.GetType() != field[1] or fld.GetWidth() != expected_with or fld.GetPrecision() != field[3]:
gdaltest.post_reason( field[0] + ' field definition wrong.' )
return 'fail'
ds.Destroy()
ogr.GetDriverByName('MapInfo File').DeleteDataSource('tmp/testlyrdef.mif')
return 'success'
开发者ID:samalone,项目名称:gdal-ios,代码行数:49,代码来源:ogr_mitab.py
示例10: ogr_gft_ogr2ogr_non_spatial
def ogr_gft_ogr2ogr_non_spatial():
if ogrtest.gft_drv is None:
return 'skip'
if not ogrtest.gft_can_write:
return 'skip'
import test_cli_utilities
if test_cli_utilities.get_ogr2ogr_path() is None:
return 'skip'
layer_name = 'no_geometry_table_%d' % ogrtest.gft_rand_val
f = open('tmp/no_geometry_table.csv', 'wt')
f.write('foo,bar\n')
f.write('"baz","foo"\n')
f.write('"baz2","foo2"\n')
f.write('"baz\'3","foo3"\n')
f.close()
gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' -f GFT "GFT:refresh=' + ogrtest.gft_refresh + '" tmp/no_geometry_table.csv -nln ' + layer_name + ' -overwrite')
os.unlink('tmp/no_geometry_table.csv')
ds = ogr.Open('GFT:refresh=%s' % ogrtest.gft_refresh, update = 1)
lyr = ds.GetLayerByName(layer_name)
if lyr.GetLayerDefn().GetFieldCount() != 2:
gdaltest.post_reason('did not get expected field count')
ds.ExecuteSQL('DELLAYER:' + layer_name)
return 'fail'
if lyr.GetGeomType() != ogr.wkbNone:
gdaltest.post_reason('did not get expected layer geometry type')
ds.ExecuteSQL('DELLAYER:' + layer_name)
return 'fail'
if lyr.GetFeatureCount() != 3:
gdaltest.post_reason('did not get expected feature count')
ds.ExecuteSQL('DELLAYER:' + layer_name)
return 'fail'
ds.ExecuteSQL('DELLAYER:' + layer_name)
ds = None
return 'success'
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:45,代码来源:ogr_gft.py
示例11: ogr_tiger_3
def ogr_tiger_3():
if ogrtest.tiger_ds is None:
return 'skip'
import test_cli_utilities
if test_cli_utilities.get_ogr2ogr_path() is None:
return 'skip'
try:
shutil.rmtree('tmp/outtiger')
except:
pass
gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' -f TIGER tmp/outtiger tmp/cache/TGR01001 -dsco VERSION=1006')
ret = 'success'
filelist = os.listdir('tmp/cache/TGR01001')
exceptions = [ 'TGR01001.RTA', 'TGR01001.RTC', 'TGR01001.MET', 'TGR01001.RTZ', 'TGR01001.RTS']
for filename in filelist:
if filename in exceptions:
continue
f = open('tmp/cache/TGR01001/' + filename, 'rb')
data1 = f.read()
f.close()
try:
f = open('tmp/outtiger/' + filename, 'rb')
data2 = f.read()
f.close()
if data1 != data2:
#gdaltest.post_reason('%s is different' % filename)
print('%s is different' % filename)
ret = 'fail'
except:
#gdaltest.post_reason('could not find %s' % filename)
print('could not find %s' % filename)
ret = 'fail'
try:
shutil.rmtree('tmp/outtiger')
except:
pass
return ret
开发者ID:samalone,项目名称:gdal-ios,代码行数:45,代码来源:ogr_tiger.py
示例12: ogr_ods_5
def ogr_ods_5():
drv = ogr.GetDriverByName('ODS')
if drv is None:
return 'skip'
import test_cli_utilities
if test_cli_utilities.get_ogr2ogr_path() is None:
return 'skip'
gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' -f ODS tmp/test.ods data/test.ods')
ds = ogr.Open('tmp/test.ods')
ret = ogr_ods_check(ds)
ds = None
os.unlink('tmp/test.ods')
return ret
开发者ID:normanb,项目名称:gdal,代码行数:19,代码来源:ogr_ods.py
示例13: ogr_xlsx_5
def ogr_xlsx_5():
drv = ogr.GetDriverByName('XLSX')
if drv is None:
return 'skip'
import test_cli_utilities
if test_cli_utilities.get_ogr2ogr_path() is None:
return 'skip'
gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' -f XLSX tmp/test.xlsx data/test.xlsx')
ds = ogr.Open('tmp/test.xlsx')
ret = ogr_xlsx_check(ds)
ds = None
os.unlink('tmp/test.xlsx')
return ret
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:19,代码来源:ogr_xlsx.py
注:本文中的test_cli_utilities.get_ogr2ogr_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论