In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use python to achieve osm slice calculation". In daily operation, I believe many people have doubts about how to use python to achieve osm slice calculation. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to use python to achieve osm slice calculation". Next, please follow the editor to study!
General maps are displayed by publishing slices in the background and read by the front-end engine. Some of the map slices are cut by longitude and latitude, and some are cut by Google's Mercator, so according to a certain coordinate range and zoom level, the horizontal and vertical order of the slices can be calculated, and detailed z (zoom), x (horizontal), y (vertical) numbers can be obtained, and then according to the basic server url. This slice can be downloaded to the local, multiple slices merged into one, given coordinate information, it will become a map image, the general map download tools are also downloaded and generated in accordance with this principle.
OSM is an open source map. Its map slices are cut according to longitude and latitude, that is, EPSG:4326. When calculating the slices of longitude and latitude, there is no need to convert the coordinates into web Mercator coordinates. Here is a code (python) to calculate the order of slices based on longitude and latitude coordinates:
Def deg2num (lat_deg, lon_deg, zoom):
Lat_rad = math.radians (lat_deg)
N = 2.0 * * zoom
Xtile = int ((lon_deg + 180.0) / 360.0 * n)
Ytile = int ((1.0-math.log (math.tan (lat_rad) + (1 / math.cos (lat_rad) / math.pi) / 2.0 * n)
Return (xtile, ytile)
Input longitude and latitude coordinates and zoom level, you can find which slice the coordinates are on, and the direction of longitude is equal, which is relatively simple in the calculation. The latitude narrows at the distance of high latitude, so, to calculate through a complex mathematical formula, the higher the grade, the more the number of slices, the more slices will be downloaded, and the number of slices will increase according to the number of squares.
The downloaded slice coordinate range is not necessarily the same as the incoming coordinate range, so the map downloader is sometimes the same, and the merged image is not the four incoming ranges, which requires a certain amount of map clipping at a later stage.
A downloaded slice can be merged with libraries such as gdal, which is very convenient for merging and calculating the merged map.
At this point, the study on "how to use python to achieve osm slice calculation" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.