Line_interpolate point with multilinestring

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

Line_interpolate point with multilinestring

Scott Ellington
Greetings all,

I have just compiled the newest version of PostGIS (8.2) to test out the
line_interpolate_point function.  I am interested in using this for
geocoding, but when I try to use this function against my tiger data I
get the following:

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?

thanks in advance,

Scott Ellington



Reply | Threaded
Open this post in threaded view
|

Re: Line_interpolate point with multilinestring

David Blasby-3
Quoting Scott Ellington <[hidden email]>:

> 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.

dave



Reply | Threaded
Open this post in threaded view
|

Re: Line_interpolate point with multilinestring

Paul Ramsey-2
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 <[hidden email]>:
>
>
>>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: [hidden email]
      | Phone: (250) 885-0632
      \_

Reply | Threaded
Open this post in threaded view
|

Re: Line_interpolate point with multilinestring

Scott Ellington
Great advice guys.  I went ahead and updated my tiger data to LINESTRING
as you suggested.  No since in running geometryN on the fly if there is
no need to.

thanks again,
Scott Ellington

On Tue, 2004-06-22 at 12:51, Paul Ramsey wrote:

> 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 <[hidden email]>:
> >
> >
> >>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.
>