Weather data from .JSON API

2 次查看(过去 30 天)
Esben
Esben 2023-4-26
评论: Esben 2023-4-26
Hi,
Im trying to import the following weather data from an .JSON API. I have tried "webread" on the URL but I dont know how to extract the wheather data values as shown in the table in the bottom of this post.
URL:
https://bank.stat.gl:443/api/v1/da/Greenland/EN/EN30/ENX1SUM.px
JSON query:
{
"query": [
{
"code": "weather station",
"selection": {
"filter": "item",
"values": [
"5"
]
}
},
{
"code": "time",
"selection": {
"filter": "item",
"values": [
"0",
"1",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"2",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"3",
"4",
"5",
"6",
"7",
"8",
"9"
]
}
}
],
"response": {
"format": "px"
}
}
and I expect the follow table to be imported as shown in the table which was generated on this homepage: https://bank.stat.gl/pxweb/da/Greenland/Greenland__EN__EN30/ENX1SUM.px/table/tableViewLayout1/
  2 个评论
Rik
Rik 2023-4-26
Your URL doesn't seem to contain the data, but only the row/col headers:
data=webread('https://bank.stat.gl:443/api/v1/da/Greenland/EN/EN30/ENX1SUM.px')
data = struct with fields:
title: 'Summerede graddageværdier efter vejrstation og tid' variables: {2×1 cell}
data.variables{1}.valueTexts
ans = 20×1 cell array
{'Nanortalik' } {'Qaqortoq' } {'Narsarsuaq' } {'Narsaq' } {'Paamiut' } {'Nuuk' } {'Kapisillit' } {'Maniitsoq' } {'Kangerlussuaq' } {'Sisimiut' } {'Qasigiannguit' } {'Kangaatsiaq' } {'Aasiaat' } {'Ilulissat' } {'Qeqertarsuaq' } {'Uummannaq' } {'Upernavik' } {'Qaanaaq' } {'Tasiilaq' } {'Ittoqqortoormiit'}
data.variables{2}.valueTexts
ans = 27×1 cell array
{'1995'} {'1996'} {'1997'} {'1998'} {'1999'} {'2000'} {'2001'} {'2002'} {'2003'} {'2004'} {'2005'} {'2006'} {'2007'} {'2008'} {'2009'} {'2010'} {'2011'} {'2012'} {'2013'} {'2014'} {'2015'} {'2016'} {'2017'} {'2018'} {'2019'} {'2020'} {'2021'}
Esben
Esben 2023-4-26
Thanks for the asnswer @Rik. I will ask the API provider why there is no data :)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Weather and Atmospheric Science 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by