<div dir="ltr">Hi,<br><br>Does this help?<br><a href="https://github.com/postgis/postgis/blob/master/raster/doc/RFC2-WellKnownBinaryFormat">https://github.com/postgis/postgis/blob/master/raster/doc/RFC2-WellKnownBinaryFormat</a><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 22, 2020 at 12:06 AM Felix Schütt <<a href="mailto:felix.schuett@maps4print.com">felix.schuett@maps4print.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I'm currently working to understand the raster format of PostGIS, <br>
especially the binary encoding. Let's say that I have a bunch of binary <br>
data in a file format that raster2pgsql doesn't understand. I have a <br>
program that reads out the raster data of that file and now I want to <br>
insert it into postgis. I have the width and height of the image, the <br>
coordinates of the image corners, the EPSG code and the binary image <br>
data. My question is, how do I construct an SQL query (INSERT or COPY <br>
statement) to insert the data into a table. Using a different file <br>
format, raster2pgsql is able to construct a query like this:<br>
<br>
BEGIN;<br>
CREATE TABLE "n00e010.srtmgl3.hgt" ("rid" serial PRIMARY KEY,"rast" <br>
raster);<br>
INSERT INTO "n00e010.srtmgl3.hgt" ("rast") VALUES ('00100 [... LOTS OF <br>
NUMBERS ...]'::raster);<br>
END;<br>
<br>
However, I don't know how to construct the binary stream in the "LOTS OF <br>
NUMBERS" part. The public documentation <br>
(<a href="https://postgis.net/docs/manual-2.1/RT_reference.html" rel="noreferrer" target="_blank">https://postgis.net/docs/manual-2.1/RT_reference.html</a>) is extremely <br>
sparse on documenting how the binary data is formatted, which is <br>
probably the most important part. What is "scaleX", "scaleY", "ipX", <br>
"ipY" and where do I get them from (and why are they set to 0.5 in the <br>
example)? (Also, if I run the example and try to add the layer in QGIS <br>
2.18, I somehow can't add the raster layer?) Why is the raster data <br>
inserted as a second row, but in the output of raster2pgsql it's just a <br>
single row? Is the header of the binary data always the same or do the <br>
fields change based on the data type? The official docs basically just <br>
say "just use raster2pgsql lol", there is no documentation of how the <br>
binary stream is encoded beyond this single example.<br>
<br>
If I had an 3x3 *signed 16-bit integer* array of bytes (just greyscale), <br>
how would I go about formatting the binary stream so that PostGIS <br>
accepts them and I can display them in QGIS (using PostGIS 3.0.1 and <br>
PostgreSQL 12)? Is there a spec? Where should the image data go and how <br>
is it encoded (especially regarding 16-bit integers instead of 8-bit <br>
ones like in the example)?<br>
<br>
Thanks in advance for any help and thanks for creating PostGIS,<br>
<br>
Felix<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div>Darafei Praliaskouski</div><div>Support me: <a href="http://patreon.com/komzpa" target="_blank">http://patreon.com/komzpa</a></div></div></div></div>