공개 데이터 세트 쿼리 및 결과 시각화
BigQuery에서 공개 데이터 세트를 쿼리하고 결과를 시각화하는 방법을 알아봅니다.
Google Cloud 콘솔에서 이 태스크에 대한 단계별 안내를 직접 수행하려면 둘러보기를 클릭합니다.
시작하기 전에
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Make sure that you have the following role or roles on the project: BigQuery Job User, Service Usage Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
IAM으로 이동 - 프로젝트를 선택합니다.
- 액세스 권한 부여를 클릭합니다.
-
새 주 구성원 필드에 사용자 식별자를 입력합니다. 일반적으로 Google 계정의 이메일 주소입니다.
- 역할 선택 목록에서 역할을 선택합니다.
- 역할을 추가로 부여하려면 다른 역할 추가를 클릭하고 각 역할을 추가합니다.
- 저장을 클릭합니다.
-
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Make sure that you have the following role or roles on the project: BigQuery Job User, Service Usage Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
IAM으로 이동 - 프로젝트를 선택합니다.
- 액세스 권한 부여를 클릭합니다.
-
새 주 구성원 필드에 사용자 식별자를 입력합니다. 일반적으로 Google 계정의 이메일 주소입니다.
- 역할 선택 목록에서 역할을 선택합니다.
- 역할을 추가로 부여하려면 다른 역할 추가를 클릭하고 각 역할을 추가합니다.
- 저장을 클릭합니다.
-
-
Verify that billing is enabled for your Google Cloud project.
BigQuery API가 사용 설정되었는지 확인
새 프로젝트를 만들면 BigQuery API가 자동으로 사용 설정됩니다.
Google Cloud 콘솔에서 BigQuery 페이지로 이동합니다.
BigQuery 스튜디오의 탐색기 창에서
데이터 추가를 클릭합니다.데이터 추가 대화상자의 필터링 기준 창에서
공개 데이터 세트를 클릭합니다.
Marketplace 페이지의 Marketplace 검색 필드에
NYC Citi Bike Trips
를 입력하여 검색 범위를 좁힙니다.검색 결과에서 NYC Citi Bike Trips를 클릭합니다.
제품 세부정보 페이지에서 데이터 세트 보기를 클릭합니다. 세부정보 탭에서 데이터 세트에 관한 정보를 확인할 수 있습니다.
Google Cloud 콘솔에서 BigQuery 페이지를 엽니다.
SQL 쿼리 를 클릭합니다.쿼리 편집기 에서 다음 쿼리를 입력합니다.SELECT start_station_name, start_station_latitude, start_station_longitude, ST_GEOGPOINT(start_station_longitude, start_station_latitude) AS geo_location, COUNT(*) AS num_trips FROM `bigquery-public-data.new_york.citibike_trips` GROUP BY 1, 2, 3 ORDER BY num_trips DESC LIMIT 100;
쿼리가 유효하면 쿼리에서 처리할 데이터양과 함께 체크표시가 나타납니다. 쿼리가 유효하지 않으면 느낌표가 오류 메시지와 함께 표시됩니다.
실행 을 클릭합니다. 가장 인기 있는 방송국은쿼리 결과 섹션에 표시됩니다.선택사항: 작업 기간과 쿼리 작업에서 처리한 데이터 양을 표시하려면 쿼리 결과 섹션에서 작업 정보 탭을 클릭합니다.
시각화 탭으로 전환합니다. 이 탭은 결과를 빠르게 시각화할 수 있는 지도를 생성합니다.시각화 구성 패널에서 다음을 수행합니다.
- 시각화 유형이 지도로 설정되어 있는지 확인합니다.
- 지역 열이
geo_location
로 설정되어 있는지 확인합니다. - 데이터 열에서
num_trips
을 선택합니다. - 확대 옵션을 사용하여 맨해튼 지도를 표시합니다.
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
- BigQuery 샌드박스 알아보기
- BigQuery에서 데이터 세트를 만들고, 데이터를 로드하고, 테이블을 쿼리하는 방법을 알아봅니다.
이 튜토리얼에서 사용하는 Google Cloud 프로젝트에 결제를 사용 설정하지 않으면 BigQuery 샌드박스에서 공개 데이터를 쿼리합니다. BigQuery 샌드박스를 사용하면 제한된 BigQuery 기능 세트로 BigQuery를 무료로 학습할 수 있습니다.
공개 데이터 세트 보기
BigQuery 공개 데이터 세트는 기본적으로 bigquery-public-data
라는 프로젝트의 BigQuery Studio에서 사용할 수 있습니다. 이 튜토리얼에서는 NYC Citi Bike 운행 데이터 세트를 쿼리합니다. Citi Bike는 맨해튼, 브루클린, 퀸즈, 저지시티에 자전거 10,000대와 600개의 정차장을 보유한 대규모 자전거 공유 프로그램입니다. 이 데이터 세트에는 2013년 9월 Citi Bike가 설립된 이후의 Citi Bike 운행 정보가 포함되어 있습니다.
공개 데이터 세트 쿼리
다음 단계에서는 citibike_trips
테이블을 쿼리하여 NYC Citi Bike Trips 공개 데이터 세트에서 가장 인기 있는 Citi Bike 정거장 100개를 확인합니다.
이 쿼리는 역의 이름과 위치, 해당 역에서 시작된 이동 수를 가져옵니다.
이 쿼리는 ST_GEOGPOINT 함수를 사용하여 각 대여소의 경도 및 위도 매개변수에서 점을 만들고 GEOGRAPHY
열에 해당 점을 반환합니다. GEOGRAPHY
열은 통합된 지리 데이터 뷰어에서 히트맵을 생성하는 데 사용됩니다.
삭제
이 페이지에서 사용한 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 다음 단계를 수행합니다.
프로젝트 삭제
BigQuery 샌드박스를 사용하여 공개 데이터 세트를 쿼리한 경우에는 프로젝트에 결제가 사용 설정되지 않으므로 프로젝트를 삭제하지 않아도 됩니다.
비용이 청구되지 않도록 하는 가장 쉬운 방법은 튜토리얼에서 만든 프로젝트를 삭제하는 것입니다.
프로젝트를 삭제하는 방법은 다음과 같습니다.