python下载google map地图数据

来源:互联网 发布:ftp站点怎么绑定域名 编辑:程序博客网 时间:2024/06/07 07:11

 

# coding=gbk

'''

Created on 2010-6-3

 

@author: Administrator

'''

import urllib

left=113.14062501;

bottom=22.178289;

right=113.62447;

top=22.78125;

 

dy=0.0025349162;#(22.5643181-22.5641596);#这是个GOOGLE API的GetBound()函数获得的在一定放大级别下512像素的经纬度范围

dx=0.0027465819;#(113.3400086-113.3398370);

#pixX=dx/512.0;

#pixY=dy/512.0;

 

_width=right-left;#经度距离

_height=top-bottom;#纬度距离

#d_width=(_width*10000.0)*3.0;#单位米

#d_height=(_height*10000.0)*3.0;#单位米

clos=_width/dx;#    横向图片数

rows=_height/dy;#纵向图片数

#clos=d_width/60.0;#    横向图片数

#rows=d_height/60.0;#纵向图片数

pImage_width=dx;#_width/clos;#_width/clos;#每张图片的经度宽度

pImage_height=dy;#_height/rows;#_height/rows;#每张图片的经度宽度

iclos=round(clos);

irows=round(rows);

#"/n距离(米):",d_width," ",d_height,

print "经度范围:",_width," ",_height,"图片数:",rows,clos,"/n每张图片:",pImage_width," ",pImage_height;

for i in range(3):

    print i;

    for j in range(3):

        print j;

        centerX=left+pImage_width*j*2+(pImage_width/2.0);

        centerY=top-pImage_height*i*2+(pImage_height/2.0);

        strurl="http://ditu.google.cn/staticmap?center="+str(centerY)+","+str(centerX)+"&span="+str(pImage_width)+","+str(pImage_height)+"&maptype=satellite&format=png&size=512x612&key=ABQIAAAAksIjZ-2E34LmlghebP6TlRRM9uYouW25bpUuMiT0LulBXvKjqhRIRANH6RzatBTe6P1Keuurkhvu5Q&sensor=false";

        print strurl;

        urllib.urlretrieve(strurl, "e:/googlemap/"+str(j)+"_"+str(i)+".png");

 

 

 

 

 

 

 

 

 

原创粉丝点击