Symbol 'asterisk' not working with agg

8 views
Skip to first unread message

lobsiger...@gmail.com

unread,
Apr 22, 2022, 3:28:16 AMApr 22
to pytroll
Dear all,

while fixing the 'cities' overlays of PyCoast I noticed that I cannot use symbol 'asterisk' when using agg (it works with pil though). It doesn't work with the 'points' overlays and agg either. There is no error message and no symbol plotted. Has anybody had success using symbol 'asterisk' with agg recently? I'm working under Devuan GNU/Linux.

# Name                   Version         Build                         Channel
pycoast                   1.5.0              pyhd8ed1ab_0       conda-forge
pillow                       9.1.0             py38h0ee0e06_2    conda_forege
aggdraw                  1.3.14           py38h0bf2f78_0     conda-forge


Best regards,
Ernst

David Hoese

unread,
Apr 22, 2022, 8:08:50 AMApr 22
to pyt...@googlegroups.com
Hi Ernst,

This definitely seems like a bug. The method for drawing it exists in
the AGG contour writer:

https://github.com/pytroll/pycoast/blob/42ba82e32251fe48d62af1ebf0ad81d0577d74e4/pycoast/cw_agg.py#L115-L147

But compared to the rectangle and circle/ellipse, this is the only
symbol that doesn't have a dedicated function in the underlying aggdraw
library. I wonder if something is getting messed up with the width and
it is setting some small/fractional width to aggdraw and aggdraw is
deciding to just not draw it at all. Do you have a small example script
(no input data please) that reproduces the issue?

Dave

P.S. I know you have all your other PRs for pycoast and I do plan on
looking at them, I just don't have the time currently. Hoping to get to
them as part of the Pytroll Contributor Week.
> --
> You received this message because you are subscribed to the Google
> Groups "pytroll" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pytroll+u...@googlegroups.com
> <mailto:pytroll+u...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/pytroll/c18d136b-6ac2-4108-8de8-17066187b31fn%40googlegroups.com
> <https://groups.google.com/d/msgid/pytroll/c18d136b-6ac2-4108-8de8-17066187b31fn%40googlegroups.com?utm_medium=email&utm_source=footer>.

lobsiger...@gmail.com

unread,
Apr 22, 2022, 12:13:52 PMApr 22
to pytroll
Hi Dave,

here is your rather small example script. It makes both a pil and an agg image using cw_add_points().

Cheers,
Ernst
asterisk-test.py

David Hoese

unread,
Apr 22, 2022, 12:57:41 PMApr 22
to pyt...@googlegroups.com
Awesome, thank you. Took a really long time but I was able to get it to
work with the following change:

diff --git a/pycoast/cw_agg.py b/pycoast/cw_agg.py
index 040713e..36fee1a 100644
--- a/pycoast/cw_agg.py
+++ b/pycoast/cw_agg.py
@@ -124,25 +124,25 @@ class ContourWriterAGG(ContourWriterBase):
# draw '|'
(x_bm, y_bm) = (x, y - half_ptsize) # bottom middle point
(x_tm, y_tm) = (x, y + half_ptsize) # top middle point
- self._draw_line(draw, [(x_bm, y_bm), (x_tm, y_tm)],
+ self._draw_line(draw, [x_bm, y_bm, x_tm, y_tm],
outline=outline, width=width,
outline_opacity=outline_opacity)
# draw '-'
(x_lm, y_lm) = (x - half_ptsize, y) # left middle point
(x_rm, y_rm) = (x + half_ptsize, y) # right middle point
- self._draw_line(draw, [(x_lm, y_lm), (x_rm, y_rm)],
+ self._draw_line(draw, [x_lm, y_lm, x_rm, y_rm],
outline=outline, width=width,
outline_opacity=outline_opacity)
# draw '/'
(x_bl, y_bl) = (x - half_ptsize, y - half_ptsize) # bottom
left point
(x_tr, y_tr) = (x + half_ptsize, y + half_ptsize) # top right
point
- self._draw_line(draw, [(x_bl, y_bl), (x_tr, y_tr)],
+ self._draw_line(draw, [x_bl, y_bl, x_tr, y_tr],
outline=outline, width=width,
outline_opacity=outline_opacity)
# draw '\'
(x_tl, y_tl) = (x - half_ptsize, y + half_ptsize) # top left
point
(x_br, y_br) = (x + half_ptsize, y - half_ptsize) # bottom
right point
- self._draw_line(draw, [(x_tl, y_tl), (x_br, y_br)],
+ self._draw_line(draw, [x_tl, y_tl, x_br, y_br],
outline=outline, width=width,
outline_opacity=outline_opacity)

Something in aggdraw must assume some kind of structure and it just
silently fails. I think this is probably going to a patch in pycoast as
well as documentation (at the minimum) for aggdraw.

Dave
> <https://groups.google.com/d/msgid/pytroll/c18d136b-6ac2-4108-8de8-17066187b31fn%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/pytroll/c18d136b-6ac2-4108-8de8-17066187b31fn%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "pytroll" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pytroll+u...@googlegroups.com
> <mailto:pytroll+u...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/pytroll/2357dd43-1b48-4ebc-8a69-82d4518756can%40googlegroups.com
> <https://groups.google.com/d/msgid/pytroll/2357dd43-1b48-4ebc-8a69-82d4518756can%40googlegroups.com?utm_medium=email&utm_source=footer>.

lobsiger...@gmail.com

unread,
Apr 22, 2022, 4:12:56 PMApr 22
to pytroll
Thanks for that Dave,

the list in _draw_line() must indeed be [x0, y0, x1, y1]. I now used _draw_poygon() that works the same way.
I added symbols 'triangle',  'star5',  'star6',  'star7'. Works in both pil and agg like a charm. See images below.

Cheers,
Ernst
star7_agg.jpg
triangle_agg.jpg
star5_agg.jpg
star6_agg.jpg
Reply all
Reply to author
Forward
0 new messages