Home Business Intelligence Energy BI and Google Maps API (Handle Lookup)

Energy BI and Google Maps API (Handle Lookup)

0
Energy BI and Google Maps API (Handle Lookup)

[ad_1]

On this publish I clarify find out how to use Google Maps APIs to retrieve helpful data out of Google Maps. The use case state of affairs may very well be getting deal with, postal code, and many others. from present latitude and longitude values. The info may very well be generated by any form of GPS monitoring gadget like your Garmin biking GPS pc, your Fitbit watch and many others. I do know you possibly can load your GPS monitoring knowledge into athletic social networks to analyse your actions. However, if you wish to do some extra particular knowledge analytics like during which space of the town you created extra energy throughout your biking actions then these web sites won’t provide you with what you need free of charge.

As an example, you possibly can export your gadget knowledge to CSV then import and append all CSV information right into a Energy BI mannequin and create wonderful analytical studies. How you can import your CSV information right into a Energy BI mannequin is out of scope of this text so I depart it to you for any additional investigations.

GPS monitoring gadgets are creating a number of knowledge together with geographic coordinates which might be simply utilized in Energy BI. You’ll be able to merely put latitude and longitude on a Map visualisation and also you’re good to go.

Power BI Map using Coordinates

You too can concatenate the latitude and longitude knowledge and use it as Location in your Map visualisation.

Power BI Map using Location

This may be completed from Question Editor in M language.

Creating Location from Latitude and Longitude in Power BI

However, in some instances you want some extra geo-information like Nation, Metropolis, Publish Code and Road Handle in a desk as properly. Otherwise you would possibly wish to use postal code in a slicer. On this article I present you find out how to get all of those data out of Google Maps by passing present coordinates to Google Maps geocoding API.

To have the ability to observe this publish steps you should:

  • Have a Google account
  • Activate the Google Maps Geocoding API
  • Discover a desired API in Google Builders Information
  • Use the API in Energy BI
  • A GPS gadget knowledge exported to CSV file

I assume you have already got an present Google account or you understand how to create a brand new one, so I bounce straight into the following step which is activating geocoding API. To have the ability to begin utilizing the Google Maps Geocoding API you should get an API key first.

Google Maps Geocoding API

  • Scroll down and click on “Get A Key”

Get Google Maps API Key

  • This can navigate you to Google Builders Console
  • Click on “Sure” then click on “Agree and proceed”

Get Google Maps API Key 2

  • Sort in a reputation then click on “Create”
  • Get Google Maps API Key 3

You efficiently created an API key. We are going to use this key within the subsequent sections of this text.

Now that we have now an API key we are able to use a number of Google Geocoding APIs out there right here. As you possibly can see there are many helpful APIs you should use to leverage your Energy BI mannequin. In my pattern I have to retrieve Nation, Publish Code and Road Handle out of present coordinates generated by my bike GPS pc. So I take advantage of Reverse Geocoding (Handle Lookup). Here’s a pattern:

https://maps.googleapis.com/maps/api/geocode/json?latlng=-36.8484213,174.7457047&key=YOUR_API_KEY

Should you copy and paste the above API in your internet browser you possibly can see its output which is a JSON offering detailed details about the placement.

Notice: Don’t forget to repeat and paste your API key on the finish of the API.

JSON Output of Google Reverse Geocoding API

The concept is to outline a operate in Energy BI then go latitude and longitude to the operate to get Nation, Postal Code and Road Handle.

The way it works

  • Open Energy BI Desktop
  • Get Information from Internet
  • Paste the API within the URL part then click on OK

Power BI Desktop Get Data From Web

  • Keep on with the default and click on “Join”

Power BI Desktop Access Web Content

  • This opens “Question Editor”
  • Click on “Listing”

Power BI Desktop Query Editor Expand List

  • Convert the listing to desk by clicking “To Desk” button from “Remodel” tab from the ribbon

Power BI Desktop Convert List to Table

  • Click on on develop complicated column icon (image) to develop the desk then tick “formatted_address” and “varieties” columns then click on OK

Power BI Desktop Expand Complex Column

Power BI Desktop Expand Complex Column 2

  • Develop the “varieties” column as properly

