I am just trying to create a sample topology using pgrouting. The dataset I am using is simply two crossing line segments (not connected in the middle because in the future I will have over/underpasses and I want to see how this is handled).

However I keep getting this error:

NOTICE:  pgr_createTopology('test_edges', 0.1, 'id', 'geom', 'source', 'target', rows_where := 'true', clean := f)
NOTICE:  Performing checks, please wait .....
NOTICE:  ----> PGR ERROR in pgr_createTopology: Column source not found
HINT:    ----> Check your column name
CONTEXT:  SQL statement "SELECT _pgr_onError(err, reportErrs, fnName,  'Column '|| col ||' not found', ' Check your column name','Column '|| col || ' found')"
PL/pgSQL function _pgr_getcolumnname(text,text,text,integer,text) line 18 at PERFORM
SQL statement "select *                 from _pgr_getColumnName(sname, tname,source,2,fnName)"
PL/pgSQL function pgr_createtopology(text,double precision,text,text,text,text,text,boolean) line 61 at SQL statement
NOTICE:  Unexpected error raise_exception
Total query runtime: 64 msec
1 row retrieved.

The table name is "test_edges" and it has two columns, "id" and "geom". I am using this query:

select pgr_createTopology('test_edges', 0.1, 'id', 'geom');

This is the table I am using:

enter image description here

Does anybody know why this would not work?

  • I'd start with adding both source and target columns to the given table before requesting the topology creation. – Michal Zimmermann Apr 11 '17 at 12:37
  • Thank you @Michal Zimmermann, that was it. I did not realize that the source and target columns needed to already exist in the table. – wfgeo Apr 11 '17 at 12:57

Add source and target columns to your table.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.


For example, see http://workshop.pgrouting.org/2.4.11/en/chapters/topology.html, which shows altering the table to add the source and target columns.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.