PostGIS – Rows with NULL Geometry or Null After Running PGR_CreateTopology

pgroutingpostgis

After running the code below on a line shapefile that I imported into my postgis database it tells me I have many rows with NULL geometry. I think this might be related to the split with lines operation I performed on it in QGIS before importing. How can this be fixed so that I can run my pgr_Dijkstra properly without error.

SELECT pgr_createTopology('streams', 0.00001, 'geom', 'gid');

NOTICE:  PROCESSING:
NOTICE:  pgr_createTopology('streams', 1e-05, 'geom', 'gid', 'source', 'target', rows_where := 'true', clean := f)
NOTICE:  Performing checks, please wait .....
NOTICE:  Creating Topology, Please wait...
NOTICE:  1000 edges processed
NOTICE:  -------------> TOPOLOGY CREATED FOR  1944 edges
NOTICE:  Rows with NULL geometry or NULL id: 5740
NOTICE:  Vertices table for table public.streams is: public.streams_vertices_pgr
NOTICE:  ----------------------------------------------

Successfully run. Total query runtime: 934 msec.
1 rows affected.

Best Answer

The problem was caused by using the Fix Geometries tool in QGIS after performing the Split with lines operation. It appears the Fix Geometries tool removes the newly formed geometries created by the Split with lines tool causing those edges to have NULL geometries.

Related Question