You are reading the article Hacking Google Maps To Create Distance Features In Your Model / Applications updated in November 2023 on the website Eastwest.edu.vn. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested December 2023 Hacking Google Maps To Create Distance Features In Your Model / Applications
This article is going to be different from the rest of my articles published on Analytics Vidhya – both in terms of content and format. I usually layout my article such that after a read, the reader is left to think about how this article can be implemented on grounds.
In this article, I will start with a round of brainstorming around a particular type of business problem and then talk about a sample analytics based solution to these problems. To make use of this article make sure that you follow my instructions carefully.
Let’s start with a few business cases:
Retail bank: Optimize primary bank branch allocation for all the customers. This is to make sure that the bank branch allotted to the customer is close to the mailing or permanent address of the customer for his convenience. This might be specially applicable, if we open a new branch and the closest branch for many existing customer changes to this new branch.
Retail Store chain: Send special offers to your loyal customers. But offers could be region specific so same offer cannot be sent to all. Hence, you first need to find the closest store to the customer and then mail the offer which is currently applicable for that store.
Credit card company who sells co-branded cards: You wish to find out all partner stores which are closest to your existing client base and then mail them appropriate offers.
Manufacturing plant: Wish to find out wholesalers near your plant for components required in manufacturing of the product.
What is so common in all the problems mentioned above? Each of these problems deal with getting the distance between multiple combination of source and target destinations.A common approach
I have worked in multiple domains and saw this problem being solved in similar fashion which gives approximate but quick results.
Exercise : Can you think of a method to do the same using your currently available data and resources?
Here is the approach :
You generally have a PIN CODE for both source and destination. Using these PIN CODES, we find the centroid of these regions. Once you have both the centroids, you check their latitude and longitude. You finally calculate the eucledian distance between these two points. We approximate our required distance with this number. Following figure will explain the process better :
The two marked areas refers to different PIN CODES and the distance 10 kms is used as an approximate distance between the two points.
Exercise : Can you think of challenges with this approach ?
Here are a few I can think of :
If the point of interest is far away from the centroid, this approach will give inaccurate results.
Some times the centroid of other PIN CODE can be more closer to the point of interest than its own PIN CODE. But because it falls in area of the distant PIN CODE, we still approximate the point of interest with the centroid of distant PIN CODE.
In cases where we need finer distances than the precision of PIN CODE demarcation, this method will lead nowhere. Imagine a scenario where two branches of a bank and customer address is located in the same PIN CODE. We have no way to find the closest branch.
The distance calculated is a point to point distance and not on road. Imagine a scenario when you have two PIN Codes right next to each other but you have valley between which you need to circle around to reach destination.A manual Approach
Say you have two branches and a single customer, how will you make a call between the two branches (which one is closer)? Here is a step by step approach :
You choose the first combination of branch-customer pair.
You feed the two addresses in Google Maps.
You pick the distance/time on road
You fill in the distance in the table with the combinations (2 in this case)
Repeat the same process with the other combination.How to automate this approach?
Obviously, this process cannot be done manually for millions of customers and thousands of branches. But this process can be well automated (however, Google API have a few caps on the total number of searches). Here is a simple Python code which can be used to create functions to calculate the distance between two points on Google Map.
Exercise : Create a table with a few sources and destinations. Use these functions to find distance and time between those points. Reply “Done without support” if you are able to implement the code without looking at the rest of the solution.
Here is how we can read in a table of different source-destination combinations :
Notice that we have all types of combinations here. Combination 1 is a combo of two cities. Combo 4 is a combination of two detailed address. Combo 6 is a combination of a city and a monument. Let’s now try to get the distances and time & check if they make sense.
All the distance and time calculations in this table look accurate.
Exercise : What are the benefits of using this approach over the PIN CODE approach mentioned above? Can you think of a better way to do this task?
Here is the complete Code :
[stextbox id=”grey”]import googlemaps from datetime import datetime def finddist(source, destination): gmaps = googlemaps.Client(key='XXX') now = datetime.now() directions_result = gmaps.directions(source, destination, mode="driving",departure_time=now) for map1 in directions_result: overall_stats = map1['legs'] for dimensions in overall_stats: distance = dimensions['distance'] return [distance['text']] def findtime(source, destination): gmaps = googlemaps.Client(key='XXX') now = datetime.now() directions_result = gmaps.directions(source, destination, mode="driving",departure_time=now) for map1 in directions_result: overall_stats = map1['legs'] for dimensions in overall_stats: duration = dimensions['duration'] return [duration['text']] import numpy as np import pandas as pd import pylab as pl import os os.chdir(r"C:UsersTavishDesktop") cities = pd.read_csv("cities.csv") cities["distance"] = 0 cities["time"] = 0 for i in range(0,8): source = cities['Source'][i] destination = cities['Destination'][i] cities['distance'][i] = finddist(source,destination) cities['time'][i] = findtime(source,destination) [/stextbox]
[stextbox id=”grey”]End Notes
GoogleMaps API come with a few limitations on the total number of searches. You can have look at the documentation, if you see a use case of this algorithm.
Did you find the article useful? Share with us find more use cases of GoogleMaps API usage apart from the one mentioned in this article? Also share with us any links of related video or article to leverage GoogleMaps API. Do let us know your thoughts about this article in the box below.If you like what you just read & want to continue your analytics learning, subscribe to our emails, follow us on twitter or like our facebook page.
You're reading Hacking Google Maps To Create Distance Features In Your Model / Applications
Has there ever been an app that has caused so much of an uproar in the Apple community as Apple Maps? It was released in the fall of 2012 with iOS 6, and it was not received well to say the least. It was so poorly received that Tim Cook even wrote a letter apologizing for the poor launch of Apple Maps which contributed o the firing of Scott Forstall:
At Apple, we strive to make world-class products that deliver the best experience possible to our customers. With the launch of our new Maps last week, we fell short on this commitment. We are extremely sorry for the frustration this has caused our customers and we are doing everything we can to make Maps better.
Now that we are almost six years into Apple Maps, I am of the opinion that Apple was right, certainly in a post Facebook privacy scandal world, to replace Google Maps with their in-house mapping product. In fact, Google Maps isn’t on my iPhone, and here are five reasons I prefer Apple Maps over Google Maps.
You don’t have to sign in to use Maps. Personalized features, like letting you know when it’s time to leave for your next appointment, are created using data on your device. The data that Maps collects while you use the app — like search terms, navigation routing, and traffic information — is associated with random identifiers so it can’t be tied to your Apple ID. These identifiers reset themselves as you use the app to ensure the best possible experience and to improve Maps. Maps extensions that are used in ride-booking and reservation apps run in their own sandboxes and share permissions with their own parent apps. For ride-booking apps, Maps shares only your starting point and destination with the extension. And when you reserve a table at a restaurant, the extension knows only the point of interest you tapped.
Location data is one of the most private things you can share with someone. I’m not a “tin-foil” hat type person, but I do not want an app tracking everywhere I go.
2. Siri Integration
Is Siri the best voice assistant on the market? Most definitely not, but I also find it incredibly useful in the car. Being able to say “Hey Siri, give me directions home” is incredibly helpful while driving. Unless Apple allows users to replace Siri with a new default assistant (Google or Amazon), Siri will remain the best Assistant for iPhone users. You can also ask for directions to specific places (Hey Siri, give me directs to 123 Main Street, etc.).
3. Apple Watch
In a period where a lot of Apple Watch apps are disappearing, Apple Maps remains a built-in (and useful) feature. When you have your iPhone doing navigation, Apple Watch will vibrate with alerts to turn. This feature also works with walking directions. This feature alone makes Apple Maps an incredibly attractive platform if you wear Apple Watch.
4. Yelp Integration
Instead of having to build a database of company reviews, Apple Maps has Yelp integration to populate data. Yelp has been around for years and has a plethora of great data about local businesses. In fact, I use Yelp quite a bit for restaurant reservations. The integration of the two apps is well done, and a key part of the Apple Maps experience. I’d love to see Apple look into features like restaurant recommendations though.
5. Good Enough Maps Data
If I had to pick a product based on the map data alone, it would be hard to choose anything but Google Maps. They’ve been around for a lot longer than Apple Maps, and are continually getting better. On the flip side, Apple Maps hasn’t given me incorrect information in years. My non-scientific opinion is that Apple Maps data is 85% as good as Google. That 85% is 100% of what I need, and the other benefits of Apple Maps outweigh any negatives.
One final reason I love Apple Maps: it lists if a business takes Apple Pay.
FTC: We use income earning auto affiliate links. More.
If you commute to work or travel regularly, you probably rely on Google Maps to get to your desired destination. The app offers a robust lineup of tools to make your commute smoother. But what happens when you hit traffic halfway to your destination or are concerned about the amount of traffic on the road before you leave the house? You can simply check the traffic with Google Maps.
Tip: make route planning more efficient with a few Google Maps extensions.Checking Traffic in Google Maps
The traffic feature in Google Maps can come in handy when deciding which route to take to work or the grocery store. This feature color codes your map based on traffic volume, with green indicating no traffic delays, yellow or orange indicating medium traffic, and red indicating severe traffic delays.
Before you even begin your journey, you can quickly check the traffic conditions by following the steps below.How to Check Traffic in Google Maps on Mobile
Open Google Maps from your mobile device.
Tap on the “Layers” icon in the upper-right portion of the screen.
In the “Map details” section, tap “Traffic.”
Exit the Layers section by tapping the “X” in its top-right corner.How to Check Traffic on Google Maps on Desktop
Open a web browser and go to Google Maps.
Move your cursor to hover over the “Layers” thumbnail at the bottom left.Finding an Alternate Route in Google Maps
Sometimes the “quickest” route by mileage isn’t as quick. Luckily, Google Maps makes it easy to select alternate routes after you enter your desired destination in the smartphone app or in your web browser.How to Find an Alternate Route in Google Maps on Mobile
Open the Google Maps mobile app.
Tap on the “Directions” icon at the bottom right.
Enter your starting point and desired destination.
Once both locations are entered, touch the three dots next to the starting address.
Select “Route Options” from the menu options.
Tap the checkboxes next to each option you would like Google Maps to consider when planning your route. Press “Done” when you finish.
Still not happy with the route Google Maps has selected? See all of the alternate routes that display as gray lines on the screen. Tap on any of the options to select an alternate route.How to Find an Alternate Route in Google Maps on Desktop
Enter your starting point and desired destination.
Once you’ve entered both destinations, multiple route options are displayed as a list. Compare options based on time, mileage, or traffic.
Google Maps will provide options based on devices linked to your Google account. Select one.
Note: if none of the devices or addresses are correct, you can add a new device to your Google account.Frequently Asked Questions Does Google Maps show real-time traffic?
Yes, Google Maps displays real-time traffic status in most regions worldwide, which makes it easy for users to check whether there are traffic delays.Why is Google Maps not showing traffic?
If you cannot pull up traffic data on Google Maps, you may need to update your application, check your data connection, or recalibrate your location services.
Image credit: PhotoMIX Company via Pexels. All Screenshots by Megan Glosson.
Megan Glosson is a freelance technology writer based in Nashville, TN. She has extensive experience working with everything from printers to smart home systems, and serves as the go-to “tech guru” for a small business that sells digital products. Megan has created thousands of articles for online publications and company blogs, including How-To Geek, Clean Email, and Review Geek.
Subscribe to our newsletter!
Our latest tutorials delivered straight to your inbox
Sign up for all newsletters.
This article was published as a part of the Data Science BlogathonPre-requisites
Knowledge of OpenCV is a must.
Basic understanding of detection algorithm.
We know that security is always a main concern in every area because of the rise in crime rates in crowded areas or in suspicious isolated areas. Threat violence is a modern human rights issue. Nowadays Gun-related violence threatens our most fundamental human right that is the right to life. Gun violence is a daily tragedy that affects the lives of people around the world. At least or more than 400 people die every single day because of violence committed with these weapons. The availability of guns always remains a big factor behind the stake in crime and chaos. This is just illustrated by the crime scene in America like you know. In the USA, Gun culture is very strong and has a historical origin also.
Even for light weapons or guns, licenses are a must under the “2023 Arms Rules”. However, securing a license is a very complex procedure that can take some months. It’s much difficult to put a point on illegally possessed weapons. This possesses a major problem for these dangerous weapons on the security concern of the public. Due to the thriving demand for the protection of safety, security, and personal properties if any, the needs and deployment of video surveillance systems can recognize and interpret the scene, and irregular events play important role in intelligence monitoring.What is the objective behind the threat detection system?
We are going to implement the following method to detect weapons using the YOLOv3 algorithm. This dataset is further trained for the classification of weapons using the YOLOv3 (You Only Look Once) algorithm. Once the data is trained successfully, the system will be able to classify the type of weapon present in the real-time input video from the surveillance cameras(CCTVs) along with the weapon. If the weapon is detected, then a threat alert will be sent to the respective authorities. Let’s get started…
Before getting started, first we need to look at the YOLOv3 algorithm.What is the YOLOv3 and how it works?
Yolov3 Algorithm namely YOLOv3 (You Only Look Once Version 3) is a real-time object detection algorithm that identifies specific objects in videos, webcams, or images. As we know, Region-based convolutional neural networks (R-CNN) require thousands of network evaluations to make predictions better for one image which might be very time-consuming and sore to optimize.
In YOLOv3, the feature extraction and object localization were unified into a single uniform block. Its single-stage architecture, named YOLO (You Only Look Once) results in a very fast surmise time. It takes the entire image in a single case and predicts the bounding box coordinates and class probabilities for these boxes for an object. Unlike other methods, images are scanned with a sliding window but in YOLO, the whole image is passed into a convolutional neural network (CNN) and predicts the output in one pass. The following fig shows its working:-
Image 1System Requirement
● Intel Pentium Processor
● Min 4 GB RAM
● Min 1 GB Hard Disc
● Any Operating System
● Anaconda, Jupyter Notebook
● OpenCV: OpenCV is an open-source library used for computer vision(CV), machine learning(ML), and image processing(IP).
● YOLOv3Implementation of our threat detection System
Here raw images are not appropriate for analysis purposes and it needs to be converted into the processed format, such as jpeg, jpg for further analysis. The image size is reconstructed into a square image and the images were then retained in the RGB/BGR format. Dataset is created by collecting weapon images and making them ready for the creation of the dataset. We have taken this dataset from the internet in which images are in jpeg format in the Images folder. There is one more Labels folder that has txt format files where for each file, the first line contains several objects in the corresponding image and the next line contains coordinates of the describiSeparation of the Dataset into training and testing data
As the dataset is stored in the darknet folder and then compressed darknet folder into a zip file and upload into your google drive. The dataset that is uploaded is further divided into 70% training data and 30% testing data and the images are separated into different folders which can be used further for training the model.
By using the following code you can perform train test splitting:
So we need to install the sci-kit learn library and then import module train_test_split from it. As we want to split data so we have set test_size=0.3 for testing data and random_state is nothing but our seed which will keep all samples the same at every time.
Further, save this splitting in the form of .txt files. Although this is beyond the scope of this article, hence you can download directly these files from here: chúng tôi and chúng tôi which I have already split, and placed them in the directory “darknetdata“.
The following code shows how to read data and split.
Import following libraries to work with operating system and files inside it:import os import random # Read data with train and validation X = [os.path.join('train', x) for x in os.listdir('train')] Y = [os.path.join('val', x) for x in os.listdir('val') if x[-3:] == "txt"] from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.3, random_state=2023)
As you can see in the above code, listdir() will return a list that contains names of files in that directory which is given by the path earlier to read data accordingly.
Further, In the next step, we are required to create file “yolo.names” in the same directory “darknetdata”, with object names that we want to detect as every new line. For example, in our case, we need to detect weapons only so the first line would be “weapon”. You can create this file by using notepad.
Now, create file “yolo.data” in the directory darknetdata, containing:classes= 1 #number of objects that we want to detect train = data/train.txt valid = data/val.txt names = data/yolo.names backup = backup #folder which is created on google drive
C. How to train the model?
So you need to modify only this part of the code in the configuration file to train the model as shown below: (open it with notepad and make changes accordingly)# At Line 8 & 9: width = 416, height = 416 #At Line 20 max_batches = 6000 # At Line 22 steps = 5400 #At Line 603, 689, 776 filters = 18 #At Line 610, 696, 783 classes = 1
Open directory “darknetexamples” folder, open file “detector.c” file . At line 138, change or modify this line as below:
Here you can refer to my COLAB notebook i.e how to train the model.Testing the threat detection model
So we are required to install OpenCV libraries by using the pip command as follows:
pip install opencv-python
So we will import OpenCV, NumPy libraries to read images and perform mathematical operations simultaneously.import cv2 import numpy as np # Load Yolo algorithm nnet = cv2.dnn.readNet("yolov3_training_2000.weights", "yolov3_testing.cfg") classes = ["Weapon"]
Here, in the above code, we can see that, we need to load weights and configuration files in order to use the Yolo algorithm and define classes of your object detection by using OpenCV. The configuration file contains all convolutional neural network layers.layer = net.getLayerNames() op_layer = [layer[i - 1] for i in nnet.getUnconnectedOutLayers()] colors = np.random.uniform(0, 255, size=(len(classes), 3))
In the above code, you can see that we have taken CNN layers i.e neural network layers as well as output layers(op_layer). And then we have also taken random colors according to classes. So that each object is uniquely identified by a different color.def value(): val = input("Enter Filename or press key enter to start web camera: n") if val == "": val = 0 return val
In the above code, we have defined the value() function where it accepts the file name that you wanted to test. by using the input function we can accept some value from the user.# for image capture cap = cv2.imread(value()) while True: height, width, channels = cap.shape # Detecting objects blobi = cv2.dnn.blobFromImage(cap, 0.00392, (512, 512), (0, 0, 0), True, crop=False) net.setInput(blobi) outl = net.forward(output_layers) # Showing information on the screen class_ids =  confidences =  boxes =  for out in outl: for detection in out: scores = detection[5:] class_id = np.argmax(scores) confidence = scores[class_id] # Object detected center_x = int(detection * width) center_y = int(detection * height) w = int(detection * width) h = int(detection * height) # Rectangle coordinates x = int(center_x - w / 2) y = int(center_y - h / 2) boxes.append([x, y, w, h]) confidences.append(float(confidence)) class_ids.append(class_id) ind = cv2.dnn.NMSBoxes(boxes, confidences, 0.5, 0.4) print(ind) if ind == 0: print("Weapon detected in Image!! Threat Alert!") else: print("Weapon Not detected...") font = cv2.FONT_HERSHEY_PLAIN for i in range(len(boxes)): if i in ind: x, y, w, h = boxes[i] label = str(classes[class_ids[i]]) color = colors[class_ids[i]] cv2.rectangle(cap, (x, y), (x + w, y + h), color, 2) cv2.putText(cap, label, (x, y + 30), font, 3, color, 3) cv2.imshow("Image", cap) key = cv2.waitKey(0) cap.release() cv2.destroyAllWindows()
In the above code, firstly we have read the image from an input file. Then to detect objects in the given image we need to find out height, width and then detect an object and pass it to the input layer and output as well. And then to detect an object we are required its respective coordinates as (x,y,h,w) so that the bounding box can be drawn.
Once all these get completed, we need to perform NMS that is Non-Max Suppression to avoid multiple bounding boxes around the object and get only the best box. Then if this weapon is found in the image then it will alert as below:
Image Source: Self
And if this weapon is not found in the image then it will alert as below:
Image Source: SelfOutput of the threat detection model
The above detection is done through a live webcam.Conclusion
With this result, this can be useful to security and police officers who are constantly on patrol to make them aware of the weapon in the surveillance. I hope you liked the article. Thank You!Image Source
The media shown in this article are not owned by Analytics Vidhya and are used at the Author’s discretion.
Keyhole Now Live on Google Maps
Today Google integrated Keyhole into Google Maps. Here’s The Kelsey Group’s corporate offices. This is a companion view; Google’s high-resolution graphical mapping is still the default. Keyhole integration into Google Maps has been expected since the company was acquired late last year.
Of course, this is a beta and it doesn’t have 100 percent of the functionality of the client software version (nor will it). It offers an interesting, alternate view of locations and will be helpful in certain contexts (e.g., housing search, travel). But I had high expectations and was a bit frustrated that the maps didn’t zoom in closer in the two major metro areas I tested (Los Angeles and New York).
There is a novelty/wow factor here, which can’t be underestimated in the consumer context. But in the few searches I tried, I actually preferred the “cartographic” maps (the most recent upgrade before keyhole). They were cleaner and more pleasing to look at, subjectively speaking.
I would also like to see Google Maps do the kind of overlay (“Map Nearby”) that Yahoo! Maps offers.
Rest assured the product will get better—and so must the mapping functionality on Google’s competitors’ sites.
Here’s the verbatim press release:
In a continued effort to connect searchers with the information they need whether it’s across the Internet or in their neighborhood, today, Google announced the integration of Keyhole, a digital mapping service acquired by Google in 2004, into Google Maps. The integration enables Google Maps users to view maps and directions through Keyhole’s satellite and aerial high resolution digital photos. The new functionality is also available on the maps shown through Google Local.
The traditional graphical maps provided by Google Maps are still available through the service, as well as, Google Local. In addition, users can now select ‘Satellite’ mode and see actual overhead views of the area or route they have selected. As with the original Google Maps, the Keyhole maps enable users to zoom in and out, and navigate the satellite and aerial high resolution digital maps dynamically in any direction.
Keyhole will continue to offer its Keyhole 2 LT and PRO software products that provide interactive access to a streaming 3D global database of imagery and mapping information.
There is a lot you can do with Google Docs since it is a powerful word processor. It’s not on the same level as Microsoft Word, of course, but there is quite a lot you can do with it. For example, you can create a newsletter in Google Docs with relative ease.
Google Docs is a free word processor that is cloud-based and is included as part of the Google Suite productivity tools. A Newsletter is a tool used by organizations and businesses to share valuable and important information with customers on their network.Does Google have a newsletter format?
When it comes down to creating newsletters, many tend to use premium software, but if you are on a strict budget, you don’t have to. That’s because it’s possible to create a newsletter via a document processor such as Google Docs.
The newsletter template for Google Docs is great because it allows the user to create a newsletter without needing prior skills or experience. With this template, folks can share news or other information with hundreds of people with relative ease.How to create a Newsletter in Google Docs?
Creating a newsletter in Google Docs will require you to use the Newsletter template and perform some customizations to make it your own. So open Google Docs, visit the Template Gallery, select the Newsletter template, and finally customize it to meet your requirements.Open Google Docs
First, you must launch into your favorite web browser, and from there, navigate to the official Google Docs webpage.
Once that is done, please sign in with your Google account information if you haven’t done so already.Select the Newsletter template
Doing this will reveal additional templates.Customize the Newsletter
We now want to customize the newsletter template for it to better fit your overall requirements. Let us give you an example of what to do.
Begin by replacing the text and images with your preferred options.
Once you’ve accomplished that task, select Get Add-ons, then search for Mail Merge. Choose the second app that shows up in the results to install the free add-on. Bear in mind it is the add-on made by Quicklution, so you cannot miss it.Tips to think about while creating a newsletter
Write a title or subject line in your Newsletter for your users to have something to think about.
Ensure your newsletter is short and delivers information that is straight to the point.
If you can, please add some multimedia content so that your newsletter isn’t just a wall of text.
The last thing to consider here is to make sure the content is designed for the target audience. That’s because going off-script can be detrimental and drive readers away.
READ: How to use Version History in Google DocsHow to create a newsletter in Google Slides?
Open Google Slides and create a new document. From there, give it the name, Newsletter. Add a title and a content box at the top of the newly created slide. From the title box, type an easy-to-remember name for your newsletter. Next, add a subtitle box at the bottom of the title, and type a short description. Once you’re done, add a text box below the subtitle area, and proceed to type your newsletter content. Customize the newsletter with images, tables, charts, and other visual elements before saving your work.
Update the detailed information about Hacking Google Maps To Create Distance Features In Your Model / Applications on the Eastwest.edu.vn website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!