我在ArcGIS Model Builder中创建一个模型,该模型允许用户在地址数据库(存储为shapefile)中搜索地址,然后将其用作Network Analyst中的“停止”功能以提供最佳路线。我可以在邮政编码中找到多个功能,但是我不知道如何提取单个地址。
我当前使用的地址数据库是北爱尔兰的Pointer数据库,其中包含许多地址字段,例如建筑物编号,建筑物名称,街道和邮政编码。我编写了一个python脚本来搜索邮政编码并将特征转换为shapefile,但是结果(显然)是在邮政编码区域内找到的许多点要素。我发现很难提出一个脚本,该脚本将组合地址数据库中找到的字段以查找单点要素。这是我用来从shapefile中提取邮政编码的代码:
postcodei = arcpy.GetParameterAsText(0).upper()
outputLayer = arcpy.GetParameterAsText(1)
for address in addresses:
QueryStringPosti = "POSTCODE = \'" + postcodei + "\'"
arcpy.Select_analysis("Pointer_Fermanagh.shp","addressi.shp",QueryStringPosti)
arcpy.CopyFeatures_management("addressi.shp", outputLayer)
count = arcpy.GetCount_management("addressi.shp")
address_count = count.getOutput(0)
if int(address_count) > 0:
outString = address_count + " buildings within this postcode were found and imported to shapefile"
else:
outString = "*** ERROR: '" + postcodei + "' was not found"
arcpy.AddMessage(outString)
上面的脚本工作正常,但是如何增强它以组合数据集中的字段以搜索单个地址?如您所见,我只是从python开始,因此任何输入将不胜感激。