Raster2pgsql - preserving number of decimal places

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Raster2pgsql - preserving number of decimal places

niconysus

Hello,

 

I’m investigating loading some height data into Postgis as type Raster.

It comes in .asc files and I am using raster2pgsql and psql to load it.

 

I’m running with PostgreSQL 9.5.2 and POSTGIS="2.2.2 r14797".

 

I’ve tried the following raster2pgsql combinations:

raster2pgsql -s 27700 -I -C -M *.asc -F public.test1 > test1.sql

raster2pgsql -I -C -M *.asc -F public. test2 > test2.sql

raster2pgsql -I -M *.asc -F public.test3 > test3.sql

 

After loading with psql I am querying it with this sql:

 

SELECT filename, rid, ST_Value(rast, pt.geom) As val

FROM test3 CROSS JOIN (SELECT st_GeomFromText('POINT(454900 254900)', 0) As geom) As pt

WHERE rid in (221,222,223,224);

 

My problem is that instead of values with 2 decimal places I get 12.

So this query should bring back 145.44 but I get 145.440002441406.

 

Please could you let me know if there is anything I can do to preserve the correct number of DPs?

Any help and advice would greatly appreciated.

 

Regards

Nick

 

 

Registered Office: 7 Abbey Court, Eagle Way, Sowton, Exeter, Devon, EX2 7HY. Registered Number 2892803 Registered in England and Wales. The information contained in this e-mail is confidential and may be subject to legal privilege. If you are not the intended recipient, you must not use, copy, distribute or disclose the e-mail or any part of its contents or take any action in reliance on it. If you have received this e-mail in error, please e-mail the sender by replying to this message. All reasonable precautions have been taken to ensure no viruses are present in this e-mail. Landmark Information Group Limited cannot accept responsibility for loss or damage arising from the use of this e-mail or attachments and recommend that you subject these to your virus checking procedures prior to use.
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: Raster2pgsql - preserving number of decimal places

Mateusz Loskot

On 24 Sep 2016 22:56, "Nick Ward" <[hidden email]> wrote:
>
> SELECT filename, rid, ST_Value(rast, pt.geom) As val

round(ST_Value(...), 2)

--
Mateusz Łoskot


_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: Raster2pgsql - preserving number of decimal places

niconysus

Thank you Mateusz for the suggestion.

I sort of assumed I could do it via the select but was hoping to be able to load the exact values as rounding may not give the correct result.

 

Can anyone let me know what I am doing wrong or if this is just not achievable?

 

Regards

Nick

 

From: postgis-users [mailto:[hidden email]] On Behalf Of Mateusz Loskot
Sent: 24 September 2016 22:11
To: PostGIS Users Discussion <[hidden email]>
Subject: Re: [postgis-users] Raster2pgsql - preserving number of decimal places

 

On 24 Sep 2016 22:56, "Nick Ward" <[hidden email]> wrote:
>
> SELECT filename, rid, ST_Value(rast, pt.geom) As val

round(ST_Value(...), 2)

--
Mateusz Łoskot

Registered Office: 7 Abbey Court, Eagle Way, Sowton, Exeter, Devon, EX2 7HY. Registered Number 2892803 Registered in England and Wales. The information contained in this e-mail is confidential and may be subject to legal privilege. If you are not the intended recipient, you must not use, copy, distribute or disclose the e-mail or any part of its contents or take any action in reliance on it. If you have received this e-mail in error, please e-mail the sender by replying to this message. All reasonable precautions have been taken to ensure no viruses are present in this e-mail. Landmark Information Group Limited cannot accept responsibility for loss or damage arising from the use of this e-mail or attachments and recommend that you subject these to your virus checking procedures prior to use.
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users