Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to obtain the longitude and latitude information of each point on Baidu map

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use Python to get the longitude and latitude information of various points on Baidu map". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to use Python to obtain longitude and latitude information of various points on Baidu map"!

Demand analysis

It is to grab the information of some specific points on Baidu map and generate a test example to do the later experiment of the algorithm. For example, the following map:

Now you need to crawl the relevant information about these points of the "supermarket" searched on the map, including latitude and longitude, location name and so on.

First of all, of course, the stupidest way is to check the Baidu map coordinate pickup system, and then copy and paste it to the document one by one:

This method is time-consuming and laborious, is not in line with our core socialist values, and seems to be as good as 150 points at a time (I don't know how to get more points, friends who know can tell me). But we certainly need more than that:

So, we have to find a way, can we use some automated scripts to automatically crawl data and save it in the desired format?

Baidu Map POI

Then Baidu learned about Baidu map POI data by accident.

What is POI? POI is a real-world entity that can be abstracted into spatial points, such as restaurants, hotels, shopping malls and so on. POI data has spatial coordinates and various attributes, which is one of the basic data of all kinds of map query software.

Baidu Maps, as the top map service provider in China, contains rich POI data, so how to quickly obtain Baidu Map POI point of interest data? -- of course, you have to use the Python+ crawler to accomplish this task.

The key to POI data acquisition is to construct an appropriate url, and the corresponding POI data can be requested by accessing the url.

Preparation in advance

Before we start, we need to do some preparatory work, apply for an account and key, and then call the API of Baidu Maps to get the required data.

First of all, you need to log in to Baidu Map Open platform http://lbsyun.baidu.com/ to complete the registration. This platform is used by Baidu Maps to provide interfaces for developers. There are many other functions. Here we only talk about POI crawling.

After registering and logging in, enter the console in the upper right corner:

Then find my application under the application management on the left and create an application.

Then, enter the application name, select the server for the application type, and retrieve the location to the check box. Refer to the documentation for specific API invocation methods.

It is worth noting that the setting of the IP whitelist, if you want to make any IP calls, write 0.0.0.0 IP 0 to avoid the trouble of choosing this one.

After the creation is completed, we will get the AK of such an application, which is the access key:

Find the Web service API in the development documentation:

Select a location to retrieve the service documentation for V2.0, and we will see the instructions:

In fact, through an edited URL, request data, and then the server returns the corresponding information. For example, if you use administrative areas to retrieve supermarket information in Wuhan, you can edit:

Http://api.map.baidu.com/place/v2/search?query= supermarket & region= Wuhan & output=json&ak= just created the application AK

Enter the browser and enter to get the desired information:

At this point, I believe you have a deeper understanding of "how to use Python to obtain the longitude and latitude information of various points on Baidu map". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report