错误

错误:ArcGIS API for Python GeoEnrichment 错误:国家聚合模式仅支持全球数据集合

Last Published: July 22, 2021

错误消息

ArcGIS Python 函数 enrich_layer(arcgis.features.enrich_data 模块)用于使用以下代码片段来丰富具有人口统计信息的多个点位置:

from arcgis.gis import GIS from arcgis.features.enrich_data import enrich_layer # 连接到 GIS gis = GIS("Pro") # 使用可用于关注的国家/地区的分析变量 analysis_variables = [ "KeyFacts.TOTPOP_CY", "HouseholdTotals.AVGHHSZ_CY", "KeyFacts.PP_CY", "Spending.CS01_CY" ] points = [ {"country": "Australia", "coords": (-33.918199,151.202186)}, {"country": "Belgium", "coords": (51.051012,4.335651)}, {"country": "Netherlands", "coords": (51.848607,4.669177)} ] for point in points: country = point['country'] coords = point['coords'] pt_enrich = enrich_layer( coords, analysis_variables=analysis_variables, distance=30, units='Kilometers', buffer_type='StraightLine', return_boundaries=True, ) print(pt_enrich.layer.featureSet.features[0].attributes)

这在某些国家/地区运行良好,但在其他国家/地区会失败并显示错误消息:

{"messageCode": "AO_100000", "message": "国家聚合模式仅支持全球数据集合。 无法处理以下数据集合:'KeyFacts'、'HouseholdTotals'、'Spending'。"}

根据以下 URL 中的数据浏览器 https://la.arcgis.com/databrowser/index.html,测试中的所有国家/地区(澳大利亚、比利时和荷兰)都应支持这些分析变量。

原因

错误信息国家聚合模式仅支持全球数据集合”表示与输入坐标的缓冲距离生成与多个国家/地区相交的丰富面输入要素,其仅支持全球数据集合,不支持任何分析变量。

根据点坐标所在的位置,输入坐标的 30 公里缓冲区可以与多个国家/地区相交,因此仅在某些情况下会遇到错误。

解决方案或解决方法

此错误有两个可能的解决方法:

在 enrich_layer 方法中设置名为 country 的可选参数,以将每个缓冲输入点的丰富限制为单个国家/地区

from arcgis.gis import GIS from arcgis.features.enrich_data import enrich_layer # 连接到 GIS gis = GIS("Pro") # 使用来自各种集合的分析变量进行测试 analysis_variables = [ "KeyFacts.TOTPOP_CY", "HouseholdTotals.AVGHHSZ_CY", "KeyFacts.PP_CY", "Spending.CS01_CY" ] points = [ {"country": "Australia", "code": "AU", "coords": (-33.918199,151.202186)}, {"country": "Belgium", "code": "BE", "coords": (51.051012,4.335651)}, {"country": "Netherlands", "code": "NL", "coords": (51.848607,4.669177)} ] for point in points: country = point['country'] coords = point['coords'] code = point['code'] pt_enrich = enrich_layer( coords, analysis_variables=analysis_variables, country= code, distance=30, units='Kilometers', buffer_type='StraightLine', return_boundaries=True, ) print(pt_enrich.layer.featureSet.features[0].attributes)

使用 arcgis.geoenrichment 模块可以聚合所有国家/地区的所有 KeyGlobalFacts

from arcgis.gis import GIS from arcgis.geoenrichment import enrich, BufferStudyArea from arcgis.geometry import Point gis = GIS("Pro") points = [] points.append(Point({"x" : 4.335651, "y" : 51.051012, "spatialReference" : {"wkid" : 4326}})) points.append(Point({"x" : 151.202186, "y" : -33.918199, "spatialReference" : {"wkid" : 4326}})) points.append(Point({"x" : 4.669177, "y" : 51.848607, "spatialReference" : {"wkid" : 4326}})) points.append(Point({"x" : 114.125105, "y" : 22.343511, "spatialReference" : {"wkid" : 4326}})) for pt in points: buffered = BufferStudyArea(area= pt, radii=[30], units='Kilometers', overlap=False) enriched = enrich( study_areas=[buffered], data_collections=['KeyGlobalFacts'], ) print(enriched)

文章 ID:000025443

从 ArcGIS 专家处获得帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项

相关信息

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