Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4021) - 04 May 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

MetOffice Radar/Satellite Images

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
212adws
Posts: 6
Joined: Mon 05 Apr 2010 12:24 pm
Weather Station: Maplin N96FY
Operating System: Windows 7
Location: Woking, Surrey, UK
Contact:

MetOffice Radar/Satellite Images

Post by 212adws »

Hi
My first post. I have been "lurking" here for ages and now own a Fine Offset WS.

It seems that the MetOffice is soon going to ease the current restrictions on the use of much of the data on their website. A document at http://www.opsi.gov.uk/unlocking-servic ... mmentstart explains, wherein there is specific reference to their radar imagery soon being possibly classified as either unregistered or registered free content.

In eager anticipation I have been coddling together a PHP script to download, say, the Rainfall Radar image. But I have a coding problem I cannot solve: sometimes the images are not available for a short while, during updates etc., and an http request returns empty but I haven't been able to work out how to expand the script to load an alternate "image not available" image in that situation. Can anybody give me a few pointers?

Code: Select all

//Set latest MetOffice radar/satellite image(s) URL
date_default_timezone_set('Atlantic/Azores'); //image timestamp lags 1hr
$YmdH = date("YmdH");
$Ymd = date("Ymd");
$hcorrection = time() - 3600;
$hcorrected = date("H",$hcorrection);
$datei = "00" ; 
if (date("i") <= 15) {
$fetchtime = $Ymd.$hcorrected.$datei;
			}
else	{
$fetchtime = $YmdH.$datei;
	}
/*
usage example:
echo "<img src ='http://www.metoffice.gov.uk/weather/images/uk_radar_".$fetchtime.".gif' width=212 height=314>";
*/
//end set URL
Probably the above is schoolboy stuff but I'm 62 and having a go!

Derek
http://sheerwater.info (under construction!!)
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: MetOffice Radar/Satellite Images

Post by daj »

Hi Derek,

Do a quick check on the file size -- if it returns a file size then it has found the image

here's some code....I moved the building of the image URL out to a variable as I use it twice (once to check, and once to get the image).

Code: Select all

$img="http://www.metoffice.gov.uk/weather/images/uk_radar_" .$fetchtime. ".gif";

if (getimagesize($img)) {   
echo "<img src =" . $img . " width=212 height=314>";
}
else
{
echo "No image";
}
As always there are many ways to do this, but this is a simple one to follow (hopefully!)

"No Image" could equally be a holding image of your own
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
212adws
Posts: 6
Joined: Mon 05 Apr 2010 12:24 pm
Weather Station: Maplin N96FY
Operating System: Windows 7
Location: Woking, Surrey, UK
Contact:

Re: MetOffice Radar/Satellite Images

Post by 212adws »

Thanks David. Just the kind of clue I needed!!

Derek
http://www.sheerwater.info
Post Reply