ListDatasets

摘要

返回当前工作空间中的数据集的列表。 可针对数据集名称和数据集类型指定搜索条件,从而限制返回的列表。

说明

必须先设置工作空间环境,然后才能使用多个列表函数,包括 ListDatasetsListFeatureClassesListFilesListRastersListTablesListWorkspaces

语法

ListDatasets ({wild_card}, {feature_type})
参数说明数据类型
wild_card

限制返回的结果。如果未指定某一值,则返回所有值。通配符不区分大小写。

符号说明示例

*

表示零个或多个字符。

Te* 可找到田纳西州和德克萨斯州。

String
feature_type

Specifies the type of dataset that will be returned.

  • CoverageCoverages will be returned.
  • FeatureCoverages or geodatabase datasets will be returned, depending on the workspace.
  • GeometricNetworkGeometric network datasets will be returned.
  • LasDatasetLAS datasets will be returned.
  • MosaicMosaic datasets will be returned.
  • NetworkNetwork datasets will be returned.
  • ParcelFabricParcel fabric datasets will be returned.
  • ParcelFabricForArcmapArcMap parcel fabric datasets will be returned.
  • RasterRaster datasets will be returned.
  • RasterCatalogRaster catalog datasets will be returned.
  • TerrainTerrain datasets will be returned.
  • TinTIN datasets will be returned.
  • TopologyTopology datasets will be returned.
  • TraceNetworkTrace network datasets will be returned.
  • UtilityNetworkUtility network datasets will be returned.
  • AllAll datasets in the workspace will be returned.

(默认值为 All)

String
返回值
数据类型说明
String

该函数返回包含数据集名称的列表,该列表受通配符和要素类型参数限制。

代码示例

ListDatasets 示例

列出以 C 开头的要素数据集名称。

import arcpy

arcpy.env.workspace = "c:/data"

# Print all the feature datasets in the workspace that start with the letter C.
datasets = arcpy.ListDatasets("C*", "Feature")

for dataset in datasets:
    print(dataset)
ListDatasets 示例 2

列出以 c 或 f 开头、以 c 以外的其他字母开头或同时包含 c 和 f 的要素数据集名称。

import arcpy
arcpy.env.workspace = 'c:/data'

# Print all the feature datasets in the workspace that start with the letter c
# or f.
datasets1 = list(set(arcpy.ListDatasets("c*", "Feature")) |
                 set(arcpy.ListDatasets("f*", "Feature")))
print(datasets1)

# Print all the feature datasets in the workspace that start with the letters
# except c.
datasets2 = list(set(arcpy.ListDatasets("*", "Feature")) -
                 set(arcpy.ListDatasets("c*", "Feature")))
print(datasets2)

# Print all the feature datasets in the workspace that contain both the letter c
# and f.
datasets3 = list(set(arcpy.ListDatasets("*c*", "Feature")) &
                 set(arcpy.ListDatasets("*f*", "Feature")))
print(datasets3)
ListDatasets 示例 3

使用 feature_type 关键字参数列出追踪网络数据集。

import arcpy

arcpy.env.workspace = 'c:/data/myGDB.gdb/TN_dataset'

# Print all the trace networks in the workspace.
datasets = arcpy.ListDatasets(feature_type="tracenetwork")
for dataset in datasets:
    print(dataset)
ListDatasets 示例 4

使用位置参数列出地理数据库中的栅格数据集。

import arcpy

arcpy.env.workspace = 'c:/data/mySQLserver.sde'

# Print all the raster datasets in the workspace.
datasets = arcpy.ListDatasets("", "Raster")
for dataset in datasets:
    print(dataset)
ListDatasets 示例 5

列出企业级地理数据库中所有者为特定用户的要素数据集。

import arcpy
arcpy.env.workspace = 'c:/data/mySQLserver.sde' 

# Print all the feature datasets owned by 'user1' in the enterprise gdb
datasets = arcpy.ListDatasets("user1*", "Feature")
for dataset in datasets:
    print(dataset)

相关主题