可视化查询结果
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
分析和商业智能工具对于帮助您发现 BigQuery 数据中的数据洞见至关重要。BigQuery 支持多种 Google 和第三方数据可视化工具,您可以使用这些工具来分析地点洞察数据查询结果,包括:
- Looker Studio
- BigQuery Geo Viz
- Colab 笔记本
- Google Earth Engine
以下示例介绍了如何在以下平台中直观呈现结果:
- Looker Studio,一个可让您构建和使用数据可视化、信息中心和报告的平台。
- BigQuery Geo Viz 是一种使用 Google Maps API 直观呈现 BigQuery 中的地理空间数据的工具。
如需详细了解如何使用其他工具直观呈现数据,请参阅 BigQuery 文档。
查询要直观呈现的数据
以下可视化图表示例使用以下查询来生成纽约市设有轮椅无障碍入口的餐厅数量。
此查询会返回一个表格,其中包含每个地理点的餐厅数量,每个点的大小为 0.005 度。
由于您无法对 GEOGRAPHY
点执行 GROUP BY
操作,因此此查询使用 BigQuery ST_ASTEXT
函数将每个点转换为该点的 STRING
WKT 表示形式,并将该值写入 geo_txt
列。然后,使用 geo_txt
执行 GROUP BY
。
SELECT
geo_txt, -- STRING WKT geometry value.
ST_GEOGFROMTEXT(geo_txt) AS geo, -- Convert STRING to GEOGRAPHY value.
count
FROM (
-- Create STRING WKT representation of each GEOGRAPHY point to
-- GROUP BY the STRING value.
SELECT WITH AGGREGATION_THRESHOLD
ST_ASTEXT(ST_SNAPTOGRID(point, 0.005)) AS geo_txt,
COUNT(*) AS count
FROM
`places_insights___us___sample.places_sample`
WHERE
'restaurant' IN UNNEST(types)
AND wheelchair_accessible_entrance = true
GROUP BY
geo_txt
)
下图显示了此查询的输出示例,其中 count
包含每个点的餐厅数量:

使用 Looker Studio 直观呈现数据
下图显示了以热力图形式在 Looker 数据洞察中呈现的这些数据。热力图显示了从低(绿色)到高(红色)的密度。

将数据导入 Looker Studio
如需将数据导入 Looker Studio,请执行以下操作:
在查询数据以直观呈现中运行上述查询。
在 BigQuery 结果中,依次点击打开方式 -> Looker Studio。您的结果会自动导入 Looker Studio。
Looker Studio 会创建一个默认报告页面,并使用结果的标题、表格和条形图对其进行初始化。

选择网页上的全部内容,然后将其删除。
点击插入 -> 热图,将热图添加到报告中。
在图表类型 -> 设置下,按如下所示配置字段:

热图如上所示。您可以选择图表类型 -> 样式,进一步配置地图的外观。
使用 BigQuery Geo Viz 直观呈现数据
以下图片显示了在 BigQuery Geo Viz 中以填充地图形式显示的此数据。填充地图按点状单元格显示餐厅密度,其中点越大,密度越高。

将数据导入 BigQuery Geo Viz
如需将数据导入 BigQuery Geo Viz,请执行以下操作:
在查询数据以直观呈现中运行上述查询。
在 BigQuery 结果中,依次点击打开方式 -> GeoViz。
显示屏会打开并显示查询步骤。
选择运行按钮以运行查询。地图会自动显示地图上的点。
选择数据以查看数据。
在数据部分,点击添加样式按钮。
选择 fillColor,然后使用滑块启用以数据为依据的样式设置。
按如下所示设置其余字段:

