Weather data from .JSON API

2 Ansichten (letzte 30 Tage)
Esben
Esben am 26 Apr. 2023
Kommentiert: Esben am 26 Apr. 2023
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 Kommentare
Rik
Rik am 26 Apr. 2023
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 am 26 Apr. 2023
Thanks for the asnswer @Rik. I will ask the API provider why there is no data :)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Weather and Atmospheric Science finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by