-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheartquakes.py
38 lines (32 loc) · 1.08 KB
/
eartquakes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import urllib.request
import csv
import io
import math
def get_csv(url_usgs):
response = urllib.request.urlopen(url_usgs)
csvfile = csv.reader(io.StringIO(response.read().decode('utf-8')), delimiter=',')
next(csvfile, None)
return csvfile
#web marcator , convert latitute longituted in x,y axis
class Converti:
def __init__(self,lon,lat,zoom):
self.lon = lon
self.lat = lat
self.zoom = zoom
def mercX(self):
self.lon = math.radians(self.lon)
a = (256/math.pi)*math.pow(2,self.zoom)
b = self.lon + math.pi
return a * b
def mercY(self):
self.lat = math.radians(self.lat)
a = (256/math.pi)*math.pow(2,self.zoom)
b = math.tan(math.pi/4 + self.lat/2)
c = (math.pi)-(math.log(b))
return a * c
#open the api and write the content of the png file in a file that we will call map_raw.png
def download(api):
url_image = api
image = urllib.request.urlopen(url_image).read()
with open('map_raw.png', 'wb') as output:
_ = output.write(image)