Membuat kueri set data publik dan memvisualisasikan hasilnya
Pelajari cara membuat kueri set data publik dan memvisualisasikan hasilnya di BigQuery.
Untuk mengikuti panduan langkah demi langkah tugas ini langsung di Google Cloud konsol, klik Pandu saya:
Sebelum memulai
- 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.
Buka IAM - Pilih project.
- Klik Grant access.
-
Di kolom New principals, masukkan ID pengguna Anda. Biasanya berupa alamat email untuk Akun Google.
- Di daftar Select a role, pilih peran.
- Untuk memberikan peran tambahan, klik Tambahkan peran lain, lalu tambahkan setiap peran tambahan.
- Klik Simpan.
-
-
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.
Buka IAM - Pilih project.
- Klik Grant access.
-
Di kolom New principals, masukkan ID pengguna Anda. Biasanya berupa alamat email untuk Akun Google.
- Di daftar Select a role, pilih peran.
- Untuk memberikan peran tambahan, klik Tambahkan peran lain, lalu tambahkan setiap peran tambahan.
- Klik Simpan.
-
-
Verify that billing is enabled for your Google Cloud project.
Pastikan BigQuery API diaktifkan.
Jika Anda membuat project baru, BigQuery API akan otomatis diaktifkan.
Di konsol Google Cloud , buka halaman BigQuery.
Di BigQuery Studio, di panel Penjelajah, klik
Tambahkan data.Dalam dialog Tambahkan data, di panel Filter Menurut, klik
Set data publik.
Di halaman Marketplace, di kolom Search Marketplace, ketik
NYC Citi Bike Trips
untuk mempersempit penelusuran Anda.Di hasil penelusuran, klik NYC Citi Bike Trips.
Di halaman Detail produk, klik Lihat set data. Anda dapat melihat informasi tentang set data di tab Detail.
Di konsol Google Cloud , buka halaman BigQuery.
Klik
SQL query .Di
query editor , masukkan kueri berikut: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;
Jika kueri valid, tanda centang akan muncul bersama dengan jumlah data yang diproses kueri. Jika kueri tidak valid, tanda seru akan muncul bersama dengan pesan error.
Klik
Jalankan . Stasiun paling populer tercantum di bagianHasil kueri .Opsional: Untuk menampilkan durasi tugas dan jumlah data yang diproses tugas kueri, klik tab Informasi tugas di bagian Hasil kueri.
Beralihlah ke tab
Visualisasi . Tab ini membuat peta untuk memvisualisasikan hasil Anda dengan cepat.Di panel Konfigurasi visualisasi:
- Pastikan Jenis visualisasi disetel ke Peta.
- Pastikan Kolom geografi disetel ke
geo_location
. - Untuk Kolom data, pilih
num_trips
. - Gunakan opsi Perbesar untuk menampilkan peta Manhattan.
- 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.
- Pelajari sandbox BigQuery.
- Pelajari cara membuat set data, memuat data, dan mengkueri tabel di BigQuery.
Jika Anda tidak mengaktifkan penagihan untuk Google Cloud project yang digunakan dalam tutorial ini, Anda harus membuat kueri data publik di sandbox BigQuery. Sandbox BigQuery memungkinkan Anda mempelajari BigQuery dengan sekumpulan fitur BigQuery terbatas tanpa biaya.
Melihat set data publik
Set data publik BigQuery tersedia secara default di BigQuery Studio dalam project bernama bigquery-public-data
. Dalam
tutorial ini, Anda akan membuat kueri set data Perjalanan NYC Citi Bike. Citi Bike adalah program berbagi sepeda besar, dengan 10.000 sepeda dan 600 stasiun di Manhattan, Brooklyn, Queens, dan Jersey City. Set data ini mencakup perjalanan Citi Bike sejak Citi Bike diluncurkan pada September 2013.
Mengkueri set data publik
Pada langkah-langkah berikut, Anda akan membuat kueri tabel citibike_trips
untuk menentukan
100 stasiun Citi Bike paling populer dalam set data publik Perjalanan NYC Citi Bike.
Kueri mengambil nama dan lokasi stasiun, serta jumlah perjalanan yang dimulai di stasiun tersebut.
Kueri menggunakan fungsi ST_GEOGPOINT
untuk membuat titik dari parameter bujur dan lintang setiap stasiun dan
menampilkan titik tersebut dalam kolom GEOGRAPHY
. Kolom GEOGRAPHY
digunakan untuk
membuat peta panas di penampil data geografi terintegrasi.
Pembersihan
Agar akun Google Cloud Anda tidak dikenai biaya untuk resource yang digunakan pada halaman ini, ikuti langkah-langkah berikut.
Menghapus project
Jika Anda menggunakan sandbox BigQuery untuk mengkueri set data publik, penagihan tidak akan diaktifkan untuk project Anda, dan Anda tidak perlu menghapus project.
Cara termudah untuk menghilangkan penagihan adalah dengan menghapus project yang Anda buat untuk tutorial.
Untuk menghapus project: