Current Weather Conditions Weather Graphic

444 views
Skip to first unread message

Scott Danville

unread,
Sep 24, 2022, 1:00:01 PM9/24/22
to weewx-user
Can WeeWx generate a constantly updated .png graphic to be used on a weather site such as the one shown hear?
If it does not, can this feature be added? 
sticker800_170.png

Tom Keffer

unread,
Sep 24, 2022, 1:08:34 PM9/24/22
to weewx...@googlegroups.com
WeeWX cannot create a PNG graphic like that, at least not out of the box. I suppose one could write a custom report generator to do so.

But, may I ask, why? Why not just use HTML and appropriate icons? It scales better and uses less bandwidth.

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/c4f8ad5a-0fcb-4540-b446-f0938ae2c7c8n%40googlegroups.com.

Scott Danville

unread,
Sep 24, 2022, 1:27:56 PM9/24/22
to weewx-user
I place a current conditions graphic from my station in local weather forecast videos that my students create that can pull graphics directly from the web in real time.  HTML can not be embedded, only .png, .jpg, .gif etc.
I was using Meteotemplate to do so, but unfortunately my school blocked the availability to Meteotemplate as the creator is located in the Czech Republic.

Gerard Cerchio

unread,
Sep 25, 2022, 4:35:46 PM9/25/22
to weewx-user
Hi Scott,
You peaked my curiosity. As far as I know the USA gets along perfectly well with the Czech Republic. If I am not asking too much, what kind of school blocks access to eastern European nations and for what reasons?

vince

unread,
Sep 26, 2022, 2:32:09 AM9/26/22
to weewx-user
It is not unusual for sites to block access to/from certain countries if there are believed to be patterns of attempted attacks from their network address blocks.  Yes, source addresses can be spoofed but if you geolocate addresses blocked by fail2ban etc. there are some definite patterns you can reveal that are rather consistent.

Schools also usually have very limited IT staff so they can tend to block more by default as a perceived safety measure.

vince

unread,
Sep 26, 2022, 2:43:28 AM9/26/22
to weewx-user

Your template spelled ‘Weather’ incorrectly in the top line.

I overlay text on a webcam image via a cron job that reads conditions from a text file weewx writes via my custom skin.  That is not ‘realtime’ but updating every 5 minutes is fast enough for me.

Your beautiful png would be much harder to do but it would likely be possible the same way, but it would take a lot of trial and effort.

Conceptually the same approach would work. Save a file with the data and overlay on a base image. This is a place cron works great on.

Glenn McKechnie

unread,
Sep 26, 2022, 6:30:38 AM9/26/22
to weewx...@googlegroups.com
On 24/09/2022, Scott Danville <scott.d...@gmail.com> wrote:
> Can WeeWx generate a constantly updated .png graphic to be used on a
> weather site such as the one shown hear?
> If it does not, can this feature be added?

That looks similar to the ouput of wxgraphic. A php script that
generates a png file from clientraw.txt. It returns a png file upon a
server request to wxgraphic.php. You obviously still need a web facing
server that can hadle php files, and that's not located in the Czech
Republic.!

https://saratoga-weather.org/wxtemplates/plugins.php
https://saratoga-weather.org/legacy-scripts/wxgraphic_6.3.zip

The files origins are available via the web archive.
https://web.archive.org/web/20130105094954/http://scripts.anolecomputer.com/wxgraphic/


Back in 2018 I was playing around with it and got it working with a
WL_stickertags file which provides suitable data via a cheetah
template, for an australian site.

https://www.australiawx.net/instructions.php

I co-opted that templates output but somethings changed in the
intervening years ... ie:- it needs tweaking to work again.

Interested? If so I'll spend some time on it, it's currently raining so...

--


Cheers
Glenn

rorpi - read only raspberry pi & various weewx addons
https://github.com/glennmckechnie
wxgraphic-063-weewx.png

Glenn McKechnie

unread,
Sep 29, 2022, 12:59:49 AM9/29/22
to weewx-user
A couple of wet days have resulted in a working, WeeWX installable, version of that wxgraphics package (Weather Graphic) I mentioned previously.


The original wxgraphic_6.3 is available as a release, but it isn't fully integrated with wee_extension.
The better and latest version (v0.6.4) is available for download as main.

(added to the weewx/wiki as under Services :  WXgraphic - Weather Graphic: A php driven generator to create a weather graphic image via your web server)





On Monday, 26 September 2022 at 4:30:38 pm UTC+10 Glenn McKechnie wrote:

Scott Danville

unread,
Sep 29, 2022, 12:01:40 PM9/29/22
to weewx-user
First, THANK YOU!!!!! This is awesome.  I cannot tell you how much I appreciate this.
I am having some trouble generating the graphics though.

Installed the weewx extension.  Files exist in /etc/weewx/skins and are generating in /html/weewx/wxgraphic  however I cannot get any weather stickers/banners
PHP_verify.php is all okay with GD enabled.
What might I do to get the graphics generated?
Scott

Steeple Ian

unread,
Sep 29, 2022, 8:26:22 PM9/29/22
to weewx-user
Yes, having the same issue here. PHP 8.1.9 enabled with GD, index.php generated but 0bytes, just a blank rectangle. No obvious clue in the error log.
Ian

Glenn McKechnie

unread,
Sep 29, 2022, 10:11:41 PM9/29/22
to weewx...@googlegroups.com
Hmmm.

A browser request to the wxgraphics directory should get a response.

Mine can be called using the following URL in a browser. (working example)

http://203.213.243.61/weewx/wxgraphic/

which is a short hand way of calling

http://203.213.243.61/weewx/wxgraphic/index.php

either one should work if everything is configured / working correctly.

My web server is already set up for php so I'm not sure if I'm missing
something else. I'd expect the server to work for index.php if the
PHP_verify.php page works, and I'd imagine that Steeple Ians
configuration would be fully php enabled - weather34 if I'm correct?
so...

Just downloaded from the repo and I can confirm that it still works
(for me). I didn't bugger anything up there.

We'll look at everything on your webserver.

Should be 20 files and 3 directories under /html/weewx/wxgraphic

In there are 2 files that we are most concerned with.
config.txt, because we change its values.

then under /html/weewx/wxgraphic/DATA there should be 2 files with the
other important one being wxgraphic_weewx.txt

For example, my wxgraphic_weewx.txt contains...

07:39:00,30/09/22,11.4,8.3,8.3,70.3,6.1,1027.2,Rising
Slowly,11.0,SSE,0.0,13.9,,06:01:57,18:27:40

That's 16 columns, one of which is blank - ,,

If you send me your config.txt and wxgraphic_weewx.txt I should be
able to plug them into my setup and see if they work here. I assume
there have been no edits to skin.conf so I'll ignore that for the
moment.

The html error.log (perhaps /var/log/apache2/error.log ) should have
no additional entries with a default installation, and with
curr_cond_icon = 'no' reset in skin.conf

You can send them to the list or direct to my gmail email address that
should be in the email header.

I'll upload a working wxgraphic_weewx.txt to the repo too. If you have
doubts on yours then fetch that and try it (in the brief window before
it gets overwritten by yours.)

On 30/09/2022, 'Steeple Ian' via weewx-user <weewx...@googlegroups.com> wrote:
> Yes, having the same issue here. PHP 8.1.9 enabled with GD, index.php
> generated but 0bytes, just a blank rectangle. No obvious clue in the error
> log.
> Ian
>
> On Thursday, September 29, 2022 at 2:01:40 PM UTC+2 scott.d...@gmail.com
> wrote:
>
>> First, THANK YOU!!!!! This is awesome. I cannot tell you how much I
>> appreciate this.
>> I am having some trouble generating the graphics though.
>>
>> Installed the weewx extension. Files exist in /etc/weewx/skins and are
>> generating in /html/weewx/wxgraphic however I cannot get any weather
>> stickers/banners
>> PHP_verify.php is all okay with GD enabled.
>> *What might I do to get the graphics generated?*
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to weewx-user+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/e593fe74-f3bc-4d46-8f39-7f67fd81b91fn%40googlegroups.com.

