Bigquery GIS,如何使用 Openstreetmap 数据集对每个国家/地区的坐标进行分组
Bigquery GIS , how to group coordinates per country using Openstreetmap dataset
我正在 Bigquery 中使用 openstreetmap 数据集,我查询了 return 一个像这样的列表
这是我正在使用的查询
SELECT
ar.key,
ar.value,
osm_id,
osm_way_id,
ST_CENTROID(geometry) AS center_location
FROM
`bigquery-public-data.geo_openstreetmap.planet_features`,
UNNEST(all_tags) AS ar
WHERE
('amenity') in (
SELECT
(key)
FROM
UNNEST(all_tags))
or
(('suburb') in (
SELECT
(value)
FROM
UNNEST(all_tags)) or
('city') in (
SELECT
(value)
FROM
UNNEST(all_tags))
or ('town') in (
SELECT
(value)
FROM
UNNEST(all_tags))
or ('village') in (
SELECT
(value)
FROM
UNNEST(all_tags)))
我的问题是假设我有另一个 table 国家/地区,几何形状为多边形
我如何将字段中心位置连接到 return 名称国家(如果该点在多边形内,则它属于一个国家)
let's say I have another table with Country, geometry as a polygon
how I join the field center location to return the name country ( if the point is inside a polygon, then it belong to a country)
空间连接是两个表的连接,在 WHERE 子句中具有谓词地理函数。例如:
-- how many stations within 1 mile range of each zip code?
SELECT
zip_code AS zip,
ANY_VALUE(zip_code_geom) AS polygon,
COUNT(*) AS bike_stations
FROM
`bigquery-public-data.new_york.citibike_stations` AS bike_stations,
`bigquery-public-data.geo_us_boundaries.zip_codes` AS zip_codes
WHERE ST_DWithin(
zip_codes.zip_code_geom,
ST_GeogPoint(bike_stations.longitude, bike_stations.latitude),
1609.34)
GROUP BY zip
ORDER BY bike_stations DESC
你可以在这里看到更多 - Using JOINs with spatial data
我正在 Bigquery 中使用 openstreetmap 数据集,我查询了 return 一个像这样的列表
这是我正在使用的查询
SELECT
ar.key,
ar.value,
osm_id,
osm_way_id,
ST_CENTROID(geometry) AS center_location
FROM
`bigquery-public-data.geo_openstreetmap.planet_features`,
UNNEST(all_tags) AS ar
WHERE
('amenity') in (
SELECT
(key)
FROM
UNNEST(all_tags))
or
(('suburb') in (
SELECT
(value)
FROM
UNNEST(all_tags)) or
('city') in (
SELECT
(value)
FROM
UNNEST(all_tags))
or ('town') in (
SELECT
(value)
FROM
UNNEST(all_tags))
or ('village') in (
SELECT
(value)
FROM
UNNEST(all_tags)))
我的问题是假设我有另一个 table 国家/地区,几何形状为多边形
我如何将字段中心位置连接到 return 名称国家(如果该点在多边形内,则它属于一个国家)
let's say I have another table with Country, geometry as a polygon how I join the field center location to return the name country ( if the point is inside a polygon, then it belong to a country)
空间连接是两个表的连接,在 WHERE 子句中具有谓词地理函数。例如:
-- how many stations within 1 mile range of each zip code?
SELECT
zip_code AS zip,
ANY_VALUE(zip_code_geom) AS polygon,
COUNT(*) AS bike_stations
FROM
`bigquery-public-data.new_york.citibike_stations` AS bike_stations,
`bigquery-public-data.geo_us_boundaries.zip_codes` AS zip_codes
WHERE ST_DWithin(
zip_codes.zip_code_geom,
ST_GeogPoint(bike_stations.longitude, bike_stations.latitude),
1609.34)
GROUP BY zip
ORDER BY bike_stations DESC
你可以在这里看到更多 - Using JOINs with spatial data