1. 程式人生 > >利用arcpy在arcgis中實現polyline偏移(polyline節點遍歷、座標更新)

利用arcpy在arcgis中實現polyline偏移(polyline節點遍歷、座標更新)

今天我們來學習關於arcgis中的多義線偏移。使用的是令牌”[email protected]”,將多義線的拐點的x、y值取出來。然後再做平移操作。如下圖所示,為我們的測試資料polylineTest.shp多義線資料。下面的座標我們起始的座標數x、y值。

而下面是經過我們編寫程式碼,帶節點的x、y值上面分別增加了10.2的資料。其中藍色為我們的原始資料,而紫紅色為我們處理後的資料。

這次我們錄製一個除錯程式碼的一個小小的gif動畫,大家也可以跟著學習一下,雖然很簡單,但是可以學習一下。

原始碼如下所示:


import arcpy
testData="D:\Data\polylineTest\polylineTest.shp"
tempFeatureClass = "D:\Data\mmp.shp";
xOffset = 10.2
yOffset = 10.2

if arcpy.Exists(tempFeatureClass):
    arcpy.Delete_management(tempFeatureClass)

arcpy.CopyFeatures_management(testData, tempFeatureClass)

with arcpy.da.UpdateCursor(tempFeatureClass, ["
[email protected]
"]) as cursor: for row in cursor: cursor.updateRow([[row[0][0] + xOffset, row[0][1] + yOffset]])

在寫程式的時候,遇到了如下的找不到對應的資料表問題,從中可以知道是沒有找到表資料。需要正確的寫上表資料。

RuntimeError: 'in_table' is not a table or a featureclass


                                                                     更多內容,敬請關注公眾號