[postgis-users] PostGIS ST_EuclideanDistance() not working. Wrong upperleftx and y?

1 view
Skip to first unread message

Vitor Sapucaia

unread,
Jun 21, 2017, 4:58:07 AM6/21/17
to postgi...@lists.osgeo.org
Hello guys!

I need help on this question that I've posted on GIS stackexchange:

here is the question:

I'm trying to make this ST_EuclideanDistance() function work, but no success so far. I'm not getting the expected result because the raster seems to be drawn at a wrong location.

Documentation:

https://trac.osgeo.org/postgis/wiki/PostGIS_Raster_SoC_Idea_2012/Distance_Analysis_Tools

Firstly, I'm considering this test page to test the function:

https://trac.osgeo.org/postgis/wiki/PostGIS_Raster_SoC_Idea_2012/Distance_Analysis_Tools/test

When running the second test case:

CREATE TABLE test_source_raster_1 AS 
SELECT 
    1 AS rid, rast 
  FROM 
    (SELECT 
       ST_MakeEmptyRaster(10,10,0,0,1,1,0,0,4326) AS rast
     ) foo;
CREATE TABLE test_source_geometry_1 AS 
SELECT 
    generate_series(1,10) AS id,
    ST_RandomPoints(the_geom,10) AS the_geom 
  FROM 
    (SELECT 
       ST_SetSRID(ST_Extent(rast::geometry), 4326) AS the_geom 
    FROM test_source_raster_1) foo;
CREATE TABLE test_ref_raster_1 AS 
SELECT 
  1 AS rid, rast 
  FROM 
    (SELECT 
       ST_MakeEmptyRaster(10,10,0,0,1,1,0,0,4326) AS rast
    ) foo;
 CREATE TABLE test_eudist_1_a_i_1 AS 
   (SELECT 
      1 AS rid,
      ST_EuclideanDistance(
         rast,'32BF','public',                    
         'test_source_geometry_1', 'the_geom', True
       ) AS rast 
     FROM test_ref_raster_1);

I'm getting this result (every raster pixel is null):

results

And this is the expected result I should have gotten: 

expected

Pierre Racine

unread,
Jun 22, 2017, 1:54:32 PM6/22/17
to PostGIS Users Discussion

Try setting the ST_MakeEmptyRaster() upperlefty parameter to a negative value (-1).

 

Pierre

 

De : postgis-users [mailto:postgis-us...@lists.osgeo.org] De la part de Vitor Sapucaia
Envoyé : 21 juin 2017 04:58
À : postgi...@lists.osgeo.org
Objet : [postgis-users] PostGIS ST_EuclideanDistance() not working. Wrong upperleftx and y?

Reply all
Reply to author
Forward
0 new messages