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 do Regional Competition and Cooperation among Baidu API, python and arcgis

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Today, let's introduce how Baidu API, python and arcgis do regional competition and cooperation. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.

one

BAT products are used by everyone, and Baidu maps are often used, such as going out to buy medicine if you have a cold, looking for the nearest drugstore on Baidu map, going out to withdraw money to find a bank, or self-study to find a library and so on. Baidu map is good to find a suitable place.

The reason for this is that I am working on a project in Liaoyang. The owner of the project wants to build a drift on his own land. The leader asked me to look for similar projects around Shenyang, Liaoning Province. According to the traditional practice, Baidu map may be searched with keywords to see the distribution of drifting, and then collated and summarized one by one.

Some time ago, I learned that many big Internet companies provide API (interface for developer applications), so I thought of using this technology to do a regional competition with tables and maps.

two

Since I did it on PC, let's first introduce what I want to search. Baidu map looks like this:

The search keywords are on the left, and the list of provinces and cities is on the right

We can see the distribution of Liaoning drifting in various cities.

The above two can do a simple list with the map, what I want to do is the city-level distribution, and behind you can see that some drifting is a scenic spot, is regarded as several, must be manually judged and selected!

Baidu Map API: (website: http://api.map.baidu.com/lbsapi/cloud/index.htm)

The steps are as follows: go to the URL-Baidu Map API products-WEB Service API- location Retrieval Service-Service documentation. What I want to do is to search by region. On this page, I mainly get the url address with json data, as shown in the following figure:

The arrow refers to url

To apply for AK, you can go to the page of applying for ak on the service document page, and you can apply directly. Note that the setting of the IP whitelist is 0.0.0.0max 0, as shown in the following figure:

In this way, I get my ak, and I can get the URL of the data according to the changes I need:

Http://api.map.baidu.com/place/v2/search?query= rafting & region= Benxi & output=json&ak=QhqVRWoXovf0EtoSe2WbwC5W5Uc4Q7zG

Enter the browser address bar as shown below:

Contains longitude and latitude information, name and address of the city

After the completion of this step, the work of Baidu API is basically completed. The url is obtained in preparation for python to grab data.

three

Step 2 is to save the json data in the URL into the Excel file. It is not convenient for me to paste out the code example, which is a bit like a csdn post, as shown below:

Url uses, json module uses

The second half of the code, xlwt usage

This part of the crawler learns the two modules of json and xlwt, and the rest uses the basic knowledge of python. The crawled data is saved to the local excel file and opened as follows:

The red part is the same scenic spot.

After this step, the next step is to brush and sort out the data. The longitude and latitude are divided into two columns in excel (this method is to divide the columns with symbols). When the data is ready, it goes to the final step and places it on the map.

four

Before using Arcgis processing, there is another step. The latitude and longitude obtained by Baidu is the Baidu coordinate system. What we need is the earth coordinates, and we need to use the coordinate conversion tool:

Universal coordinate transformation (produced by Future Traffic Laboratory)

After a series of operations, I got the final desired data, the drift data of Liaoning cities with longitude and latitude information, the table is as follows:

Arcgis processing step: open arcmap, import the base map of the world map (add data-add base map-select the gray version of China Map), and then import XY coordinate data (file-add data-add xy data) Note: select the geographic coordinate system as shown:

Select the table we have prepared and correspond to the latitude and longitude

Finally, you need to adjust the coordinates of the point and map the picture. Finally, combined with the table, the map is placed, and the following three PPT are drawn according to the data on the OTA website to complete the task assigned to me by the leader:

Liaoning drifting table data

Geographical distribution of drift in Liaoning Province

Select several cases of benchmarking projects for analysis and summary

Above is Baidu API, python and arcgis how to do regional competition and cooperation of all the content, more and Baidu API, python and arcgis how to do regional competition and cooperation-related content can search the previous articles or browse the following articles to learn ha! I believe the editor will add more knowledge to you. I hope you can support it!

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