Cloud OnAir: Add rich geospatial analysis to your toolbox with BigQuery GIS

Cloud OnAir: Add rich geospatial analysis to your toolbox with BigQuery GIS

Google Cloud Tech

5 лет назад

1,846 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@ekaterinakuzmina4932
@ekaterinakuzmina4932 - 17.09.2019 17:15

Hi, I tried to reproduce your code with NY center coordinates. The code worked perfectly fine in the BigQuery and gave me an expected table with POLYGONs, however when I copied the code to BigQuery GIS Vis I got the "Expected a geography column, but found none" error and no images. Can you please help me to understand what was wrong? The script is below:

with
params AS
(
SELECT
-74.0060 as lon,
40.7128 as lat,
15 as radius -- in miles
),


zipcodes_within_distance as (
SELECT
zipcode
FROM
`bigquery-public-data.utility_us.zipcode_area` as zip_area,
params
WHERE
ST_DWithin(ST_GeogPoint(params.lon, params.lat), ST_GeogPoint(zip_area.longitude, zip_area.latitude), 1609*params.radius)
),


state_by_zipcode as (
SELECT
zipcode ,
sum(if(gender = '' and minimum_age is null and maximum_age is null, population, 0)) as total,
sum(if(gender = 'female' and minimum_age is null and maximum_age is null, population, 0)) as total_female,
sum(if(gender = 'male' and minimum_age is null and maximum_age is null, population, 0)) as total_male,
sum(if(maximum_age <= 24, population, 0)) as population_0_24,
sum(if(minimum_age >= 25 and maximum_age <= 44, population, 0)) as population_25_44,
sum(if(minimum_age >= 45 and maximum_age <= 64, population, 0)) as population_45_64,
sum(if(minimum_age >= 65, population, 0)) as population_65_plus
FROM `bigquery-public-data.census_bureau_usa.population_by_zip_2010` AS zip_census
WHERE
zipcode IN (SELECT zipcode FROM zipcodes_within_distance)
GROUP BY zipcode
)


SELECT s.*, z.zipcode_geom
FROM state_by_zipcode s
JOIN `bigquery-public-data.utility_us.zipcode_area` z
ON s.zipcode = z.zipcode

Ответить