Raster tile size impact results

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

Raster tile size impact results

Pierre Bails
Hi all,

I'm looking for get all pixel's value in a raster insert thanks to raster2pgsql intersect by a polygon. 
Nevertheless, there are some things that I don't understand: depends on tile size, I don't have the same result... The error between 2 raster is also correlate to the pixel size (I assume it's due to the pixel number).

Can you explain me how the tile size can influence the final result ?

Here is the query :
SELECT DISTINCT SUM((px).val)
FROM(
  SELECT *
  FROM  mns INNER JOIN  st_setsrid(st_geomfromgeojson('{"type":"Polygon","coordinates":[[[x,y],[x,y],[x,y] ]]}'), 4326) as geom on ST_Intersects(mns.rast, geom)
) AS clip, ST_PixelAsCentroids (ST_Clip(clip.rast, clip.geom),1) AS px;

DSM px size 70cm: 
raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable (result: 46 347 846)
raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 46 382 873
Difference: 35027

DSM px size 20cm : 
raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable :  567 505 888 
raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 596 897 610
Difference: 29 391 722 
   
If we considere 250x250's result as reference, there is a difference of 0.07% in the first case, and 5% in the second. If the polygon area increases, the error rate increases.

Thank you,

Pierre

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

Re: Raster tile size impact results

Pierre Racine-2
I would try to understand, visually using OpenJump, how your tiles are clipped in the two cases... I guess sometimes 1 pixel wide tiles get clipped in a strange way.

Pierre

> -----Original Message-----
> From: postgis-users [mailto:[hidden email]] On Behalf
> Of Pierre Bails
> Sent: Wednesday, June 15, 2016 11:41 AM
> To: [hidden email]
> Subject: [postgis-users] Raster tile size impact results
>
> Hi all,
>
> I'm looking for get all pixel's value in a raster insert thanks to raster2pgsql
> intersect by a polygon.
> Nevertheless, there are some things that I don't understand: depends on tile
> size, I don't have the same result... The error between 2 raster is also correlate
> to the pixel size (I assume it's due to the pixel number).
>
> Can you explain me how the tile size can influence the final result ?
>
> Here is the query :
> SELECT DISTINCT SUM((px).val)
> FROM(
>   SELECT *
>   FROM  mns INNER JOIN
> st_setsrid(st_geomfromgeojson('{"type":"Polygon","coordinates":[[[x,y],[x,y],[x
> ,y] ]]}'), 4326) as geom on ST_Intersects(mns.rast, geom)
> ) AS clip, ST_PixelAsCentroids (ST_Clip(clip.rast, clip.geom),1) AS px;
>
>
> DSM px size 70cm:
> raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable (result: 46 347
> 846)
>
> raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 46 382 873
> Difference: 35027
>
>
> DSM px size 20cm :
> raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable :  567 505 888
>
> raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 596 897 610
> Difference: 29 391 722
>
>
> If we considere 250x250's result as reference, there is a difference of 0.07% in
> the first case, and 5% in the second. If the polygon area increases, the error rate
> increases.
>
> Thank you,
>
> Pierre
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: Raster tile size impact results

Pierre Bails
Hello,

Unfortunatly, I don't find a way to print raster results in OpenJump. Can you explain me how I can do it ? 

Thank you for your help !

Pierre

Le lun. 20 juin 2016 à 16:16, Pierre Racine <[hidden email]> a écrit :
I would try to understand, visually using OpenJump, how your tiles are clipped in the two cases... I guess sometimes 1 pixel wide tiles get clipped in a strange way.

Pierre

> -----Original Message-----
> From: postgis-users [mailto:[hidden email]] On Behalf
> Of Pierre Bails
> Sent: Wednesday, June 15, 2016 11:41 AM
> To: [hidden email]
> Subject: [postgis-users] Raster tile size impact results
>
> Hi all,
>
> I'm looking for get all pixel's value in a raster insert thanks to raster2pgsql
> intersect by a polygon.
> Nevertheless, there are some things that I don't understand: depends on tile
> size, I don't have the same result... The error between 2 raster is also correlate
> to the pixel size (I assume it's due to the pixel number).
>
> Can you explain me how the tile size can influence the final result ?
>
> Here is the query :
> SELECT DISTINCT SUM((px).val)
> FROM(
>   SELECT *
>   FROM  mns INNER JOIN
> st_setsrid(st_geomfromgeojson('{"type":"Polygon","coordinates":[[[x,y],[x,y],[x
> ,y] ]]}'), 4326) as geom on ST_Intersects(mns.rast, geom)
> ) AS clip, ST_PixelAsCentroids (ST_Clip(clip.rast, clip.geom),1) AS px;
>
>
> DSM px size 70cm:
> raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable (result: 46 347
> 846)
>
> raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 46 382 873
> Difference: 35027
>
>
> DSM px size 20cm :
> raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable :  567 505 888
>
> raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 596 897 610
> Difference: 29 391 722
>
>
> If we considere 250x250's result as reference, there is a difference of 0.07% in
> the first case, and 5% in the second. If the polygon area increases, the error rate
> increases.
>
> Thank you,
>
> Pierre
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users

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

Re: Raster tile size impact results

