I use the spatial tools extensively to build polygons of radio station coverage which I store in a SQL Server database. I ran into a couple of situations where the attempt to insert into SQL Server produces an error:
Error: Output Data (68): DataWrap2ODBC::SendBatch: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
System.FormatException: 24115: The well-known binary (WKB) input is not valid.
System.FormatException:
at Microsoft.SqlServer.Types.WellKnownBinaryReader..ctor(SqlBytes bytes, GeoDataSink sink)
at Microsoft.SqlServer.Types.SqlGeography.GeographyFromBinary(OpenGisType type, SqlBytes wkbGeography, Int32 srid)
.[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]The statement has been terminated.
To test whether SQL Server was the problem, I also tried outputting the same data to a Tableau .hyper file, and got the error:
Error: Output Data (104): invalid geography format (valid well known text is required)
Context: 0x5fdfad59
Outputting to an Alteryx .yxdb works fine. I have not tried this with any other databases
In situations where the points forming the polygon are all the same point, the SpatialObj_Built output is null. But if the points forming the polygon are a line, the SpatialObj_Built output is not null, but does not contain a polygon either.
In the attached example, you will see 2 example locations, each with 3 records: one with a polygon, one with an error, and one null. I also show how you can use a Select tool to convert the spatial object to Well Known Text (WKT) to aid with diagnosis, as well as the Spatial Info tool. I also include the workaround to convert the empty object to null when this happens.
I believe this to be a bug with either the Poly-Build tool or the output to certain databases.