steepleian

unread,
Sep 30, 2022, 6:27:17 AM9/30/22
to weewx...@googlegroups.com
Hi Glen,
Yes you have the right person. Yes I am quite sharp on PHP as you perceived :-)
I am just off on road trip to France with Laptop tucked under my arm. I will have a closer look at the logs when I reach my destination after the weekend.
Cheers
Ian

Sent from my iPhone

> On 30 Sep 2022, at 00:11, Glenn McKechnie <glenn.m...@gmail.com> wrote:
>
> Hmmm.
> To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAAraAzi7eTOjcy%2B%3DwE4RwAkG6fVjsvRiGA6H1b4qUua8AnwCgg%40mail.gmail.com.

Glenn McKechnie

unread,
Sep 30, 2022, 6:40:22 AM9/30/22
to weewx...@googlegroups.com
A road trip! Bonus points.

I've added a troubleshooting section to the README at
https://github.com/glennmckechnie/weewx-WXgraphic

Basically what was outlined in my last message but I've uploaded my
working wxgraphic_weewx.txt and config.txt to the
skins/WXgraphic/examples directory.

I suspect wxgraphic_weewx.txt more than config.txt, but we shall see.

My email address is in the header of skin.conf If you need to send
any files send them there.

an oldman

unread,
Sep 30, 2022, 7:29:28 AM9/30/22
to weewx-user
see if this helps
PHP Version: 8.1.10
weewx 4.8.0 using weewx-sdr driver

wxgraphic_weewx.txt has 08:55:00 AM,09/29/2022,48.8,45.0,45.0,73.8,40.8,30.1,Steady,3.1,ESE,0.0,4.0,,07:40:44,19:27:56
skin.conf curr_cond_icon = 'yes'
php log
[30-Sep-2022 07:11:21 UTC] PHP Warning:  Undefined array key "" in /var/www/html/weewx/wxgraphic/index.php on line 473
[30-Sep-2022 07:11:21 UTC] PHP Fatal error:  Uncaught ValueError: Path cannot be empty in /var/www/html/weewx/wxgraphic/index.php:473
Stack trace:
#0 /var/www/html/weewx/wxgraphic/index.php(473): imagecreatefrompng()
#1 {main}
  thrown in /var/www/html/weewx/wxgraphic/index.php on line 473

now if i change skin.conf curr_cond_icon = 'no' all works

hope this helps

Glenn McKechnie

unread,
Sep 30, 2022, 8:02:08 AM9/30/22
to weewx...@googlegroups.com
That does help. Most definitely!

I get a similar error message but it still generates the image,
regardless of curr_cond_icon setting

What is different is that mine is a Warning, yours is Fatal so it
likely comes down to how strict php is set - in it's ini file

PHP Notice: Undefined index: in
/tmp/var/www/html/weewx/wxgraphic/index.php on line 480
PHP Warning: imagecreatefrompng(): Filename cannot be empty in
/tmp/var/www/html/weewx/wxgraphic/index.php
on line 480

I've had a look at that problem spot before, line 480 - looks like
I'm running with a few extra lines?? - but i couldn't see anything
obvious, and as it was running okay so I left it for later. Mea culpa.

Looks like 'later' has now arrived!

Your wxgraphic_weewx.txt output appears similar. I don't have AM in my
timestamp as I'm running 24hr time. Looks like the script compensates
for it.

So Yes. It could well come down to my /etc/php/7.0/apache2/php.ini
settings masking it.

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_startup_errors = Off
log_errors = On

