An issue I had with osm2pgsql was missing nodes when looking at road ways. It revolved around non ID-ordered data that I was trying to use. This was also an issue in previous posts, I had neglected to use the –slim arguement while importing the data set. To see this in action, I imported Brooklyn, NY data and exported road nodes with –slim and without as shown below:

SQL Command

For both with/out slim arguement the following SQL command was used to output data:

SELECT (dp).path[1] AS region, (dp).path AS index, ST_X(ST_Transform((dp).geom, 4326)) AS lon, ST_Y(ST_Transform((dp).geom, 4326)) AS lat
FROM (SELECT ST_DumpPoints(ST_Collect(way)) AS dp 
FROM planet_osm_line where highway is not null AND 
highway = 'residential' OR highway = 'trunk' OR highway = 'primary' OR highway = 'motorway' OR highway = 'secondary' OR highway = 'tertiary') AS foo
ORDER BY index;

Without Slim

osm2pgsql -S C:\ -c -d gisNoSlim -U postgres -H localhost C:\osm\brooklyn_new-york.osm.pbf

With Slim

osm2pgsql -S C:\ -c -d gisSlim -U postgres -H localhost C:\osm\brooklyn_new-york.osm.pbf

As you can tell, quite a lot of data was missing without using slim.