Pierre Racine-2
Sorry for the late answer.

You have to vectorize them on the fly from within OpenJump:

SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable;

If your raster is very big and tiled, just vectorize the tiles you need:

SELECT rid, rast::geometry FROM yourrastertable;

Look at the rids and then:

SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable
WHERE rid = x or rid = y

Pierre

> -----Original Message-----
> From: postgis-users [mailto:[hidden email]] On Behalf
> Of Pierre Bails
> Sent: Friday, June 24, 2016 12:32 PM
> To: PostGIS Users Discussion <[hidden email]>
> Subject: Re: [postgis-users] Raster tile size impact results
>
> Hello,
>
> Unfortunatly, I don't find a way to print raster results in OpenJump. Can you
> explain me how I can do it ?
>
> Thank you for your help !
>
> Pierre
>
> Le lun. 20 juin 2016 à 16:16, Pierre Racine <[hidden email]
> <mailto:[hidden email]> > a écrit :
>
>
> I would try to understand, visually using OpenJump, how your tiles are
> clipped in the two cases... I guess sometimes 1 pixel wide tiles get clipped in a
> strange way.
>
> Pierre
>
> > -----Original Message-----
> > From: postgis-users [mailto:[hidden email]
> <mailto:[hidden email]> ] On Behalf
> > Of Pierre Bails
> > Sent: Wednesday, June 15, 2016 11:41 AM
> > To: [hidden email] <mailto:postgis-
> [hidden email]>
> > Subject: [postgis-users] Raster tile size impact results
> >
> > Hi all,
> >
> > I'm looking for get all pixel's value in a raster insert thanks to
> raster2pgsql
> > intersect by a polygon.
> > Nevertheless, there are some things that I don't understand: depends
> on tile
> > size, I don't have the same result... The error between 2 raster is also
> correlate
> > to the pixel size (I assume it's due to the pixel number).
> >
> > Can you explain me how the tile size can influence the final result ?
> >
> > Here is the query :
> > SELECT DISTINCT SUM((px).val)
> > FROM(
> >   SELECT *
> >   FROM  mns INNER JOIN
> >
> st_setsrid(st_geomfromgeojson('{"type":"Polygon","coordinates":[[[x,y],[x,y],[x
> > ,y] ]]}'), 4326) as geom on ST_Intersects(mns.rast, geom)
> > ) AS clip, ST_PixelAsCentroids (ST_Clip(clip.rast, clip.geom),1) AS px;
> >
> >
> > DSM px size 70cm:
> > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable (result:
> 46 347
> > 846)
> >
> > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 46 382
> 873
> > Difference: 35027
> >
> >
> > DSM px size 20cm :
> > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable :  567
> 505 888
> >
> > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 596
> 897 610
> > Difference: 29 391 722
> >
> >
> > If we considere 250x250's result as reference, there is a difference of
> 0.07% in
> > the first case, and 5% in the second. If the polygon area increases, the
> error rate
> > increases.
> >
> > Thank you,
> >
> > Pierre
> _______________________________________________
> postgis-users mailing list
> [hidden email] <mailto:[hidden email]>
> http://lists.osgeo.org/mailman/listinfo/postgis-users

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

Re: Raster tile size impact results

Pierre Bails
Hi,

Thank you for the tips. 

Well, I don't know why, but the st_clip function doesn't seem work fine. 
After clipping and dumping each pixel as point, some points follow tiles, others follow the geometry. Any idea why ?
For now, to avoid the problem, I apply a St_ContainsProperly after the dump.

pasted1
Red : geometry
Light blue : tiles
Dark blue : pixels as points

Thank you for your help !

Pierre 

--
Pierre Bails
GIS Engineer

Redbird
EMEA - 16, rue de la Comète - 75007 Paris - France
US - 44 Tehama St, San Francisco, CA 94105 - USA
Mobile: +33 677 375 851 | US Office: +1 415 366 0191 FR Office: +33 184 165 201

Le ven. 15 juil. 2016 à 17:28, Pierre Racine <[hidden email]> a écrit :
Sorry for the late answer.

You have to vectorize them on the fly from within OpenJump:

SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable;

If your raster is very big and tiled, just vectorize the tiles you need:

SELECT rid, rast::geometry FROM yourrastertable;

Look at the rids and then:

SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable
WHERE rid = x or rid = y

Pierre

> -----Original Message-----
> From: postgis-users [mailto:[hidden email]] On Behalf
> Of Pierre Bails
> Sent: Friday, June 24, 2016 12:32 PM
> To: PostGIS Users Discussion <[hidden email]>
> Subject: Re: [postgis-users] Raster tile size impact results
>
> Hello,
>
> Unfortunatly, I don't find a way to print raster results in OpenJump. Can you
> explain me how I can do it ?
>
> Thank you for your help !
>
> Pierre
>
> Le lun. 20 juin 2016 à 16:16, Pierre Racine <[hidden email]
> <mailto:[hidden email]> > a écrit :
>
>
>       I would try to understand, visually using OpenJump, how your tiles are
> clipped in the two cases... I guess sometimes 1 pixel wide tiles get clipped in a
> strange way.
>
>       Pierre
>
>       > -----Original Message-----
>       > From: postgis-users [mailto:[hidden email]
> <mailto:[hidden email]> ] On Behalf
>       > Of Pierre Bails
>       > Sent: Wednesday, June 15, 2016 11:41 AM
>       > To: [hidden email] <mailto:[hidden email]
> [hidden email]>
>       > Subject: [postgis-users] Raster tile size impact results
>       >
>       > Hi all,
>       >
>       > I'm looking for get all pixel's value in a raster insert thanks to
> raster2pgsql
>       > intersect by a polygon.
>       > Nevertheless, there are some things that I don't understand: depends
> on tile
>       > size, I don't have the same result... The error between 2 raster is also
> correlate
>       > to the pixel size (I assume it's due to the pixel number).
>       >
>       > Can you explain me how the tile size can influence the final result ?
>       >
>       > Here is the query :
>       > SELECT DISTINCT SUM((px).val)
>       > FROM(
>       >   SELECT *
>       >   FROM  mns INNER JOIN
>       >
> st_setsrid(st_geomfromgeojson('{"type":"Polygon","coordinates":[[[x,y],[x,y],[x
>       > ,y] ]]}'), 4326) as geom on ST_Intersects(mns.rast, geom)
>       > ) AS clip, ST_PixelAsCentroids (ST_Clip(clip.rast, clip.geom),1) AS px;
>       >
>       >
>       > DSM px size 70cm:
>       > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable (result:
> 46 347
>       > 846)
>       >
>       > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 46 382
> 873
>       > Difference: 35027
>       >
>       >
>       > DSM px size 20cm :
>       > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable :  567
> 505 888
>       >
>       > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 596
> 897 610
>       > Difference: 29 391 722
>       >
>       >
>       > If we considere 250x250's result as reference, there is a difference of
> 0.07% in
>       > the first case, and 5% in the second. If the polygon area increases, the
> error rate
>       > increases.
>       >
>       > Thank you,
>       >
>       > Pierre
>       _______________________________________________
>       postgis-users mailing list
>       [hidden email] <mailto:[hidden email]>
>       http://lists.osgeo.org/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users

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

Re: Raster tile size impact results

Pierre Bails
In reply to this post by Pierre Racine-2
Hi,

Thank you for the tips. 

Well, I don't know why, but the st_clip function doesn't seem work fine. 
After clipping and dumping each pixel as point, some points follow tiles, others follow the geometry. Any idea why ?
For now, to avoid the problem, I apply a St_ContainsProperly after the dump.

unnamed.png
Red : geometry
Light blue : tiles
Dark blue : pixels as points

Thank you for your help !

Pierre


Le ven. 15 juil. 2016 à 17:28, Pierre Racine <[hidden email]> a écrit :
Sorry for the late answer.

You have to vectorize them on the fly from within OpenJump:

SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable;

If your raster is very big and tiled, just vectorize the tiles you need:

SELECT rid, rast::geometry FROM yourrastertable;

Look at the rids and then:

SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable
WHERE rid = x or rid = y

Pierre

> -----Original Message-----
> From: postgis-users [mailto:[hidden email]] On Behalf
> Of Pierre Bails
> Sent: Friday, June 24, 2016 12:32 PM
> To: PostGIS Users Discussion <[hidden email]>
> Subject: Re: [postgis-users] Raster tile size impact results
>
> Hello,
>
> Unfortunatly, I don't find a way to print raster results in OpenJump. Can you
> explain me how I can do it ?
>
> Thank you for your help !
>
> Pierre
>
> Le lun. 20 juin 2016 à 16:16, Pierre Racine <[hidden email]
> <mailto:[hidden email]> > a écrit :
>
>
>       I would try to understand, visually using OpenJump, how your tiles are
> clipped in the two cases... I guess sometimes 1 pixel wide tiles get clipped in a
> strange way.
>
>       Pierre
>
>       > -----Original Message-----
>       > From: postgis-users [mailto:[hidden email]
> <mailto:[hidden email]> ] On Behalf
>       > Of Pierre Bails
>       > Sent: Wednesday, June 15, 2016 11:41 AM
>       > To: [hidden email] <mailto:[hidden email]
> [hidden email]>
>       > Subject: [postgis-users] Raster tile size impact results
>       >
>       > Hi all,
>       >
>       > I'm looking for get all pixel's value in a raster insert thanks to
> raster2pgsql
>       > intersect by a polygon.
>       > Nevertheless, there are some things that I don't understand: depends
> on tile
>       > size, I don't have the same result... The error between 2 raster is also
> correlate
>       > to the pixel size (I assume it's due to the pixel number).
>       >
>       > Can you explain me how the tile size can influence the final result ?
>       >
>       > Here is the query :
>       > SELECT DISTINCT SUM((px).val)
>       > FROM(
>       >   SELECT *
>       >   FROM  mns INNER JOIN
>       >
> st_setsrid(st_geomfromgeojson('{"type":"Polygon","coordinates":[[[x,y],[x,y],[x
>       > ,y] ]]}'), 4326) as geom on ST_Intersects(mns.rast, geom)
>       > ) AS clip, ST_PixelAsCentroids (ST_Clip(clip.rast, clip.geom),1) AS px;
>       >
>       >
>       > DSM px size 70cm:
>       > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable (result:
> 46 347
>       > 846)
>       >
>       > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 46 382
> 873
>       > Difference: 35027
>       >
>       >
>       > DSM px size 20cm :
>       > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable :  567
> 505 888
>       >
>       > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 596
> 897 610
>       > Difference: 29 391 722
>       >
>       >
>       > If we considere 250x250's result as reference, there is a difference of
> 0.07% in
>       > the first case, and 5% in the second. If the polygon area increases, the
> error rate
>       > increases.
>       >
>       > Thank you,
>       >
>       > Pierre
>       _______________________________________________
>       postgis-users mailing list
>       [hidden email] <mailto:[hidden email]>
>       http://lists.osgeo.org/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users

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

