[postgis-users] Raster + Geometry Intersection

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Mon Feb 27 06:37:43 PST 2012


1) Make sure ST_SRID on the geometries and ST_SRID on the raster give the same result.

2) Use OpenJump to display vector queries from PostGIS and make sure everything align properly.

Pierre

> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-
> bounces at postgis.refractions.net] On Behalf Of Ed Linde
> Sent: Monday, February 27, 2012 9:25 AM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] Raster + Geometry Intersection
> 
> Hi Pierre,
> I used --> /root/postgis-svn/raster/loader/raster2pgsql -s 4326 -t 50x50 -I *.tif
> public.srtm_tiled > elev.sql for the loading. The switch in args did not make a
> difference unfortunately! :( I am pretty sure that the OSM roads geometry used
> SRID = 4326, and I think the arguments I have used to get in the tif files with the
> -s option also is right.
> One warning I got while loading was (maybe it makes sense to you?) :
> 
> /root/postgis-svn/raster/loader/raster2pgsql -s 4326 -t 50x50 -I *.tif
> public.srtm_tiled > elev.sql Processing 1/4: srtm_38_01.tif Processing 2/4:
> srtm_38_02.tif
> WARNING: Different geotransform matrices found in the set of rasters being
> converted to PostGIS raster Processing 3/4: srtm_39_01.tif Processing 4/4:
> srtm_39_02.tif
> 
> I tried loading the rasters and the roads in qgis, but it didn't manage to show
> them together, so I am not sure why its not aligning. I am sure its some sort of
> alignment issue, but do not see where its wrong. I am getting the SRTM files
> from http://gis-lab.info/data/srtm-tif/
> And the OSM road was just the map for Denmark on OSM -->
> http://download.geofabrik.de/osm/europe/
> 
> Is it possible for you to intersect these? I understand you are the author of the
> postgis tutorial that I am trying to follow to achieve the same...hence I ask. :)
> 
> Cheers,
> Ed
> 
> 
> 
> On Mon, Feb 27, 2012 at 2:58 PM, Pierre Racine <Pierre.Racine at sbf.ulaval.ca>
> wrote:
> 
> 
> 
> 
> 	> -----Original Message-----
> 	> From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-
> users-
> 	> bounces at postgis.refractions.net] On Behalf Of Ed Linde
> 	> Sent: Monday, February 27, 2012 7:21 AM
> 	> To: postgis-users at postgis.refractions.net
> 	> Subject: [postgis-users] Raster + Geometry Intersection
> 	>
> 	> Hi,
> 	> I am trying to compute elevations for a road network that I have
> downloaded
> 	> and installed into my pg database using osm2pgsql. I also have loaded
> SRTM tif
> 	> files and they are stored as type RASTER in my table.
> 	> I am now trying to compute an intersection between the SRTM rasters
> and the
> 	> OSM road geometries... with no luck! :( I am following this tutorial -->
> 	> http://trac.osgeo.org/postgis/wiki/WKTRasterTutorial01
> 	> but I think it might be slightly outdated.
> 
> 
> 	The base queries to do the intersection are still valid. Only the uploading
> changed. And not much.
> 
> 
> 	>  SELECT o.osm_id,
> 	>         ST_Intersection(s.rast, o.way)
> 	>  FROM planet_osm_line o,
> 	>       srtm_tiled s
> 	>  WHERE ST_Intersects(s.rast, o.way);
> 	>
> 	> way type -->   way geometry(LineString,900913)
> 	>
> 	> CREATE TABLE public.srtm_tiled
> 	> (
> 	>   rid integer NOT NULL DEFAULT
> nextval('srtm_tiled_rid_seq'::regclass),
> 	>   rast raster,
> 	>   CONSTRAINT srtm_tiled_pkey PRIMARY KEY (rid)
> 	> )
> 	> WITH (
> 	>   OIDS=FALSE
> 	> );
> 	>
> 	> performing the above query returns no rows. So I am not sure what is
> wrong.. or
> 	> if I am doing this query correctly. Is the SRID set differently in the
> raster and
> 	> geometry?
> 
> 
> 	You should do ST_Intersection(o.way , s.rast) instead of
> ST_Intersection(s.rast, o.way). The first operates in the vector world and the
> second in the raster world. Let me know if that makes a difference in terms of
> results.
> 
> 	Are the SRIDs identical? Did you make sure that the raster were loaded
> properly by displaying values with ST_Value() or ST_DumpAsPolygons() or simply
> displaying the raster in QGIS? Does the raster align with the roads properly?
> 
> 
> 	> I also loaded the tif files using the tutorial, but I used the C version not
> the
> 	> python loader because I understand its been deprecated.
> 
> 
> 	Should not make any difference.
> 
> 	Pierre
> 	_______________________________________________
> 	postgis-users mailing list
> 	postgis-users at postgis.refractions.net
> 	http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 




More information about the postgis-users mailing list