是否可以根据ArcGIS Javascipt API中的CSVLayer的属性获取具有certian属性的项目数? [英] Is it possible to fetch the number of items with a certian property against the propery from a CSVLayer in ArcGIS Javascipt API?

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

问题描述

是否可以从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?

这是 csv文件.

我的意图是

  • 类别0 -1
  • 类别1 -0
  • 类别2 -1
  • 类别3 -0
  • 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?

推荐答案

您可以使用 CSVLayer SceneView ,以下代码计算了Category = 0Category = 2:

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);

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

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:

  • API documentation for Query
  • Query statistics by geometry (uses pie charts)
  • Client-side filtering of displayed features

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

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