2

I need to get 256x256 PNG-image filled with geometry (srid 4326)

For example, geometry which I want to draw:

ST_GeomFromText('MULTILINESTRING((37.44140625 55.7745261452494,37.4434662 55.7756075,37.4463273787924 55.7765730186677),(37.4700392205152 55.7765730186677,37.4774551 55.7754144,37.494278 55.7709729,37.5162506 55.7688486,37.5389099 55.7657584))', 4326)

Empty 256x256 raster (upperleftx = 37.44140625, upperlefty = 55.77657301866769):

ST_SetSRID(ST_MakeEmptyRaster(256, 256, 37.44140625, 55.77657301866769, 0.0001), 4326)

Final query:

select
encode
(
    st_aspng
    (
        st_asraster(
            ST_GeomFromText('MULTILINESTRING((37.44140625 55.7745261452494,37.4434662 55.7756075,37.4463273787924 55.7765730186677),(37.4700392205152 55.7765730186677,37.4774551 55.7754144,37.494278 55.7709729,37.5162506 55.7688486,37.5389099 55.7657584))', 4326),
            ST_SetSRID(ST_MakeEmptyRaster(256, 256, 37.44140625, 55.77657301866769, 0.0001), 4326),
            '8BUI'
        )
    ),'base64'
)

What I want to get (256x256):

(it should be png actually with alpha-channel)

What I get for now (977x110?):

enter image description here

The question is: how can I create 256x256 png-image (with defined upper x/y) filled with geometry (or geometries)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.