Download Baidu map tiles by GCJ coordinates
Lon, lat, coordinates, WGS-84, Mercator projection, tile indices… already seem confusing. When working with Baidu, amap, etc in China, there is another layer of complication for “s e c u r i t y”. GCJ-02 is the Chinese standard for formatting lon & lat, while company like Baidu made things even more complicated as they invented the BD-09 format.
So I wrote some python codes to make life easier: downloading a satellite map for any given GCJ lon&lat:
the downloaded map is made of 25 tiles (zoom level 19):
Configure the number of tiles by setting, e.g., dd=3 to obtain a map of 49 tiles. number = (2*dd+1)².
If you have a long list of GCJ coordinates in an Excel file, congratulation! you can use
https://github.com/whitegreen/BaiduTiles_byGCJ/blob/main/baiduManyTiles2.py
to download all the maps !
bdLon, bdLat = calTiles.gcj2bd(118.984728,31.284715) # input GCJ lon, lat
converts GCJ-02 to BD-09 coordinates. Comment out this line if you already have BD-09 lon & lat.
Visit https://github.com/whitegreen/BaiduTiles_byGCJ and enjoy the landscape!