2

When I try running TauDEM's "StreamNet" method including the optional -net flag to create the stream links / channel network as a shapefile, it fails with a lot of errors like:

ERROR 10: Pointer 'hFeat' is NULL in 'OGR_F_SetFieldDouble'.
ERROR 10: Pointer 'hFeat' is NULL in 'OGR_F_SetFieldDouble'.
ERROR 10: Pointer 'hFeat' is NULL in 'OGR_F_SetFieldDouble'.
ERROR 10: Pointer 'hFeat' is NULL in 'OGR_F_SetFieldDouble'.
ERROR 10: Pointer 'hFeat' is NULL in 'OGR_F_SetFieldInteger'.
More than 1000 errors or warnings have been reported. No more will be reported from now.

It looks like there have been some instances of related issues being reported and their fixes being introduced in that code base over time.

Thinking maybe the issue was it was looking for an existing dataset to write to, I tried using QGIS to create an empty shapefile hoping TauDEM might access it and write to it but that failed. (I wasn't surprised, but it was worth a shot.)

The rest of the method outputs are rendered, only the shapefile output fails.

Does anyone know if a different OGR file type will work properly, or if there is a trick to resolve this issue?

1 Answer 1

2

It turns out there is a minor bug in the create shapefile implementation, or depending on how you want to classify it, it could also just be an issue with the StreamNet method's documentation.

When reviewing the third link I cited in the original question, I noticed where one user described a solution..

As a fix, you can change the command line of streamnet by adding one parameter -netlyr to denote the layer name explicitly. This is a workaround solution that has been tested to work.

In the TauDEM documentation, -netlyr is listed as an optional parameter, presumably to pass-in a specific writable layer if writing to an OGR layer collection, like a PostGRES database. (It is of-note to consider that even OGR_SQL, when reading from a shapefile, requires adding the shapefile name, minus the .shp extension as a layer name in the FROM clause.)

So I tried it, and it worked. Simply add both options to the method's calling command:

... -net /path/to/basin_stream_net.shp -netlyr basin_streams_net ...

This is what the commands look like in the context of a complete calling statement, although in this case they are "pp_1_net.shp" and "pp_1_net", respectively..

mpiexec -n 6 ./streamnet -fel /home/elijah/Desktop/DEM-SC/sc_30m_fill.tif -p /home/elijah/Desktop/DEM-SC/sc_30m_flowdir.tif -ad8 /home/elijah/Desktop/DEM-SC/sc_30m_flowacc.tif -src /home/elijah/Desktop/DEM-SC/pp1_src.tif -ord /home/elijah/Desktop/DEM-SC/pp_1_gord.tif -tree /home/elijah/Desktop/DEM-SC/pp_1_tree.txt -coord /home/elijah/Desktop/DEM-SC/pp_1_coord.txt -net /home/elijah/Desktop/DEM-SC/pp_1_net.shp -netlyr pp_1_net -o /home/elijah/Desktop/DEM-SC/pour_pt_1.shp -w /home/elijah/Desktop/DEM-SC/pp_1_wids.tif -sw

I wanted to write up this question and answer because 1) it seems like the issue has been in-place for awhile (that issue thread I cited above is circa Jan/2018), 2) the TauDEM codebase seems to be relatively feature-complete, and the git repo does not show any edits for the past two years, and 3) the TauDEM project seems quite good in most other respects (it handles memory better than both WhiteboxTools and RichDEM on large jobs), but I had to do a fair amount of digging to find this solution. So I hoped a GIS.SE thread with a strong title would help surface this solution in future web searches and mitigate this stumbling block for anyone who might otherwise be stopped in their tracks.

1
  • This! @elrobis made my day. Also note that the other outputs -tree and -coord are required in addition to -netlyr for Streamnet to work.
    – RJPS
    Jan 25, 2022 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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