Weather data from .JSON API

조회 수: 9 (최근 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