But that aside, now has become later. I need to investigate and fix it.

In the meantime I'll edit the repo and turn that off, with a note.

Thanks for the heads up.
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to weewx-user+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/5d928a27-d9a1-4604-a934-aed14e368956n%40googlegroups.com.

an oldman

unread,
Sep 30, 2022, 8:58:29 AM9/30/22
to weewx-user
my php.ini is what came in the rpm for fedora 36
; display_errors
;   Default Value: On
;   Development Value: On
;   Production Value: Off

; display_startup_errors
;   Default Value: Off
;   Development Value: On
;   Production Value: Off

; error_reporting
;   Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
;   Development Value: E_ALL
;   Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

; log_errors
;   Default Value: Off
;   Development Value: On
;   Production Value: On

my php logs are in /var/log/php-fpm/www-error.log
that error didn't show up in journalctl or /var/log/messages or /var/log/httpd/error_log

an oldman

unread,
Sep 30, 2022, 9:05:11 AM9/30/22
to weewx-user
forgot i add to the top of index.php
ini_set('display_errors',1);
so it showed up in the browser too

Glenn McKechnie

unread,
Sep 30, 2022, 9:37:03 AM9/30/22
to weewx...@googlegroups.com
Okay.

Pushed a fix for that issue - and hopefully that was the issue!

It retains the ability to display the current condition icons, if they
are available, while ignoring the null field that is currently being
sent.

If that all works without issue, or all remains quiet, I'll roll that
up as release v0.6.4

v0.6.5 is patiently waiting in the queue. It offers the ability to
pick up the units (barom, temp, wind, rain) directly from weewx rather
than entering them by hand into skin.conf.
ie;- the WeeWX way :-)

hesf...@gmail.com

unread,
Sep 30, 2022, 9:53:37 AM9/30/22
to weewx-user
Hallo,

in germany the wxgraphic_weewx.txt.tmpl =  11:50:00,29.09.2022,13,3,12,8,13,3,80,0,9,9,999,0,langsam steigend,11,3, SSW,19,3, 0, 0, ,07:12:09,18:56:45
the error is ',' notation

i have it in wxgraphic.txt.temp and index.php (line 278) from ',' to ";" changed.

now it works

192.168.38.png


Hartmut

an oldman

unread,
Sep 30, 2022, 9:57:13 AM9/30/22
to weewx-user
i ran the config.txt through cheetah as config.txt.tmpl

#raw
......
#end raw
$barom_units = "$unit.label.pressure";
$rain_units = "$unit.label.rain";
$degree_units_type = "$unit_system";
$wind_units = "$unit.label.wind";
#raw
........
#end raw
imagecenteredtext(90, 12, "$station.location", 3, 10, $color2, 0);
#raw
........
#raw

in wxgraphic.php added
if ($degree_units_type === 'us' || $degree_units_type === 'US') {
    $degree_units = ' °F';
} else {
    $degree_units = ' °C';
}
Screenshot from 2022-09-30 04-52-44.png

Glenn McKechnie

unread,
Sep 30, 2022, 10:13:03 AM9/30/22
to weewx...@googlegroups.com
On 30/09/2022, hesf...@gmail.com <hesf...@gmail.com> wrote:
> Hallo,
>
> in germany the wxgraphic_weewx.txt.tmpl =
> 11:50:00,29.09.2022,13,3,12,8,13,3,80,0,9,9,999,0,langsam steigend,11,3,
> SSW,19,3, 0, 0, ,07:12:09,18:56:45
> the error is ',' notation

Well. That is interesting. I wonder how others have dealt with the
decimal separator being a comma - especially in csv files. I assume
that is what's causing the issue?

The simplest solution would seem be to offer a choice early in the
process about the delimiter , but has that always been required?
I had a quick look in the weewx csv file generator but nothing leapt
out there. I need to look harder, or get hit hard with a clue stick.


