是否可以从 ArcGIS Javascript API 中的 CSVLayer 获取具有特定属性的项目数量? [英] Is it possible to fetch the number of items with a certain property against the property from a CSVLayer in ArcGIS Javascript API?

查看:23
本文介绍了是否可以从 ArcGIS Javascript API 中的 CSVLayer 获取具有特定属性的项目数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从 ArcGIS Javascript API 中的 CSVLayer 获取具有特定属性的项目数量?

这是

我的目的是

如果我们显示类别"中的图例属性和所有文档都在视图中.

也可以根据相同的属性过滤项目吗?

还可以在饼图中显示详细信息吗?

您可以使用 客户端查询 以检索有关可见数据的信息.使用 CSVLayerSceneView,下面的代码统计了Category = 0Category = 2 的特征:

查看.whenLayerView(csvLayer).then(函数(csvLayerView){//创建查询var 查询 = csvLayerView.createQuery();query.outStatistics = [{onStatisticField: "CASE WHEN Category = 0 THEN 1 ELSE 0 END",outStatisticFieldName: "Category0Sum",统计类型:总和"}, {onStatisticField: "CASE WHEN Category = 2 THEN 1 ELSE 0 END",outStatisticFieldName: "Category2Sum",统计类型:总和"}];返回 csvLayerView.queryFeatures(query);}).then(功能(响应){//打印查询结果console.log("查询结果", response.features[0].attributes);}).catch(console.error);

以下 Codepen 会在视图更改时运行此代码并将新的结果行打印到控制台:https://codepen.io/arnofiva/pen/b835cc7b626965332e802fd3385056e9

要查看其他查询选项或如何将结果显示为饼图,请查看以下资源:

Is it possible to fetch the number of items with a certain property against the property from a CSVLayer in ArcGIS Javascript API?

This is the csv file.

My intent is to

  • Category 0 - 1
  • Category 1 - 0
  • Category 2 - 1
  • Category 3 - 0

If we are showing Legends from the "Category" property and all the documents are in the view.

Also is it possible to filter the items based on the same property?

Also is it possible to show the details in a Pie Chart?

解决方案

You can use client side queries to retrieve information about the visible data. Using the CSVLayer and SceneView in the Codepen, the following code counts the number of features where Category = 0 or Category = 2:

view
  .whenLayerView(csvLayer)
  .then(function(csvLayerView) {

    // Create query
    var query = csvLayerView.createQuery();
    query.outStatistics = [{
      onStatisticField: "CASE WHEN Category = 0 THEN 1 ELSE 0 END",
      outStatisticFieldName: "Category0Sum",
      statisticType: "sum"
    }, {
      onStatisticField: "CASE WHEN Category = 2 THEN 1 ELSE 0 END",
      outStatisticFieldName: "Category2Sum",
      statisticType: "sum"
    }];
    return csvLayerView.queryFeatures(query);
  })
  .then(function(response) {

    // Print query results
    console.log("Query results", response.features[0].attributes);
  }).catch(console.error);

The following Codepen runs this code whenever the view changes and prints a new line of results to the console: https://codepen.io/arnofiva/pen/b835cc7b626965332e802fd3385056e9

To see other query options or how to show the results as pie chart, checkout the following resources:

这篇关于是否可以从 ArcGIS Javascript API 中的 CSVLayer 获取具有特定属性的项目数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