点击应用样式,将样式应用到地图。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-17。
[null,null,["最后更新时间 (UTC):2025-07-17。"],[],[],null,["Analysis and [business intelligence\ntools](https://cloud.google.com/bigquery/docs/data-analysis-tools-intro) are\ncrucial to helping you discover insights from your BigQuery data. BigQuery\nsupports several Google and third-party [data visualization\ntools](https://cloud.google.com/bigquery/docs/geospatial-visualize) that you can\nuse to analyze the results of your queries on Places Insights data, including:\n\n- Looker Studio\n- BigQuery Geo Viz\n- Colab notebooks\n- Google Earth Engine\n\nThe example below describes how to visualize your results in:\n\n- Looker Studio, a platform that lets you build and consume data visualizations, dashboards, and reports.\n- BigQuery Geo Viz, a geospatial data visualization tool in BigQuery using Google Maps APIs.\n\nSee the [BigQuery\ndocumentation](https://cloud.google.com/bigquery/docs/geospatial-visualize) for\nmore information on visualizing your data using other tools.\n\nQuery data to visualize\n\nThe visualization examples below use the following query to generate a count of\nrestaurants in New York City with a wheelchair accessible entrance.\nThis query returns a table of restaurant\ncounts per geographical *point* where the size of each point is 0.005 degrees.\n\nBecause you cannot perform a `GROUP BY` operation on a `GEOGRAPHY` point, this\nquery uses the BigQuery\n[`ST_ASTEXT`](https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_astext)\nfunction to convert each point into the `STRING`\n[WKT](https://en.wikipedia.org/wiki/Well-known_text) representation of the\npoint, and writes that value to the `geo_txt` column. It then performs the\n`GROUP BY` using `geo_txt`. \n\n```googlesql\nSELECT\n geo_txt, -- STRING WKT geometry value.\n ST_GEOGFROMTEXT(geo_txt) AS geo, -- Convert STRING to GEOGRAPHY value.\n count\nFROM (\n -- Create STRING WKT representation of each GEOGRAPHY point to\n -- GROUP BY the STRING value.\n SELECT WITH AGGREGATION_THRESHOLD\n ST_ASTEXT(ST_SNAPTOGRID(point, 0.005)) AS geo_txt,\n COUNT(*) AS count\n FROM\n `places_insights___us___sample.places_sample`\n WHERE\n 'restaurant' IN UNNEST(types)\n AND wheelchair_accessible_entrance = true\n GROUP BY\n geo_txt\n)\n```\n\nThe following image shows an example output to this query where `count`\ncontains the number of restaurants for each point:\n\nVisualize data using Looker Studio\n\nThe following images show this data displayed in Looker Studio as a heatmap. The\nheatmap shows density from low (green) to high (red).\n\nImport your data into Looker Studio\n\nTo import your data into Looker Studio:\n\n1. Run the query above in [Query data to visualize](#query_data_to_visualize).\n\n2. In the BigQuery results, click **Open in -\\\u003e Looker Studio**. Your results\n are automatically imported into Looker Studio.\n\n3. Looker Studio creates a default report page and initializes it with a title,\n table, and bar graph of the results.\n\n4. Select everything on the page and delete it.\n\n5. Click **Insert -\\\u003e Heatmap** to add a heatmap to your report.\n\n6. Under **Chart types -\\\u003e Setup** configure the fields as shown below::\n\n7. The heatmap appears as above. You can optionally select **Chart types -\\\u003e\n Styles** to further configure the appearance of the map.\n\nVisualize data using BigQuery Geo Viz\n\nThe following images show this data displayed in BigQuery Geo Viz as a filled\nmap. The filled map shows the restaurant density by point cell, where the larger\nthe point corresponds to the higher density.\n\nImport your data into BigQuery Geo Viz\n\nTo import your data into BigQuery Geo Viz:\n\n1. Run the query above in [Query data to visualize](#query_data_to_visualize).\n\n2. In the BigQuery results, click **Open in -\\\u003e GeoViz**.\n\n3. The display opens to the **Query** step.\n\n4. Select the **Run** button to run the query. The map automatically shows\n the points on the map.\n\n5. Select **Data** to view the data.\n\n6. In the **Data** section, click the **Add styles** button.\n\n7. Select **fillColor** and then use the slider to enable **Data-driven**\n styling.\n\n8. Set the remaining fields as shown below:\n\n9. Click **Apply Style** to apply the styles to the map."]]