이 페이지의 H3 지리 공간 함수 빠른 시작에서는 다음을 보여 줍니다.
- 지리적 위치 데이터 세트를 Unity 카탈로그에 로드하는 방법입니다.
- 위도 및 경도 열을 H3 셀 열로 변환하는 방법입니다.
- 우편 번호 다각형 또는 다중다각형 WKT 열을 H3 셀 열로 변환하는 방법.
- 라과디아 공항에서 맨해튼의 금융 지구로 픽업 및 하차 분석을 쿼리하는 방법.
- 맵에서 H3 집계 수를 렌더링하는 방법입니다.
Notebook 및 쿼리 예제
Unity 카탈로그 데이터 준비
이 Notebook에서 다음을 수행합니다.
- Databricks Filesystem에서 공용 택시 데이터 세트를 설정합니다.
- NYC 우편 번호 데이터 세트를 설정합니다.
Unity 카탈로그 데이터 준비
노트북 가져오기
Databricks Runtime 11.3 LTS 이상을 사용하는 Databricks SQL 쿼리
쿼리 1: 기본 데이터가 설정되었는지 확인합니다. Notebook을 참조하세요.
use catalog geospatial_docs;
use database nyc_taxi;
show tables;
-- Verify initial data is setup (see instructions in setup notebook)
-- select format_number(count(*),0) as count from yellow_trip;
-- select * from nyc_zipcode;
쿼리 2: H3 NYC 우편 번호 - 해상도 에 12
을 적용합니다.
use catalog geospatial_docs;
use database nyc_taxi;
-- drop table if exists nyc_zipcode_h3_12;
create table if not exists nyc_zipcode_h3_12 as (
select
explode(h3_polyfillash3(geom_wkt, 12)) as cell,
zipcode,
po_name,
county
from
nyc_zipcode
);
-- optional: zorder by `cell`
optimize nyc_zipcode_h3_12 zorder by (cell);
select
*
from
nyc_zipcode_h3_12;
쿼리 3: H3 Taxi Trips - 해상도 에 12
을 적용합니다.
use catalog geospatial_docs;
use database nyc_taxi;
-- drop table if exists yellow_trip_h3_12;
create table if not exists yellow_trip_h3_12 as (
select
h3_longlatash3(pickup_longitude, pickup_latitude, 12) as pickup_cell,
h3_longlatash3(dropoff_longitude, dropoff_latitude, 12) as dropoff_cell,
*
except
(
rate_code_id,
store_and_fwd_flag
)
from
yellow_trip
);
-- optional: zorder by `pickup_cell`
-- optimize yellow_trip_h3_12 zorder by (pickup_cell);
select
*
from
yellow_trip_h3_12
where pickup_cell is not null;
쿼리 4: H3 LGA 픽업 - 라과디아(LGA)에서 25M 픽업
use catalog geospatial_docs;
use database nyc_taxi;
create
or replace view lga_pickup_h3_12 as (
select
t.*
except(cell),
s.*
from
yellow_trip_h3_12 as s
inner join nyc_zipcode_h3_12 as t on s.pickup_cell = t.cell
where
t.zipcode = '11371'
);
select
format_number(count(*), 0) as count
from
lga_pickup_h3_12;
-- select
-- *
-- from
-- lga_pickup_h3_12;
쿼리 5: H3 금융 지구 하차 - 금융 지구의 총 하차 34M
use catalog geospatial_docs;
use database nyc_taxi;
create
or replace view fd_dropoff_h3_12 as (
select
t.*
except(cell),
s.*
from
yellow_trip_h3_12 as s
inner join nyc_zipcode_h3_12 as t on s.dropoff_cell = t.cell
where
t.zipcode in ('10004', '10005', '10006', '10007', '10038')
);
select
format_number(count(*), 0) as count
from
fd_dropoff_h3_12;
-- select * from fd_dropoff_h3_12;
쿼리 6: H3 LGA-FD - FD에서 827K 하차(LGA에서 픽업 포함)
use catalog geospatial_docs;
use database nyc_taxi;
create
or replace view lga_fd_dropoff_h3_12 as (
select
*
from
fd_dropoff_h3_12
where
pickup_cell in (
select
distinct pickup_cell
from
lga_pickup_h3_12
)
);
select
format_number(count(*), 0) as count
from
lga_fd_dropoff_h3_12;
-- select * from lga_fd_dropoff_h3_12;
쿼리 7: 우편 번호별 LGA-FD - 우편 번호 + 가로 막대형 차트별 FD 하차 수
use catalog geospatial_docs;
use database nyc_taxi;
select
zipcode,
count(*) as count
from
lga_fd_dropoff_h3_12
group by
zipcode
order by
zipcode;
쿼리 8: H3별 LGA-FD - H3 셀 별 FD 드롭 오프 숫자 세기 + 맵 마커 시각화
use catalog geospatial_docs;
use database nyc_taxi;
select
zipcode,
dropoff_cell,
h3_centerasgeojson(dropoff_cell) :coordinates [0] as dropoff_centroid_x,
h3_centerasgeojson(dropoff_cell) :coordinates [1] as dropoff_centroid_y,
format_number(count(*), 0) as count_disp,
count(*) as `count`
from
lga_fd_dropoff_h3_12
group by
zipcode,
dropoff_cell
order by
zipcode,
`count` DESC;
Databricks Runtime 11.3 LTS 이상용 Notebook
빠른 시작-Python: H3 NYC Taxi LaGuardia에서 맨해튼까지
노트북 가져오기
Notebooks + kepler.gl 내에서 Spark Python 바인딩을 사용하는 Databricks SQL과 동일한 빠른 시작 구조입니다.
빠른 시작-Scala: H3 NYC Taxi LaGuardia에서 맨해튼까지
노트북 가져오기
Python을 셀을 통해 Notebooks + kepler.gl 내에서 Spark Scala 바인딩을 사용하는 Databricks SQL과 동일한 빠른 시작 구조입니다.
빠른 시작-SQL: H3 NYC Taxi LaGuardia에서 맨해튼까지
노트북 가져오기
Python을 셀을 통해 Notebooks + kepler.gl 내에서 Spark SQL 바인딩을 사용하는 Databricks SQL과 동일한 빠른 시작 구조입니다.