Beruflich Dokumente
Kultur Dokumente
Manish Modani
Point Query:
https://api.weather.com/v3/wx/forecast/daily/10day?geocode=10.8505,76.2711&format=json&unit
s=e&language=en-US&apiKey=a0d69ec1942942c0969ec1942992c0f4
Titles:
In this section, procedure to visualize CORE API Temperature Tiles over Kerla is discussed. Same
procedure can be applied to visualize other weather parameters.
https://www.maptiler.com/google-maps-coordinates-tile-bounds-projection/
http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
(For Current condition only ts required, For forecast both ts and fts required).
Ts = Timeslice
fts=Forecasted time slice
https://api.weather.com/v3/TileServer/series/productSet/PPAcore?apiKey=a0d69ec1942942c0969ec1
942992c0f4
https://api.weather.com/v3/TileServer/tile/temp?ts=<ts>&xyz=<X:Y:Z>&apiKey=yourApiKey
e.g.
https://api.weather.com/v3/TileServer/tile/temp?ts=1580117700&xyz=91:60:7&apiKey=a0d69ec
1942942c0969ec1942992c0f4
Above link shows following
https://api.weather.com/v3/TileServer/tile/tempFcst?ts=<ts>&fts=<fts>&xyz=<X:Y:Z>&apiKey
=yourApiKey
https://api.weather.com/v3/TileServer/tile/tempFcst?ts=1580117400&fts=1580142600&xyz=91:6
0:7&apiKey=a0d69ec1942942c0969ec1942992c0f4
(PS: Forecast layer will have many forecast files (upto 10 days). One has to choose ts &
respective fts correctly).
#### Downloads TWC tiler binary data and creates VRT for each tile.
import requests,json,csv,shutil,os,math,subprocess
import multiprocessing as mp
from osgeo import gdal
from os.path import expanduser #to enable setting home directory
cross platform
import glob
# 4 Python variables need setting for each data product. Copy the
ones for the product you want to collect to the bottom of this list.
prod_name = "Temperatureheightaboveground"
prod_num=str(43)
rtQ=0 #set this variable to 0 for CoD data, which don't contain
forecast timestamp (rt) values.
vrttemplate=os.path.join(home,"Desktop\\TWC\\CSAG","template.zoom5.v
rt")
prod_name = "VAR01515FROM25011surface"
prod_num=str(7)
rtQ=0
prod_name = "Winddirectionfromwhichblowingheightaboveground"
prod_num=str(132)
rtQ=0 #set this variable so that we can collect from APIs when rt
isn't there.
lod=5
vrttemplate=os.path.join(home,"Desktop\\TWC\\CSAG","template.zoom5.v
rt")
prod_name = "Windspeedheightaboveground"
prod_num=str(33)
rtQ=0 #set this variable so that we can collect from APIs when rt
isn't there.
#Highest lod avail is 5...
lod=5
vrttemplate=os.path.join(home,"Desktop\\TWC\\CSAG","template.zoom5.v
rt")
prod_name = "Significantheightofcombinedwindwavesandswellmsl"
prod_num=str(395)
rtQ=1 #note the script only collects the first time-stamp. If you
want more timesteps, add another loop.
vrttemplate=os.path.join(home,"Desktop\\TWC\\CSAG","template.zoom3.v
rt")
#fname=os.path.join(home, "params","xylod.all.csv")
prod_name = "Temperatureheightaboveground"
prod_num=str(43)
rtQ=0 #set this variable to 0 for CoD data, which don't contain
forecast timestamp (rt) values.
vrttemplate=os.path.join(home,"Desktop\\TWC\\CSAG","template.zoom5.v
rt")
#---------------------------Functions--------------#
########################PRODUCT INVENTORY
CALL################################
def InvCall(prod_num,prod_name,rtQ):
base1 = 'https://api.weather.com/v2/tiler/info?products='
base2 = prod_num + ":" + prod_name #product # and name
base3 = '&apiKey='+APIkey
url = base1 + base2 + base3
print ('Getting Inventory from', url)
if rt==0:
base2 = prod_num + ":" + prod_name + "&t=" + t
base3 = "&lod="+z+"&x="+x+"&y="+y+"&apiKey="+APIkey
# base3 = "&lod=5&x=15&y=10&apiKey="+APIkey
# print "base3 is", base3
url = base1 + base2 + base3 # make API URL
print ("URL called: ", url)
STATICMAP_URL=url
path =os.path.join(home,'Desktop//TWC//CSAG',prod_name + "." + t
+ "."+x+"."+y+"."+z+".bin")
r = requests.get(STATICMAP_URL.format(bin), stream=True)
if r.status_code == 200:
with open(path, 'wb') as f:
r.raw.decode_content = True
shutil.copyfileobj(r.raw, f)
return (r.status_code)
vrtfiles=[]
os.chdir(os.path.join(home,'data'))
for name in glob.glob(os.path.join(prod_glob)):
vrtfiles.append(name)
print(vrtfiles)
b1 = gdal.BuildVRT(outputvrt, vrtfiles)
#######Start of main
values = InvCall(prod_num,prod_name,rtQ)
t= values[0]
rt=values[1]
print ("t is" , t)
print ("rt is" , rt)
tile_data = csv.reader(open(fname,'r'))
n_processes = 3
pool = mp.Pool(processes=n_processes)
#------attempt at multi-threading
#results = [pool.apply_async(TESTcall, args=(4,3,5)) for i in
range (0,4)]
#results = [pool.apply_async(APIcall,
args=(prod_num,prod_name,t,rt,x,y,z))]
#------attempt at multi-threading
if respCode == 200:
ProcessData(prod_num,prod_name,t,rt,x,y,z)
print ("DONE apicalls!")
#subprocess.call(['df', '-h'])
#other GDAL commands:
#gdal_translate -of XYZ
Windspeedheightaboveground.1528326300000.16.12.5.vrt
Windspeed.test.txt
call = makebigvrt(t)