> i have it in wxgraphic.txt.temp and index.php (line 278) from ',' to ";"
> changed.
>
> now it works

Nice image ;-) That was the farm before the grass fire - we lost 36 of
those magnificent trees - not that you notice in a distance shot. Up
close we miss them - so do the cockatoos.

Great that it is working for you too.

Glenn McKechnie

unread,
Sep 30, 2022, 10:44:36 AM9/30/22
to weewx...@googlegroups.com
On 30/09/2022, an oldman <> wrote:
> i ran the config.txt through cheetah as config.txt.tmpl
>
> #raw
> ......
> #end raw
> $barom_units = "$unit.label.pressure";
> $rain_units = "$unit.label.rain";
> $degree_units_type = "$unit_system";
> $wind_units = "$unit.label.wind";
> #raw
> #raw
>
> in wxgraphic.php added

wxgraphic.php ?

That's an early version. If it's from this repo then you're an early
adopter - no medal, but definitely a 'nod and a tip of the hat' to
you.

If it's not then you're an even earlier adopter ! ;-)

> if ($degree_units_type === 'us' || $degree_units_type === 'US') {
> $degree_units = ' °F';
> } else {
> $degree_units = ' °C';
> }
>


That's a neat way of doing it . I'm pulling them from the
weewx-wxgraphic.txt file but having trouble with the utf-8 for °


> #end raw
> imagecenteredtext(90, 12, "$station.location", 3, 10, $color2, 0);
> #raw

I was avoiding that one as there is a possibility that the string is
too long for the graphic (mine is).
Entering it as an option is a chance to reword it to suit the space.
It could / should be offered as the default value, then overwritten
if desired.

an oldman

unread,
Sep 30, 2022, 11:33:02 AM9/30/22
to weewx-user
it's from saratoga-weather.org Legacy Weather PHP scripts Anole's wxgraphic.php script version 6.3
the only way i found to get past that utf-8 for ° was to move it to the php file
also i used the clientraw.txt file
yes the $station.location was to long for type=avatar, but then i like the banners better

Glenn McKechnie

unread,
Sep 30, 2022, 11:47:40 AM9/30/22
to weewx...@googlegroups.com
On 30/09/2022, an oldman <riderr...@gmail.com> wrote:
> it's from saratoga-weather.org Legacy Weather PHP scripts Anole's
> wxgraphic.php script version 6.3
> the only way i found to get past that utf-8 for ° was to move it to the php
> file

Yeah. I'll give it another go but it's fallen down the list somewhat :-)

> also i used the clientraw.txt file
> yes the $station.location was to long for type=avatar, but then i like the
> banners better

Yep, banners for the win!

Can you send me a clientraw.txt file. It appears you aren't using the
icons but I can see if my changes will still work, and also make
better sense of what the code is referencing.

Thanks In Advance.

an oldman

unread,
Sep 30, 2022, 11:59:29 AM9/30/22
to weewx-user
the clientraw.txt.tmpl is from gjr80 WeeWX-WD skin
take a look at this page it might help https://saratoga-weather.org/wdparser/index.php?site=https%3A%2F%2Fsaratoga-weather.org&submit=Submit
clientraw.txt

Steeple Ian

unread,
Sep 30, 2022, 7:49:07 PM9/30/22
to weewx-user
Hi Glen,
I managed to do a sneaky update on my phone using your latest fix and I am pleased to say it is all working now.
Thanks for the prompt update and keep up the good work.
Cheers,
Ian

hesf...@gmail.com

unread,
Oct 1, 2022, 11:20:31 AM10/1/22
to weewx-user
supplement // Nachtrag

if the values in /wxgraphic/DATA/wxgraphic_weewx.txt  = in format ""13:00:00 01.10.2022 10,1 9,7 10,1 96,0 9,5 998,3 langsam_fallend 11,3 S 4,8 19,3  07:15:41 18:51:55
i.e. with spaces, then the value for windchill or heatindex is wrong
I changed this in config.txt as follows:

