面转线 (数据管理)

摘要

创建的要素类中将包含由面边界转换而来的线(无论是否考虑邻近面)。

插图

Polygon To Line illustration

用法

语法

PolygonToLine_management (in_features, out_feature_class, {neighbor_option})
参数说明数据类型
in_features

几何必须为面的输入要素。

Feature Layer
out_feature_class

输出线要素类。

Feature Class
neighbor_option
(可选)

指定是否识别并存储面邻域信息。

  • IDENTIFY_NEIGHBORS识别面邻域关系并将该关系存储在输出中。如果某个面的不同线段与不同的面共用边界,那么该边界将被分割成各个唯一公用的线段,这些线段的两个邻近面 FID 值将存储在输出中。这是默认设置。
  • IGNORE_NEIGHBORS忽略面邻域关系;每个面边界均将变为线要素,并且边界原始面要素 ID 将存储在输出中。
Boolean

代码示例

PolygonToLine 示例 1(Python 窗口)

以下 Python 窗口脚本演示了如何在立即模式下使用 PolygonToLine 函数。

import arcpy from arcpy import env env.workspace = "C:/data" arcpy.PolygonToLine_management("Habitat_Analysis.gdb/vegtype",                                 "C:/output/Output.gdb/vegtype_lines",                                "IGNORE_NEIGHBORS")
PolygonToLine 示例 2(独立脚本)

以下独立脚本是如何在脚本环境中应用 PolygonToLine 函数的简单示例。

# Name: PolygonToLine_Example2.py # Description: Use PolygonToLine function to convert polygons to lines, #              and report how many shared or overlapping boundary lines #              were found. # Author: ESRI  # import system modules  import arcpy from arcpy import env  # Set environment settings env.workspace = "C:/data/landcovers.gdb"   # Create variables for the input and output feature classes inFeatureClass = "bldgs" outFeatureClass = "bldgs_lines"   # Use error trapping in case a problem occurs when running the tool try:     # Run PolygonToLine to convert polygons to lines using default neighbor_option     arcpy.PolygonToLine_management(inFeatureClass, outFeatureClass)       # Select lines that have LEFT_FID values greater than -1     arcpy.MakeFeatureLayer_management(outFeatureClass, "selection_lyr",                                        "\"LEFT_FID\" > -1")     result = arcpy.GetCount_management("selection_lyr")      if (result.getOutput(0) == "0"):         print "No overlapping or shared boundary lines were found."     else:         print result.getOutput(0) + " overlapping or shared " +\               "boundary lines were found."   except Exception, e:     # If an error occurred, print line number and error message     import traceback, sys     tb = sys.exc_info()[2]     print "Line %i" % tb.tb_lineno     print e.message 

环境

相关主题

许可信息

ArcView: 否
ArcEditor: 否
ArcInfo: 是

7/10/2012