本文整理匯總了Python中ocgis.util.shp_cabinet.ShpCabinet._get_features_object_方法的典型用法代碼示例。如果您正苦於以下問題:Python ShpCabinet._get_features_object_方法的具體用法?Python ShpCabinet._get_features_object_怎麽用?Python ShpCabinet._get_features_object_使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ocgis.util.shp_cabinet.ShpCabinet
的用法示例。
在下文中一共展示了ShpCabinet._get_features_object_方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _run_
# 需要導入模塊: from ocgis.util.shp_cabinet import ShpCabinet [as 別名]
# 或者: from ocgis.util.shp_cabinet.ShpCabinet import _get_features_object_ [as 別名]
def _run_(s, func):
try:
ds = ogr.Open(path)
obj = ShpCabinet._get_features_object_(ds, select_sql_where=s)
func(obj)
finally:
ds.Destroy()
示例2: test_get_features_object
# 需要導入模塊: from ocgis.util.shp_cabinet import ShpCabinet [as 別名]
# 或者: from ocgis.util.shp_cabinet.ShpCabinet import _get_features_object_ [as 別名]
def test_get_features_object(self):
# test with a shapefile not having the default unique geometry identifier
path = self.get_shapefile_path_with_no_ugid()
keywords = dict(uid=[None, 'ID'],
select_uid=[None, [8, 11, 13]],
select_sql_where=[None, 'STATE_NAME = "Wisconsin"'])
for k in self.iter_product_keywords(keywords):
ds = ogr.Open(path)
try:
try:
obj = ShpCabinet._get_features_object_(ds, uid=k.uid, select_uid=k.select_uid,
select_sql_where=k.select_sql_where)
except RuntimeError:
self.assertIsNone(k.uid)
self.assertIsNotNone(k.select_uid)
continue
if k.select_sql_where is not None:
length = 1
elif k.select_uid is not None:
length = 3
else:
length = 11
self.assertEqual(len(obj), length)
self.assertIsInstance(obj, Layer)
finally:
ds.Destroy()
# test on a shapefile having the default unique geometry identifier
path = ShpCabinet().get_shp_path('state_boundaries')
ds = ogr.Open(path)
try:
obj = ShpCabinet._get_features_object_(ds, select_uid=[8, 11, 13])
self.assertEqual(len(obj), 3)
finally:
ds.Destroy()