使用BigQuery Geo Viz可视化多边形及其质心

问题描述 投票:1回答:2

使用BigQuery Geo Viz,

我正在尝试在同一张地图上同时可视化多边形及其质心点。

我尝试了ST_UNION函数,但无法真正将两个GEOGRAPHY结合起来。

关于如何可视化两个地理的任何想法。

Polygon:
POLYGON((-95.7082555 29.9212101, -95.665885 29.907145, -95.7742806214083 29.82947355, -95.7303605 29.8538605, -95.659484 29.901497, -95.662932 29.894958, -95.8441482 29.7265376, -95.646749 29.905534, -95.810012 29.719363, -95.664174 29.883618, -95.639718 29.910045, -95.652796 29.89204, -95.649915 29.886317, -95.650089 29.881912, -95.641443 29.897741, -95.632912 29.911674, -95.653458 29.864561, -95.635056 29.864431, -95.636533 29.757219, -95.623339 29.903466, -95.597235 29.75367, -95.3636989932886 29.8063167449664, -95.575123 29.920295, -95.3944858832763 29.94248964622, -95.147033 30.013214, -95.586588 29.947706, -95.456723 31.3287239, -95.69717 29.96911, -95.674433 29.943844, -95.678203 29.935184, -95.7082555 29.9212101))

Centroid point:
POINT(-95.5606651932764 30.2307053050834)
google-bigquery gis geo
2个回答
2
投票

[尝试分别选择两个结构,并使用UNION ALL在相同的可视化图中收集它们:

SELECT ST_GeogFromText('POLYGON((-95.7082555 29.9212101, -95.665885 29.907145, -95.7742806214083 29.82947355, -95.7303605 29.8538605, -95.659484 29.901497, -95.662932 29.894958, -95.8441482 29.7265376, -95.646749 29.905534, -95.810012 29.719363, -95.664174 29.883618, -95.639718 29.910045, -95.652796 29.89204, -95.649915 29.886317, -95.650089 29.881912, -95.641443 29.897741, -95.632912 29.911674, -95.653458 29.864561, -95.635056 29.864431, -95.636533 29.757219, -95.623339 29.903466, -95.597235 29.75367, -95.3636989932886 29.8063167449664, -95.575123 29.920295, -95.3944858832763 29.94248964622, -95.147033 30.013214, -95.586588 29.947706, -95.456723 31.3287239, -95.69717 29.96911, -95.674433 29.943844, -95.678203 29.935184, -95.7082555 29.9212101))') t UNION ALL SELECT ST_GeogFromText('POINT(-95.5606651932764 30.2307053050834)') t

如果您打算在相同的可视化中显示几何图形和点,那么它将在下图中显示:

enter image description here

请让我知道这是否是您想要的


1
投票

在简单情况下,您提出的问题是在简单解决方案下只有一个多边形及其质心的问题

#standardSQL
WITH objects AS (
  SELECT 'POLYGON((-95.7082555 29.9212101, -95.665885 29.907145, -95.7742806214083 29.82947355, -95.7303605 29.8538605, -95.659484 29.901497, -95.662932 29.894958, -95.8441482 29.7265376, -95.646749 29.905534, -95.810012 29.719363, -95.664174 29.883618, -95.639718 29.910045, -95.652796 29.89204, -95.649915 29.886317, -95.650089 29.881912, -95.641443 29.897741, -95.632912 29.911674, -95.653458 29.864561, -95.635056 29.864431, -95.636533 29.757219, -95.623339 29.903466, -95.597235 29.75367, -95.3636989932886 29.8063167449664, -95.575123 29.920295, -95.3944858832763 29.94248964622, -95.147033 30.013214, -95.586588 29.947706, -95.456723 31.3287239, -95.69717 29.96911, -95.674433 29.943844, -95.678203 29.935184, -95.7082555 29.9212101))' wkt_string UNION ALL
  SELECT 'POINT(-95.5606651932764 30.2307053050834)'
)
SELECT ST_GEOGFROMTEXT(wkt_string) geo
FROM objects    

并且可以使用其他工具将其可视化-如下面的示例所示

enter image description here

对于更现实的情况,当您有许多多边形并需要对其质心进行可视化时,您可以使用以下方法(基于美国各州的示例)

#standardSQL
SELECT state_geom state, ST_CENTROID(state_geom) centroid
FROM `bigquery-public-data.utility_us.us_states_area`

结果如下

enter image description here

可以在下面的示例中看到(仅显示几个状态来了解一个想法)

enter image description here

enter image description here

enter image description here

最后,您可以在下面很好的可视化中将所有这些多边形(此示例中的状态)及其质心组合在一起,如下所示:>

enter image description here

[您可以做的另一件事(有许多无尽的选择)是向查询添加一些指标和更多属性-例如state_name和area_land_meters并通过可视化的工具提示来驱动可视化数据,如下面的示例所示

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.