I am using PostgreSQL with PostGIS to store a large amount of polygons. I want to minimize the space my polygons are taking up in my database and since all the coordinate values of the polygons I am working with only need to be 32 bit integers, I could definitely save space if the EWKB format that PostGIS uses for storage could be shortened down to use 32-bit integers instead of the 64-bit doubles for each coordinate value. Here is where I found the code for the format: https://libgeos.org/specifications/wkb/#extended-wkb (GEOS is apparently a core dependency of PostGIS)
Is it possible for me to go in and edit the few lines of code that currently define doubles to define 32-bit integers instead? If it's possible, how would I be able to access the details of the datatype in order to change it? Also, when I asked ChatGPT about this, it said I would have to create a custom format and convert things from the standard EWKB to my EWKB format. Is that the only solution or is there a way I can just customize my database so that it only stores coordinate values in 32 bit integers?
I have found the GEOS library linked above which details the EWKB format, and I also know that there's an ALTER TYPE command in PostgreSQL, but I'm not sure how to go about altering such a specific part of the geometry datatype / the geometry storage format (EWKB)...
Any insight on this?
EDIT: For clarification, all my data are already all integers, so I am not losing any data by wanting to get rid of the extra 32 bits.
ST_QuantizeCoordinates
ST_QuantizeCoordinates
: danbaston.com/posts/2018/02/15/….