Die Werte in wxgraphic_weewx.txt mit Leerzeichen getrennt  und dazu noch als Komma-Werte gespeichert werden
können diese Werte mit Komma und Punkt nicht  verglichen werden, dann ist das Ergebnis  für WindChill und HeatIndex nicht definiert oder falsch
darum habe ich in der config.txt die folgenden Ergänzungen vorgenommen ($windchill_us und $heatindex_us)
Beispiel bei CUSTOM

/******************************************************************************/
/* write_custom: This function writes your values onto a custom 500X80 banner.*/
/*  imagecenteredtext($x, $y, $text, $size, $ttfsize, $color, $angle);        */
/******************************************************************************/
function write_custom() {

  // let's start by defining some global variables that will be passed between
  // functions. This is kind of clunky!
  // NOTE: IF YOU ADD ADDITIONAL COLORS YOU'LL NEED TO ADD THEM HERE TOO!
  global $color1, $color2, $color3, $color4, $color5, $date, $t_ime, $temp,
         $degree_units, $winds, $wind_units, $gust, $raintoday, $rain_units,
         $barom, $barom_units, $baromtrendwords, $dewpt, $humidity, $heatindex,
         $heat_index_threshold, $windchill, $wind_chill_threshold,
         $banner_icon_x, $banner_icon_y, $anti_alias,
         $windchill_us, $heatindex_us;

  // this section does the heat index and wind chill
  // it figures out what to show, wind chill, heatindex or nothing
  // depending upon your settings

  $windchill_us = number_format($windchill, 1, '.', '');
  $heatindex_us = number_format($heatindex, 1, '.', '');

  switch (TRUE){
  // if windchill is <= $wind_chill_threshold we'll output it
  case ($windchill_us <= $wind_chill_threshold):
       $feelslike = "Wind Chill: $windchill$degree_units";
       imagecenteredtext(90, 52, "$feelslike", 2, 8, $color3, 0);
  break;
  // if heat index >= $heat_index_threshold we'll output it
  case ($heatindex_us >= $heat_index_threshold):
       $feelslike = "Heat Idx: $heatindex$degree_units";
       imagecenteredtext(90, 52, "$feelslike", 2, 8, $color1, 0);
  break;
  } // end switch

-------------------------------------------
There is certainly a better way, but for now it works

Gruss
Hartmut

Scott Danville

unread,
Oct 7, 2022, 11:06:07 AM10/7/22
to weewx-user
Added both commas or semicolons and get the following result between variables in wxgraphic_weewx.txt.tmpl
The new default, just a space between variables, renders no graphic.
How do I get the data to fill in the appropriate location in the wxgraphic?
This is what I get with either commas or semicolons between variables in wxgraphic_weewx.txt.tmpl
download.png

Glenn McKechnie

unread,
Oct 7, 2022, 12:41:05 PM10/7/22
to weewx...@googlegroups.com
Hmmm,

v0.6.3 used commas, from v0.6.4 spaces are used.

The latest release is v0.6.6, use that one.

Or direct from the repo which has some minor fixes. (lang file and
README.md tweaked)

What it is doing in that image is showing the first space separated
field for TEMP that it reads from wxgraphic_weewx.txt : ie: the whole
string, as it sees just one long string.

I'll reply offlist and get you to send me some files.


On 07/10/2022, Scott Danville <scott.d...@gmail.com> wrote:
> Added both commas or semicolons and get the following result between
> variables in wxgraphic_weewx.txt.tmpl
> The new default, just a space between variables, renders no graphic.
> *How do I get the data to fill in the appropriate location in the
> wxgraphic?*
> *This is what I get with either commas or semicolons between variables in *
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "weewx-user" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/weewx-user/hUIl3AJjLvs/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> weewx-user+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/3c1809be-8a79-4b86-9a89-cee81610a56fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages