<< Click to Display Table of Contents >>

Field
Field物件為 feature Class 或table資料中所有欄位的集合,內含許多用來描述每個欄位的屬性資料,包含欄位名稱,欄位資料別名等, field 物件可透過 ListFields方法來取得, 之後可透過迴圈,逐一取得每個欄位的描述。Field物件本身可被更新, 但並不影響feature Class 或table資料的欄位。
Field物件屬性
參數 |
說明 |
參數類型 |
aliasName (可讀寫) |
欄位別名 |
字串 |
name (可讀寫) |
欄位名稱 |
字串 |
type (可讀寫) |
欄位資料類型 |
字串 |
length (可讀寫) |
欄位長度 |
數值 |
precision (可讀寫) |
欄位精度 |
數值 |
editable (可讀寫) |
欄位能否編輯 |
布林值 |
isNullable (可讀寫) |
欄位可否為Null值 |
布林值 |
Field使用範例
import sgpy feature_class = "D:/temp/Line2.shp" # 透過ListFields,取得feature_class的所有field集合 fields =sgpy.ListFields(feature_class) #透過迴圈,逐一取的每個field的所有屬性,並列印 for field in fields: print("Field: {0}".format(field.name)) print("Alias: {0}".format(field.aliasName)) print("Type: {0}".format(field.type)) print("Is Editable: {0}".format(field.editable)) print("Precision: {0}".format(field.precision)) print("Length: {0}".format(field.length)) del field del fields |
©2015 Supergeo Technologies Inc. All rights reserved.