GithubHelp home page GithubHelp logo

zhengjie9510 / google-map-downloader Goto Github PK

View Code? Open in Web Editor NEW
140.0 2.0 52.0 15 KB

Small tools to download Google maps satellite image for a given extent & zoom level to a TIFF file with geographical coordinates and speeding it up with multiple threads and processes.

Home Page: https://zhengjie9510.github.io

License: MIT License

Python 100.00%
google map download tile

google-map-downloader's Introduction

Google-Map-Downloader

Google-Map-Downloader

中文:

downloader_1.1
一个小工具,你只需要输入空间范围、地图缩放等级就可以实现Google地图的下载,并输出为TIFF格式,含空间坐标系。
downloader_1.2
是在1.1版本上的改进。由于python的多线程中存在GIL锁,导致python的多线程不能利用多核,考虑到现在的计算机是多核的,为了充分利用计算机的多核资源,提高下载速度,尝试利用多进程+多线程的方式来实现地图切片下载,最终速度得到极大提高。但该部分还没有实现进度条功能。

English:

downloader_1.1:
A small tool, you only need to input the spatial extent and map zoom level to download Google Maps, and output to TIFF format, including the spatial coordinate system.
downloader_1.2:
It is an improvement on version 1.1. Due to the existence of GIL locks in python's multi-threading, python's multi-threading cannot use multi-cores. Considering that computers are now multi-core, In order to make full use of the computer's multi-core resources and increase the download speed, try to use multi-process + multi-threaded way to achieve map tile download. The final speed has been greatly improved, but this part has not implemented the progress bar function.

指南/Guide

安装/Install

conda install --yes --file requirements.txt

使用/Use

if __name__ == '__main__':
    start_time=time.time()
    
    # main(100.361,38.866,100.386,38.839,13,r'C:\Users\test.tif')
    main(left,top,right,bottom,zoom,filePath,style='s',server="Google")

    end_time=time.time()
    print('lasted a total of {:.2f} seconds'.format(end_time-start_time))
'''
Parameters
----------
left, top : left-top coordinate, for example (100.361,38.866)
    
right, bottom : right-bottom coordinate
    
z : zoom

filePath : File path for storing results, TIFF format
    
style : 
    m for map; 
    s for satellite; 
    y for satellite with label; 
    t for terrain; 
    p for terrain with label; 
    h for label;

source : Google China (default) or Google
'''

问题/Issues

If you encounter the problem of Bad network link, you can change the HEADERS in the download function, and try again.

def download(self,url):
        HEADERS = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36'}
        header = ur.Request(url,headers=HEADERS)
        err=0
        while(err<3):
            try:
                data = ur.urlopen(header).read()
            except:
                err+=1
            else:
                return data
        raise Exception("Bad network link.")

google-map-downloader's People

Contributors

dependabot[bot] avatar zhengjie9510 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

google-map-downloader's Issues

错误的网络连接

关于谷歌地图源,可以给出一些链接吗?
我有一个坐标,19级的tile下载不下来。换了地图源还是不行
非常感谢

bad network link

"After multiple attempts to change the headers in the code, I am still encountering the 'bad network link' error. May I inquire if there are alternative solutions available? Your assistance would be greatly appreciated. Thank you for your time and consideration. Best wishes!"

Bad network link

Hi Zhengjie,
It is an amazing work you did, and I try to use it but keep telling me "Bad network link", like the following:

Exception in thread Thread-4:
Traceback (most recent call last):
  File "C:\Users\winston.zhu\code\anaconda3\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:/Users/winston.zhu/Documents/SeeingMachines/Map/Google-Map-Downloader-master/Google-Map-Downloader-master/downloader_1.1.py", line 193, in run
    self.datas[i]=self.download(url)
  File "C:/Users/winston.zhu/Documents/SeeingMachines/Map/Google-Map-Downloader-master/Google-Map-Downloader-master/downloader_1.1.py", line 187, in download
    raise Exception("Bad network link.")
Exception: Bad network link.

Is there anything I can do to solve this problem? By the way, I am in Australia and use "Google" as the source.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.