Loading geographical data

First of all, we need to change our script so that we can extract the coordinates (latitude and longitude) from each vehicular collision that happened in New York according to the dataset. The Google BigQuery dataset provides the latitude and longitude values for each collision, so we're going to use them in our SQL. Qlik Sense provides a function called GeoMakePoint(), which consolidates a pair of latitude and longitude values in a single field (a geometry), making the data model more compact. 

Please refer to Chapter 11Data Forecasting Using Advanced Analytics, and On-demand App Generation (ODAG) on how to connect and use a BigQuery table, as follows:

LIB CONNECT TO 'Google_BigQuery';
// We have to make a small adjustment, since GeoAnalytics recognizes Brooklyn as Kings County
Borough:
mapping load * Inline [
From, To
BROOKLYN, KINGS
];
MAP borough USING Borough;
Collisions:
Load
collision_date,
borough,
latitude,
longitude,
zip_code,
contributing_factor_vehicle_1,
number_of_cyclist_injured,
number_of_cyclist_killed,
number_of_motorist_injured,
number_of_motorist_killed,
number_of_persons_killed,
number_of_persons_injured,
unique_key,
vehicle_type_code1,
vehicle_type_code2,
GeoMakePoint(latitude,longitude) as collision_point;
SELECT DATETIME_TRUNC(TIMESTAMP, DAY) AS collision_date,
borough,
latitude,
longitude,
zip_code,
contributing_factor_vehicle_1,
number_of_cyclist_injured,
number_of_cyclist_killed,
number_of_motorist_injured,
number_of_motorist_killed,
number_of_persons_killed,
number_of_persons_injured,
unique_key,
vehicle_type_code1,
vehicle_type_code2
FROM `bigquery-public-data.new_york_mv_collisions.nypd_mv_collisions`
WHERE NOT LOCATION IS NULL AND LENGTH(borough)>0;

Collisions_Vehicle:
load unique_key,vehicle_type_code1 as vehicle_type Resident Collisions;
Collisions_Vehicle:
load unique_key,vehicle_type_code2 as vehicle_type Resident Collisions;
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset