PostGIS ST_EuclideanDistance() not working. Wrong upperleftx and y?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

PostGIS ST_EuclideanDistance() not working. Wrong upperleftx and y?

Vitor Sapucaia
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


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

Re: PostGIS ST_EuclideanDistance() not working. Wrong upperleftx and y?

Pierre Racine-2

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

 

Pierre

 

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

 

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


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