/posts  ·   /talks  ·   /boat  ·   /#30DayMapChallenge 2020 | 2022  ·  /About

2022 / Day 10: BAD

My knowledge of colors and colorspaces is really minimal (if not to say missing completely) so very often you’ll find me using very high-contrast colors to differentiate stuff that has been queried from other stuff that had been queried before. Anyway. Color gradients are not “linear”, but this time around - who cares!

So the query today will generate_series of color hex values between #BAD and #A55 by a step of #001 in integers and convert those to hex again to apply them on a set of concentric point buffers (increasing in size). In order to make it more spaced out, man!!! every disk will have a 01 opacity set to it so we’ll end up with hex code of

#RRGGBBAA

which can be very easily used in QGIS for styling every specific feature.

output image

with
    minmax as (
       select
         1 as oid,
         st_point(
             40500.000000,5993000.000000,3301
         ) as ll,
         st_point(
             1064500.000000,7017000.000000,3301
         ) as ur
    ),
    c as (
        select
            st_centroid(
                st_collect(
                    array[ll,ur]
                )
            ) as geom
        from
            minmax
    ),
    mm as (
        select
            ('x'||'BAD')::bit(24)::int as min,
            ('x'||'A55')::bit(24)::int as max,
            ('x'||'001')::bit(24)::int as step     
    )
    select
        color.radius as oid,
        st_buffer(c.geom, color.radius*10, 'quad_segs=16') as geom,
        '#'||a[1]||a[1]||a[2]||a[2]||a[3]||a[3]||'01' as hex
    from
        c, (
            select
                row_number() over ()::int as radius,
                to_hex(s) as hex
            from
                mm
                    join lateral
                        generate_series(
                            mm.min,
                            mm.max,
                            -1*mm.step
                        ) s on true
        ) color
            join lateral
                regexp_split_to_array(
                    color.hex,
                    ''
                ) a on true
    order by
        color.radius desc
;