Power BI Desktop Query Editor

  • Filter “varieties” column to indicate “Nation”, “Postal Code” and “Steer Handle”

Power BI Desktop Query Editor Filter Column

Power BI Desktop Query Editor 2

  • We have to the columns as rows so we have to transpose the desk. So go to “rework” tab and click on “Transpose”

Power BI Desktop Transpose Table

  • As you see the second row comprises the column names. Click on “Reverse Rows” to indicate the second row first

Power BI Desktop Reverse Rows

  • Click on “Use First Row As Headers”

Power BI Desktop Use First Row As Header

  • Rename the question then save the mannequin

Power BI Desktop Rename Query

Create a Perform from an Present Question

Up to now we loaded the geo-location data for only one coordinate. Now we have to flip the question to a operate in order that we are able to invoke it for all coordinates we have now in our dataset.

A operate development is as beneath:

 

  • Click on “Superior Editor”

Power BI Desktop Advanced Editor

  • Change the code as per screenshot beneath

Power BI Desktop Create Function

1– Perform inner identify

2 & 4 – Enter parameters

3 & 5 – Parameters’ knowledge varieties

6 – Perform physique

7– Output

Notice: The identify that might be used to revoke the operate is the question identify which is “fn_GeoLocation” in our pattern.

  • Proceed modifying the codes as beneath then click on “Executed”

Power BI Desktop Function Parameters

  • What we have now completed above is that we changed the static latitude and longitude with parameters. We used “&” to concatenate each side of the supply.
  • As quickly as you click on “Executed” Energy BI detects the question as a operate

Power BI Desktop Invoke Function

  • To check the operate simply click on “Invoke” and enter latitude and longitude then click on OK

Power BI Desktop Invoke Function 2

Power BI Desktop Invoke Function 3

  • Delete the invoked operate step

We efficiently outlined a question as a operate in order that we are able to invoke it anytime.

The subsequent step is to load GPS knowledge from CSV. I’m utilizing my bike pc knowledge that I exported to CSV format earlier.

Obtain pattern CSV file right here.

  • In Question Editor, click on “New Supply” from “Residence” tab then click on “CSV”

Power BI CSV

  • Browse and open the CSV file
  • Click on OK

Power BI Query Editor CSV

  • Click on “Add Customized Column” from “Add Column” tab and identify it “Geolocation”
  • Enter the next method to invoke the fn_GeoLocation operate and click on OK

Power BI Query Editor Add New Column

Notice: I used “Quantity.ToText” operate to transform latitude and longitude knowledge kind from quantity to textual content as we outlined the operate parameters as textual content.

  • You’ll get a “Data is required about knowledge privateness” warning message. Click on “Proceed”

Power BI Query Editor Add New Column 2

  • Choose a desired privateness stage from the listing then click on “Save”

Power BI Privacy Levels

Notice: Be taught extra about “Privateness ranges” right here.

  • Scroll proper to seek out the brand new added column
  • Develop “Geolocation” column

Power BI Expand Complex Column 2

Voila! We now have bought all data wanted

  • Click on “Shut & Apply” from “Residence” tab from the ribbon and wait till the info masses into the mannequin.

Power BI Query Editor Close & Apply

Notice: It would take someday to load knowledge into the mannequin primarily based in your dataset dimension. That is due to sending coordinates to Google Maps row by row then loading the outcomes into the mannequin, so the method may very well be gradual when you have a big dataset. There are additionally some limitations utilized to the API utilization.

Now you possibly can simply use new columns for various functions like placing Nation or Postal Code in slicers, making a Location hierarchy and so forth. So there are many totally different fascinating issues you are able to do with the knowledge we bought from Google Maps.

Power BI and Google Maps API

Geo-Location APIs in Normal

As you understand Google will not be the one one who supplies geo-location APIs. You are able to do the identical utilizing Microsoft Bing Map or HERE Maps.

Extra studying supplies:

Limitations

Utilizing Geocoding API will not be free so some limitations apply if you end up on a free utilization plan. As an example you should use solely 2,500 requests per day and 10 requests per second. Take a look at right here to study extra in regards to the API utilization limitations.

The opposite alternate options like Microsoft Bing Map and HERE Map have some limitations as properly.

For extra data have have a look at the hyperlink beneath:

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here