本文整理汇总了Python中owslib.wfs.WebFeatureService.items方法的典型用法代码示例。如果您正苦于以下问题:Python WebFeatureService.items方法的具体用法?Python WebFeatureService.items怎么用?Python WebFeatureService.items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类owslib.wfs.WebFeatureService
的用法示例。
在下文中一共展示了WebFeatureService.items方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from owslib.wfs import WebFeatureService [as 别名]
# 或者: from owslib.wfs.WebFeatureService import items [as 别名]
# print(layer_def.GetFieldCount())
# layer = None
# OGR_end = time.clock()
# print(OGR_end - OGR_start)
OWS_start = time.clock()
try:
wfs = WebFeatureService(WFS_URL, version="2.0.0")
except AttributeError:
wfs = WebFeatureService(WFS_URL, version="1.1.0")
print("\n\tGlobal: ", dir(wfs))
print(wfs.version)
print(wfs.url)
print(wfs.items()[0][1])
help(wfs.getSRS)
print(wfs.timeout)
print("\n\tIdentification: ", dir(wfs.identification))
print(wfs.identification.type)
print(wfs.identification.title)
print(wfs.identification.service)
abstract = wfs.identification.abstract
if abstract: print(abstract.encode('utf8'))
print(wfs.identification.fees)
print(wfs.identification.version)
print(wfs.identification.keywords)
print(wfs.identification.accessconstraints)
print(wfs.identification.profiles)
示例2: WFSDataServiceToReclineJS
# 需要导入模块: from owslib.wfs import WebFeatureService [as 别名]
# 或者: from owslib.wfs.WebFeatureService import items [as 别名]
class WFSDataServiceToReclineJS():
def __init__(self, url, version="1.0.0"):
self.wfs = WebFeatureService(url, version=version)
self.type = self.wfs.identification.type
self.version = self.wfs.identification.version
self.title = self.wfs.identification.title
self.abstract = self.wfs.identification.abstract
def get_layer_list(self):
return list(self.wfs.contents)
def get_single_layer(self, layer):
theseLayers = self.get_layer_list()
return [i for i in theseLayers if i == layer]
def get_service_operations(self):
thisWFS = self.wfs.operations
return [op.name for op in thisWFS]
def get_GET_feature_operation(self):
operations = self.get_service_operations()
return [i for i in operations if i.endswith("GetFeature")][0]
def get_service_methods(self, service_operation):
thisWFS = self.wfs
thisOperation = service_operation
return thisWFS.getOperationByName(thisOperation).methods
#
def get_service_method_URL(self, service_operation):
thisWFS = self.wfs
thisOperation = service_operation
return thisWFS.getOperationByName('{http://www.opengis.net/wfs}GetFeature').methods['{http://www.opengis.net/wfs}Get']['url']
def get_service_format_options(self, service_operation):
thisWFS = self.wfs
thisOperation = service_operation
return thisWFS.getOperationByName(thisOperation).formatOptions
def get_GML_format_option(self, service_operation):
formatOptions = self.get_service_format_options(service_operation)
return [i for i in formatOptions if i.endswith("GML2")][0]
def get_response(self, layer):
thisLayer = self.get_single_layer(layer)
thisOperation = self.get_GET_feature_operation()
thisGML = self.get_GML_format_option(thisOperation)
response = self.wfs.getfeature(typename=thisLayer)
return response
def get_items(self):
return self.wfs.items()
def hack_up_a_layer_name(self, data_dict):
data = data_dict.get("resource")
if data.get("layer_name"):
return data.get("layer_name")
elif data.get("layer"):
return data.get("layer")
elif data.get("layers"):
return data.get("layers")
else:
try:
layer_list = self.get_layers()
return layer_list[0]
except:
return "Sorry, can't find a layer!"
def make_recline_url(self, data_dict):
data = data_dict
thisLayer = self.hack_up_a_layer_name(data).lower()
getMethod = self.get_GET_feature_operation()
baseURL = self.get_service_method_URL(getMethod)
baseURL += "&service=WFS&version=1.0.0&typeName="
baseURL += thisLayer
return baseURL
def MakeReclineJSON(self, data_dict):
json_obj = []
attribs = []
data = data_dict
gml_wfs = self.make_recline_url(data)
source = ogr.Open(gml_wfs)
print source
layer = source.GetLayerByIndex(0)
print layer
for feature in layer:
json_obj.append(feature.ExportToJson(as_object=True))
for i in json_obj:
properties = i['properties']
properties.update(dict(geometry=i['geometry']))
attribs.append(properties)
return attribs