Re: Raster tile size impact results

Pierre Racine-2

I will need to see your last query to try to find the problem.

 

Pierre

 

From: postgis-users [mailto:[hidden email]] On Behalf Of Pierre Bails
Sent: Wednesday, July 20, 2016 5:36 AM
To: PostGIS Users Discussion <[hidden email]>
Subject: Re: [postgis-users] Raster tile size impact results

 

Hi,

 

Thank you for the tips. 

 

Well, I don't know why, but the st_clip function doesn't seem work fine. 

After clipping and dumping each pixel as point, some points follow tiles, others follow the geometry. Any idea why ?

For now, to avoid the problem, I apply a St_ContainsProperly after the dump.

 

unnamed.png

Red : geometry

Light blue : tiles

Dark blue : pixels as points

 

Thank you for your help !

 

Pierre

 

 

Le ven. 15 juil. 2016 à 17:28, Pierre Racine <[hidden email]> a écrit :

Sorry for the late answer.

You have to vectorize them on the fly from within OpenJump:

SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable;

If your raster is very big and tiled, just vectorize the tiles you need:

SELECT rid, rast::geometry FROM yourrastertable;

Look at the rids and then:

SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable
WHERE rid = x or rid = y

Pierre

> -----Original Message-----
> From: postgis-users [mailto:[hidden email]] On Behalf
> Of Pierre Bails
> Sent: Friday, June 24, 2016 12:32 PM
> To: PostGIS Users Discussion <[hidden email]>
> Subject: Re: [postgis-users] Raster tile size impact results
>
> Hello,
>
> Unfortunatly, I don't find a way to print raster results in OpenJump. Can you
> explain me how I can do it ?
>
> Thank you for your help !
>
> Pierre
>
> Le lun. 20 juin 2016 à 16:16, Pierre Racine <[hidden email]
> <mailto:[hidden email]> > a écrit :
>
>
>       I would try to understand, visually using OpenJump, how your tiles are
> clipped in the two cases... I guess sometimes 1 pixel wide tiles get clipped in a
> strange way.
>
>       Pierre
>
>       > -----Original Message-----
>       > From: postgis-users [mailto:[hidden email]
> <mailto:[hidden email]> ] On Behalf
>       > Of Pierre Bails
>       > Sent: Wednesday, June 15, 2016 11:41 AM
>       > To: [hidden email] <mailto:[hidden email]
> [hidden email]>
>       > Subject: [postgis-users] Raster tile size impact results
>       >
>       > Hi all,
>       >
>       > I'm looking for get all pixel's value in a raster insert thanks to
> raster2pgsql
>       > intersect by a polygon.
>       > Nevertheless, there are some things that I don't understand: depends
> on tile
>       > size, I don't have the same result... The error between 2 raster is also
> correlate
>       > to the pixel size (I assume it's due to the pixel number).
>       >
>       > Can you explain me how the tile size can influence the final result ?
>       >
>       > Here is the query :
>       > SELECT DISTINCT SUM((px).val)
>       > FROM(
>       >   SELECT *
>       >   FROM  mns INNER JOIN
>       >
> st_setsrid(st_geomfromgeojson('{"type":"Polygon","coordinates":[[[x,y],[x,y],[x
>       > ,y] ]]}'), 4326) as geom on ST_Intersects(mns.rast, geom)
>       > ) AS clip, ST_PixelAsCentroids (ST_Clip(clip.rast, clip.geom),1) AS px;
>       >
>       >
>       > DSM px size 70cm:
>       > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable (result:
> 46 347
>       > 846)
>       >
>       > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 46 382
> 873
>       > Difference: 35027
>       >
>       >
>       > DSM px size 20cm :
>       > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable :  567
> 505 888
>       >
>       > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 596
> 897 610
>       > Difference: 29 391 722
>       >
>       >
>       > If we considere 250x250's result as reference, there is a difference of
> 0.07% in
>       > the first case, and 5% in the second. If the polygon area increases, the
> error rate
>       > increases.
>       >
>       > Thank you,
>       >
>       > Pierre
>       _______________________________________________
>       postgis-users mailing list
>       [hidden email] <mailto:[hidden email]>
>       http://lists.osgeo.org/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users


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

Re: Raster tile size impact results

Pierre Bails
Hi,

The full request is :

SELECT DISTINCT ST_AsGeojson(ST_Union((px.geom),4326))
FROM (
  SELECT *
  FROM dsm
    INNER JOIN ST_SetSRID(ST_MakeValid(ST_GeomFromGeojson('{"type":"Polygon","coordinates":[[[],[],[],[],[],[]]]}')), 4326) AS geom on ST_Intersects(dsm.rast, geom)
) AS inter,
ST_PixelAsCentroids (ST_Clip(ST_Rescale(inter.rast, 0.5), inter.geom),1) as px

Thanks,

Pierre

--
Pierre Bails
GIS Engineer

Redbird
EMEA - 16, rue de la Comète - 75007 Paris - France
US - 44 Tehama St, San Francisco, CA 94105 - USA
Mobile: +33 677 375 851 | US Office: +1 415 366 0191 FR Office: +33 184 165 201

Le lun. 25 juil. 2016 à 21:30, Pierre Racine <[hidden email]> a écrit :

I will need to see your last query to try to find the problem.

 

Pierre

 

From: postgis-users [mailto:[hidden email]] On Behalf Of Pierre Bails
Sent: Wednesday, July 20, 2016 5:36 AM


To: PostGIS Users Discussion <[hidden email]>
Subject: Re: [postgis-users] Raster tile size impact results

 

Hi,

 

Thank you for the tips. 

 

Well, I don't know why, but the st_clip function doesn't seem work fine. 

After clipping and dumping each pixel as point, some points follow tiles, others follow the geometry. Any idea why ?

For now, to avoid the problem, I apply a St_ContainsProperly after the dump.

 


Red : geometry

Light blue : tiles

Dark blue : pixels as points

 

Thank you for your help !

 

Pierre

 

 

Le ven. 15 juil. 2016 à 17:28, Pierre Racine <[hidden email]> a écrit :

Sorry for the late answer.

You have to vectorize them on the fly from within OpenJump:

SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable;

If your raster is very big and tiled, just vectorize the tiles you need:

SELECT rid, rast::geometry FROM yourrastertable;

Look at the rids and then:

SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable
WHERE rid = x or rid = y

Pierre

> -----Original Message-----
> From: postgis-users [mailto:[hidden email]] On Behalf
> Of Pierre Bails
> Sent: Friday, June 24, 2016 12:32 PM
> To: PostGIS Users Discussion <[hidden email]>
> Subject: Re: [postgis-users] Raster tile size impact results
>
> Hello,
>
> Unfortunatly, I don't find a way to print raster results in OpenJump. Can you
> explain me how I can do it ?
>
> Thank you for your help !
>
> Pierre
>
> Le lun. 20 juin 2016 à 16:16, Pierre Racine <[hidden email]
> <mailto:[hidden email]> > a écrit :
>
>
>       I would try to understand, visually using OpenJump, how your tiles are
> clipped in the two cases... I guess sometimes 1 pixel wide tiles get clipped in a
> strange way.
>
>       Pierre
>
>       > -----Original Message-----
>       > From: postgis-users [mailto:[hidden email]
> <mailto:[hidden email]> ] On Behalf
>       > Of Pierre Bails
>       > Sent: Wednesday, June 15, 2016 11:41 AM
>       > To: [hidden email] <mailto:[hidden email]
> [hidden email]>
>       > Subject: [postgis-users] Raster tile size impact results
>       >
>       > Hi all,
>       >
>       > I'm looking for get all pixel's value in a raster insert thanks to
> raster2pgsql
>       > intersect by a polygon.
>       > Nevertheless, there are some things that I don't understand: depends
> on tile
>       > size, I don't have the same result... The error between 2 raster is also
> correlate
>       > to the pixel size (I assume it's due to the pixel number).
>       >
>       > Can you explain me how the tile size can influence the final result ?
>       >
>       > Here is the query :
>       > SELECT DISTINCT SUM((px).val)
>       > FROM(
>       >   SELECT *
>       >   FROM  mns INNER JOIN
>       >
> st_setsrid(st_geomfromgeojson('{"type":"Polygon","coordinates":[[[x,y],[x,y],[x
>       > ,y] ]]}'), 4326) as geom on ST_Intersects(mns.rast, geom)
>       > ) AS clip, ST_PixelAsCentroids (ST_Clip(clip.rast, clip.geom),1) AS px;
>       >
>       >
>       > DSM px size 70cm:
>       > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable (result:
> 46 347
>       > 846)
>       >
>       > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 46 382
> 873
>       > Difference: 35027
>       >
>       >
>       > DSM px size 20cm :
>       > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff dsmTable :  567
> 505 888
>       >
>       > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff dsmTable    : 596
> 897 610
>       > Difference: 29 391 722
>       >
>       >
>       > If we considere 250x250's result as reference, there is a difference of
> 0.07% in
>       > the first case, and 5% in the second. If the polygon area increases, the
> error rate
>       > increases.
>       >
>       > Thank you,
>       >
>       > Pierre
>       _______________________________________________
>       postgis-users mailing list
>       [hidden email] <mailto:[hidden email]>
>       http://lists.osgeo.org/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users

image001.png (72K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Raster tile size impact results

Pierre Racine-2
What if you remove the ST_Rescale() ?

> -----Original Message-----
> From: postgis-users [mailto:[hidden email]] On Behalf
> Of Pierre Bails
> Sent: Thursday, July 28, 2016 4:28 AM
> To: PostGIS Users Discussion <[hidden email]>
> Subject: Re: [postgis-users] Raster tile size impact results
>
> Hi,
>
> The full request is :
>
> SELECT DISTINCT ST_AsGeojson(ST_Union((px.geom),4326))
> FROM (
>   SELECT *
>   FROM dsm
>     INNER JOIN
> ST_SetSRID(ST_MakeValid(ST_GeomFromGeojson('{"type":"Polygon","coordinat
> es":[[[],[],[],[],[],[]]]}')), 4326) AS geom on ST_Intersects(dsm.rast, geom)
> ) AS inter,
> ST_PixelAsCentroids (ST_Clip(ST_Rescale(inter.rast, 0.5), inter.geom),1) as px
>
>
> Thanks,
>
> Pierre
>
> --
>
> Pierre Bails
> GIS Engineer
>
>
> Redbird
> EMEA - 16, rue de la Comète - 75007 Paris - France
> US - 44 Tehama St, San Francisco, CA 94105 - USA
> Mobile: +33 677 375 851 | US Office: +1 415 366 0191 | FR Office: +33 184 165
> 201
>
> [hidden email] <mailto:[hidden email]>  | www.getredbird.com
> <http://www.getredbird.com/>  | Facebook
> <https://www.facebook.com/redbird.drones>  | Twitter
> <https://twitter.com/redbirdHQ>  | Youtube
> <https://www.youtube.com/channel/UC9ab5NnNorfVcRdynbTzSLw/videos>
>
> Le lun. 25 juil. 2016 à 21:30, Pierre Racine <[hidden email]
> <mailto:[hidden email]> > a écrit :
>
>
> I will need to see your last query to try to find the problem.
>
>
>
> Pierre
>
>
>
> From: postgis-users [mailto:[hidden email]
> <mailto:[hidden email]> ] On Behalf Of Pierre Bails
> Sent: Wednesday, July 20, 2016 5:36 AM
>
>
> To: PostGIS Users Discussion <[hidden email]
> <mailto:[hidden email]> >
> Subject: Re: [postgis-users] Raster tile size impact results
>
>
>
> Hi,
>
>
>
> Thank you for the tips.
>
>
>
> Well, I don't know why, but the st_clip function doesn't seem work fine.
>
> After clipping and dumping each pixel as point, some points follow tiles,
> others follow the geometry. Any idea why ?
>
> For now, to avoid the problem, I apply a St_ContainsProperly after the
> dump.
>
>
>
>
>
>
> Red : geometry
>
> Light blue : tiles
>
> Dark blue : pixels as points
>
>
>
> Thank you for your help !
>
>
>
> Pierre
>
>
>
>
>
> Le ven. 15 juil. 2016 à 17:28, Pierre Racine <[hidden email]
> <mailto:[hidden email]> > a écrit :
>
> Sorry for the late answer.
>
> You have to vectorize them on the fly from within OpenJump:
>
> SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable;
>
> If your raster is very big and tiled, just vectorize the tiles you
> need:
>
> SELECT rid, rast::geometry FROM yourrastertable;
>
> Look at the rids and then:
>
> SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable
> WHERE rid = x or rid = y
>
> Pierre
>
> > -----Original Message-----
> > From: postgis-users [mailto:postgis-users-
> [hidden email] <mailto:[hidden email]> ] On
> Behalf
> > Of Pierre Bails
> > Sent: Friday, June 24, 2016 12:32 PM
> > To: PostGIS Users Discussion <[hidden email]
> <mailto:[hidden email]> >
> > Subject: Re: [postgis-users] Raster tile size impact results
> >
> > Hello,
> >
> > Unfortunatly, I don't find a way to print raster results in
> OpenJump. Can you
> > explain me how I can do it ?
> >
> > Thank you for your help !
> >
> > Pierre
> >
> > Le lun. 20 juin 2016 à 16:16, Pierre Racine
> <[hidden email] <mailto:[hidden email]>
> > <mailto:[hidden email]
> <mailto:[hidden email]> > > a écrit :
> >
> >
> >       I would try to understand, visually using OpenJump, how
> your tiles are
> > clipped in the two cases... I guess sometimes 1 pixel wide tiles
> get clipped in a
> > strange way.
> >
> >       Pierre
> >
> >       > -----Original Message-----
> >       > From: postgis-users [mailto:postgis-users-
> [hidden email] <mailto:[hidden email]>
> > <mailto:[hidden email]
> <mailto:[hidden email]> > ] On Behalf
> >       > Of Pierre Bails
> >       > Sent: Wednesday, June 15, 2016 11:41 AM
> >       > To: [hidden email] <mailto:postgis-
> [hidden email]>  <mailto:postgis- <mailto:postgis->
> > [hidden email] <mailto:[hidden email]> >
> >       > Subject: [postgis-users] Raster tile size impact results
> >       >
> >       > Hi all,
> >       >
> >       > I'm looking for get all pixel's value in a raster insert
> thanks to
> > raster2pgsql
> >       > intersect by a polygon.
> >       > Nevertheless, there are some things that I don't
> understand: depends
> > on tile
> >       > size, I don't have the same result... The error between 2
> raster is also
> > correlate
> >       > to the pixel size (I assume it's due to the pixel number).
> >       >
> >       > Can you explain me how the tile size can influence the
> final result ?
> >       >
> >       > Here is the query :
> >       > SELECT DISTINCT SUM((px).val)
> >       > FROM(
> >       >   SELECT *
> >       >   FROM  mns INNER JOIN
> >       >
> >
> st_setsrid(st_geomfromgeojson('{"type":"Polygon","coordinates":[[[x,y],[x,y],[x
> >       > ,y] ]]}'), 4326) as geom on ST_Intersects(mns.rast, geom)
> >       > ) AS clip, ST_PixelAsCentroids (ST_Clip(clip.rast,
> clip.geom),1) AS px;
> >       >
> >       >
> >       > DSM px size 70cm:
> >       > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff
> dsmTable (result:
> > 46 347
> >       > 846)
> >       >
> >       > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff
> dsmTable    : 46 382
> > 873
> >       > Difference: 35027
> >       >
> >       >
> >       > DSM px size 20cm :
> >       > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff
> dsmTable :  567
> > 505 888
> >       >
> >       > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff
> dsmTable    : 596
> > 897 610
> >       > Difference: 29 391 722
> >       >
> >       >
> >       > If we considere 250x250's result as reference, there is a
> difference of
> > 0.07% in
> >       > the first case, and 5% in the second. If the polygon area
> increases, the
> > error rate
> >       > increases.
> >       >
> >       > Thank you,
> >       >
> >       > Pierre
> >       _______________________________________________
> >       postgis-users mailing list
> >       [hidden email] <mailto:postgis-
> [hidden email]>  <mailto:[hidden email] <mailto:postgis-
> [hidden email]> >
> >       http://lists.osgeo.org/mailman/listinfo/postgis-users
>
> _______________________________________________
> postgis-users mailing list
> [hidden email] <mailto:postgis-
> [hidden email]>
> http://lists.osgeo.org/mailman/listinfo/postgis-users
>
> _______________________________________________
> postgis-users mailing list
> [hidden email] <mailto:[hidden email]>
> http://lists.osgeo.org/mailman/listinfo/postgis-users

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

Re: Raster tile size impact results

Pierre Bails
Hi Pierre,

I have the same problem with or without the rescale function...


--
Pierre Bails


Le mar. 9 août 2016 à 14:30, Pierre Racine <[hidden email]> a écrit :
What if you remove the ST_Rescale() ?

> -----Original Message-----
> From: postgis-users [mailto:[hidden email]] On Behalf
> Of Pierre Bails
> Sent: Thursday, July 28, 2016 4:28 AM
> To: PostGIS Users Discussion <[hidden email]>
> Subject: Re: [postgis-users] Raster tile size impact results
>
> Hi,
>
> The full request is :
>
> SELECT DISTINCT ST_AsGeojson(ST_Union((px.geom),4326))
> FROM (
>   SELECT *
>   FROM dsm
>     INNER JOIN
> ST_SetSRID(ST_MakeValid(ST_GeomFromGeojson('{"type":"Polygon","coordinat
> es":[[[],[],[],[],[],[]]]}')), 4326) AS geom on ST_Intersects(dsm.rast, geom)
> ) AS inter,
> ST_PixelAsCentroids (ST_Clip(ST_Rescale(inter.rast, 0.5), inter.geom),1) as px
>
>
> Thanks,
>
> Pierre
>
> --
>
> Pierre Bails
> GIS Engineer
>
>
> Redbird
> EMEA - 16, rue de la Comète - 75007 Paris - France
> US - 44 Tehama St, San Francisco, CA 94105 - USA
> Mobile: +33 677 375 851 | US Office: +1 415 366 0191 | FR Office: +33 184 165
> 201
>
> [hidden email] <mailto:[hidden email]>  | www.getredbird.com
> <http://www.getredbird.com/>  | Facebook
> <https://www.facebook.com/redbird.drones>  | Twitter
> <https://twitter.com/redbirdHQ>  | Youtube
> <https://www.youtube.com/channel/UC9ab5NnNorfVcRdynbTzSLw/videos>
>
> Le lun. 25 juil. 2016 à 21:30, Pierre Racine <[hidden email]
> <mailto:[hidden email]> > a écrit :
>
>
>       I will need to see your last query to try to find the problem.
>
>
>
>       Pierre
>
>
>
>       From: postgis-users [mailto:[hidden email]
> <mailto:[hidden email]> ] On Behalf Of Pierre Bails
>       Sent: Wednesday, July 20, 2016 5:36 AM
>
>
>       To: PostGIS Users Discussion <[hidden email]
> <mailto:[hidden email]> >
>       Subject: Re: [postgis-users] Raster tile size impact results
>
>
>
>       Hi,
>
>
>
>       Thank you for the tips.
>
>
>
>       Well, I don't know why, but the st_clip function doesn't seem work fine.
>
>       After clipping and dumping each pixel as point, some points follow tiles,
> others follow the geometry. Any idea why ?
>
>       For now, to avoid the problem, I apply a St_ContainsProperly after the
> dump.
>
>
>
>
>
>
>       Red : geometry
>
>       Light blue : tiles
>
>       Dark blue : pixels as points
>
>
>
>       Thank you for your help !
>
>
>
>       Pierre
>
>
>
>
>
>       Le ven. 15 juil. 2016 à 17:28, Pierre Racine <[hidden email]
> <mailto:[hidden email]> > a écrit :
>
>               Sorry for the late answer.
>
>               You have to vectorize them on the fly from within OpenJump:
>
>               SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable;
>
>               If your raster is very big and tiled, just vectorize the tiles you
> need:
>
>               SELECT rid, rast::geometry FROM yourrastertable;
>
>               Look at the rids and then:
>
>               SELECT (ST_DumpAsPolygons(rast).* FROM yourrastertable
>               WHERE rid = x or rid = y
>
>               Pierre
>
>               > -----Original Message-----
>               > From: postgis-users [mailto:[hidden email]
> [hidden email] <mailto:[hidden email]> ] On
> Behalf
>               > Of Pierre Bails
>               > Sent: Friday, June 24, 2016 12:32 PM
>               > To: PostGIS Users Discussion <[hidden email]
> <mailto:[hidden email]> >
>               > Subject: Re: [postgis-users] Raster tile size impact results
>               >
>               > Hello,
>               >
>               > Unfortunatly, I don't find a way to print raster results in
> OpenJump. Can you
>               > explain me how I can do it ?
>               >
>               > Thank you for your help !
>               >
>               > Pierre
>               >
>               > Le lun. 20 juin 2016 à 16:16, Pierre Racine
> <[hidden email] <mailto:[hidden email]>
>               > <mailto:[hidden email]
> <mailto:[hidden email]> > > a écrit :
>               >
>               >
>               >       I would try to understand, visually using OpenJump, how
> your tiles are
>               > clipped in the two cases... I guess sometimes 1 pixel wide tiles
> get clipped in a
>               > strange way.
>               >
>               >       Pierre
>               >
>               >       > -----Original Message-----
>               >       > From: postgis-users [mailto:[hidden email]
> [hidden email] <mailto:[hidden email]>
>               > <mailto:[hidden email]
> <mailto:[hidden email]> > ] On Behalf
>               >       > Of Pierre Bails
>               >       > Sent: Wednesday, June 15, 2016 11:41 AM
>               >       > To: [hidden email] <mailto:[hidden email]
> [hidden email]>  <mailto:[hidden email] <mailto:[hidden email]>
>               > [hidden email] <mailto:[hidden email]> >
>               >       > Subject: [postgis-users] Raster tile size impact results
>               >       >
>               >       > Hi all,
>               >       >
>               >       > I'm looking for get all pixel's value in a raster insert
> thanks to
>               > raster2pgsql
>               >       > intersect by a polygon.
>               >       > Nevertheless, there are some things that I don't
> understand: depends
>               > on tile
>               >       > size, I don't have the same result... The error between 2
> raster is also
>               > correlate
>               >       > to the pixel size (I assume it's due to the pixel number).
>               >       >
>               >       > Can you explain me how the tile size can influence the
> final result ?
>               >       >
>               >       > Here is the query :
>               >       > SELECT DISTINCT SUM((px).val)
>               >       > FROM(
>               >       >   SELECT *
>               >       >   FROM  mns INNER JOIN
>               >       >
>               >
> st_setsrid(st_geomfromgeojson('{"type":"Polygon","coordinates":[[[x,y],[x,y],[x
>               >       > ,y] ]]}'), 4326) as geom on ST_Intersects(mns.rast, geom)
>               >       > ) AS clip, ST_PixelAsCentroids (ST_Clip(clip.rast,
> clip.geom),1) AS px;
>               >       >
>               >       >
>               >       > DSM px size 70cm:
>               >       > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff
> dsmTable (result:
>               > 46 347
>               >       > 846)
>               >       >
>               >       > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff
> dsmTable    : 46 382
>               > 873
>               >       > Difference: 35027
>               >       >
>               >       >
>               >       > DSM px size 20cm :
>               >       > raster2pgsql -a -t 250x250 -s 4326 -F pathToDSM.tiff
> dsmTable :  567
>               > 505 888
>               >       >
>               >       > raster2pgsql -a -t 50x50 -s 4326 -F pathToDSM.tiff
> dsmTable    : 596
>               > 897 610
>               >       > Difference: 29 391 722
>               >       >
>               >       >
>               >       > If we considere 250x250's result as reference, there is a
> difference of
>               > 0.07% in
>               >       > the first case, and 5% in the second. If the polygon area
> increases, the
>               > error rate
>               >       > increases.
>               >       >
>               >       > Thank you,
>               >       >
>               >       > Pierre
>               >       _______________________________________________
>               >       postgis-users mailing list
>               >       [hidden email] <mailto:[hidden email]
> [hidden email]>  <mailto:[hidden email] <mailto:[hidden email]
> [hidden email]> >
>               >       http://lists.osgeo.org/mailman/listinfo/postgis-users
>
>               _______________________________________________
>               postgis-users mailing list
>               [hidden email] <mailto:[hidden email]
> [hidden email]>
>               http://lists.osgeo.org/mailman/listinfo/postgis-users
>
>       _______________________________________________
>       postgis-users mailing list
>       [hidden email] <mailto:[hidden email]>
>       http://lists.osgeo.org/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users