Skip to content

How to convert a table to a geotable of linestrings? #10512

Answered by araichev
araichev asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks heaps, @gforsyth !
That works, and i've put the complete function together below for future readers of this thread.

Follow up question for you: If MakeLine were exposed in Ibis, how should i change my function?

def geometrize_shapes(shapes: ib.Table) -> ib.Table:
    """
    Given a GTFS shapes Ibis table, convert it to a geotable of LineStrings
    and return the result, which will no longer have the columns
    ``'shape_pt_sequence'``, ``'shape_pt_lon'``,
    ``'shape_pt_lat'``, and ``'shape_dist_traveled'``.
    """
    import ibis.expr.datatypes as dt

    @ibis.udf.scalar.builtin
    def ST_MakeLine(*col0) -> dt.LineString:
        ...
        
    return (
        shapes
    …

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@araichev
Comment options

@gforsyth
Comment options

@araichev
Comment options

Answer selected by araichev
Comment options

You must be logged in to vote
3 replies
@gforsyth
Comment options

@araichev
Comment options

@araichev
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants