<< Click to Display Table of Contents >>

 

SelectLayerByAttribute

 

 

透過wkt格式字串,建立geometry物件

SelectLayerByAttribute(parameter_name, selection_type, where_clause, invert_where_clause)

參數

說明

參數類型

in_layer

要查詢的圖層

字串

selection_type

選擇類型,為下列任一種

每種類型會有不同處理方式

NEW – 新的選擇內容將替換當前選擇內容。

OR - 保留舊的選擇內容,並加入新的選擇內容

AND – 只保留舊的選擇內容,與新的選擇內容中,重複的選擇內容,若兩者沒有重複,則不會有任何選擇內容

字串

where_clause

選擇條件

字串

invert_where_clause

指定是否應反轉表達式結果。

NON_INVERT  - 將按原樣使用查詢結果。這是默認設置。

INVERT  - 將反轉查詢結果。如果使用selection_type選項,將在選擇內容與現有選擇內容組合之前進行反轉。

字串

SelectLayerByAttribute使用範例

import sgpy

# 取得目前地圖

sgd = sgpy.mapping.MapDocument("current")

# 取得data frame

df = sgd.activeDataFrame

#從檔案中載入圖層,並加入data frame中

lyr = sgpy.mapping.Layer("D:/temp/Line2.shp")

sgpy.mapping.AddLayer(df, lyr,"AUTO_ARRANGE")

#查詢並選取圖層

sgpy.SelectLayerByAttribute(lyr,"NEW","[prop2] = 'abc'","")

#地圖更新 (將前面所做的選取,套用到地圖上)

sgpy.RefreshActiveView()

 


©2015 Supergeo Technologies Inc. All rights reserved.