[postgis-users] Line_interpolate point with multilinestring

Paul Ramsey pramsey at refractions.net
Tue Jun 22 09:51:23 PDT 2004


If you loaded your Tiger from Shape into PostGIS, shp2pgsql will have 
cast everything as a MULTILINESTRING, despite the fact that the data 
might not contain any MULTILINESTRINGs at all. This is an outgrowth of 
the fact that the Shape file format generally declares all lines and 
polygons as multis. You could convert your whole table to a new geometry 
type first using the GeometryN function as dave suggests below (drop 
type contraint, update table ("update road_100_tiger set the_geom = 
geometryn(the_geom,1)"), re-add the constraint), then procede as normal.

P.

Dave Blasby wrote:
> Quoting Scott Ellington <scottellington at comcast.net>:
> 
> 
>>scottell=# select line_interpolate_point(the_geom,0.5) from
>>road_100_tiger ;
>>ERROR:  line_interpolate_point: 1st arg isnt a line
>>
>>I assume this is because my geometry is of type MULTILINESTRING instead
>>of LINESTRING.  Is it possible for me to use my multilinestring data in
>>this function?  If not, my thinking was that perhaps I could extract the
>>LINESTRINGs on the fly.  Is there any built-in functionality to do this?
> 
> select line_interpolate_point(geometryN(the_geom,1),0.5) from
> road_100_tiger ;
> 
> GeometryN( <multi geometry> , n) pulls the nth sub-geometry out of the given 
> MULTI* or GEOMETRYCOLLECTION.


-- 
       __
      /
      | Paul Ramsey
      | Refractions Research
      | Email: pramsey at refractions.net
      | Phone: (250) 885-0632
      \_



More information about the postgis-users mailing list