使用ArcGIS Desktop创建线(最接近线的顶点)?


11

我正在使用ArcInfo 10 SP3。

我正在整理我们的实用数据。两年前,我们已经开始收集私人服务水管线。我们仍然有很多可以从旧的记录图中提取。

我想知道是否有办法创建将我们的建筑足迹连接到WaterMain线的生产线?

我想以最接近水管的建筑顶点作为起点。

在此处输入图片说明

Answers:


10

如果您正在寻找不需要开发.NET工具的解决方案,则可以使用下面的python脚本来精确地完成所需要的工作。我有完全相同的需求,并编写了以下脚本作为解决方案。使用4个参数将其配置为ArcCatalog工具,或者注释掉参数并取消注释硬编码变量,然后直接运行它。

# CreateLineFromNearestVertexToFeature.py
# Author: Jeff Berry
# Description: Creates a line between the nearest vertext on source features
# to the nearest feature in target feature class.
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy
from arcpy import env

# Local variables:
# 1. SourceFC - Feature Class 
# 2. TargetFC - Feature Class
# 3. Output_gdb - Geodatabase
# 4. Output_fc - String

SourceFC = arcpy.GetParameterAsText(0)
TargetFC = arcpy.GetParameterAsText(1)
Output_gdb = arcpy.GetParameterAsText(2)
Output_fc = arcpy.GetParameterAsText(3)

## Alternatively setup hardcoded variables    
##SourceFC = "Buildings"
##TargetFC = "WaterMains"
##Output_gdb = "D:\\New File Geodatabase.gdb"
##Output_fc = "lines_output"

SourceFeaturePoints = "SrcFtrPoints"
arcpy.env.workspace = Output_gdb

# Process: Feature Vertices To Points
arcpy.FeatureVerticesToPoints_management(SourceFC, SourceFeaturePoints, "ALL")

# Process: Near
arcpy.Near_analysis(SourceFeaturePoints, TargetFC, "1000 Feet", "LOCATION", "NO_ANGLE")

# Process: Create Feature Class...
#arcpy.CreateFeatureclass_management(Output_gdb, Output_fc, "POLYLINE", "", "DISABLED", "DISABLED", "", "", "0", "0", "0")
rows = arcpy.SearchCursor(SourceFeaturePoints)

lstIDs = []

for row in rows:
    lstIDs.append(row.ORIG_FID)

uniqueOBJIDS = set(lstIDs)
newLineList = []
shapeName = arcpy.Describe(SourceFeaturePoints).shapeFieldName

for objID in uniqueOBJIDS:
    rows = arcpy.SearchCursor(SourceFeaturePoints, "\"NEAR_DIST\" = (SELECT MIN( \"NEAR_DIST\") FROM SrcFtrPoints WHERE \"ORIG_FID\"  = " + str(objID) + ")")
    for row in rows:
        arrayLine = arcpy.Array()
        ftr = row.getValue(shapeName)
        pointStart = ftr.firstPoint
        pointEnd = arcpy.Point(row.NEAR_X, row.NEAR_Y)
        arrayLine.add(pointStart)
        arrayLine.add(pointEnd)
        plyLine = arcpy.Polyline(arrayLine)
        newLineList.append(plyLine)


arcpy.CopyFeatures_management(newLineList, Output_fc)
arcpy.Delete_management(SourceFeaturePoints, "FeatureClass")

del rows
del row
del SourceFeaturePoints
del Output_fc
del Output_gdb
arcpy.ClearEnvironment("workspace")

2

查看IIndexQuery2上的“ NearestFeature”方法。

您可以使用它来获取最接近每个建筑物的水管要素。我猜您可能会因此需要以某种方式遍历每座建筑物上的顶点,以找到最接近该要素的距离,然后使用建筑物和水管中的顶点作为端点来构建一条新的折线。我唯一这样做的地方是使用两个点要素类,希望我可以提供更多的服务。.:D

IFeatureCursor pDepthCursor = pDepthSoundings.Search(null, false);
IFeatureIndex2 pFtrInd = new FeatureIndexClass();
pFtrInd.FeatureClass = pDepthSoundings.FeatureClass;
pFtrInd.FeatureCursor = pDepthCursor;
pFtrInd.Index(null, pCombinedEnvelope);
IIndexQuery2 pIndQry = pFtrInd as IIndexQuery2;

int FtdID = 0;
double dDist2Ftr = 0;
pIndQry.NearestFeature(ppoint, out FtdID, out dDist2Ftr);

IFeature pCloseFeature = pDepthSoundings.FeatureClass.GetFeature(FtdID);
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.