操作方法

操作方法:使用 arcgis.gis 模块中的查询和 ArcGIS Python API 来查找特定项目

Last Published: June 29, 2022

摘要

在诸如克隆、导出等各种工作流中使用 ArcGIS for Python API 时,可能需要在 ArcGIS Online 或 Portal for ArcGIS 中查找特定项目并仅对这些项目执行操作。 为此,可以使用 arcgis.gis 模块中的搜索函数。 您还可以使用不同的查询或者不同查询的组合来查找和使用某些项目。

本文中显示的一些示例介绍了如何使用 ArcGIS for Python API,通过查询在 AGOL 或 Portal 中查找项目。  


 

过程

在搜索函数中使用查询以返回 ArcGIS Online 中的特定项目的示例

  • 搜索全部内容:
items = gis.content.search(query='')
  • 按关键字搜索内容:
items = gis.content.search(query='KEYWORD')
  • 按所有者搜索内容:
items = gis.content.search(query='owner:YOUR USERNAME') items = gis.content.search(query='NOT owner:YOUR USERNAME')
  • 在已提供用户名作为参数的情况下,按所有者搜索内容:
username = "YOUR USERNAME" items = gis.content.search(query='owner:'+username) items = gis.content.search(query='owner:{}'.format(username)
  • 搜索登录用户拥有的要素图层:
items = gis.content.search(query="owner:" + gis.users.me.username)
  • 按标题搜索内容:
items = gis.content.search(query='title:TITLE')
  • 搜索以前缀开头的内容:

items = gis.content.search(query='title:TITLE*')
  • 按项目类型搜索内容
items = gis.content.search(query='', item_type='Feature Service') items = gis.content.search(query='', item_type='Web Map') items = gis.content.search(query='', item_type='Web Mapping Application')
  • 以下查询将同时返回 Web 地图和 Web 制图应用程序
items = gis.content.search(query='', item_type='Map')
  • 在组织外搜索内容(查询不能为空)
items = gis.content.search(query='title:TITLE', outside_org=True)
  • 合并查询参数
items = gis.content.search(query='title:TITLE, owner:YOUR USERNAME', item_type='Feature Layer') items = gis.content.search(query='title:TITLE, type:map, owner:YOUR USERNAME')

文章 ID:000024383

从 ArcGIS 专家处获得帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项

相关信息

发现关于本主题的更多内容