FME log file warning: MS SQL Server (Spatial) Writer: Failed to write a feature of type `' to the database. ArgumentException: 24200

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2015.x

Symptom

FME log file warning: MS SQL Server (Spatial) Writer: Failed to write a feature of type `<name>' to the database.

Full error message:

MS SQL Server (Spatial) Writer: Failed to write a feature of type "name" to the database. Provider error `A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": System.ArgumentException: 24200: The specified input does not represent a valid geography instance.System.ArgumentException: at Microsoft.SqlServer.Types.SqlGeography.ConstructGeographyFromUserInput(GeoData g, Int32 srid) at Microsoft.SqlServer.Types.SqlGeography.GeographyFromBinary(OpenGisType type, SqlBytes binary, Int32 srid).'. SQL Command `DECLARE @WKB varbinary(max); SET @WKB = ?; DECLARE @SRID INTEGER; SET @SRID = ?; DECLARE @G geography; IF @WKB = '' SET @G = NULL ELSE SET @G = geography::STGeomFromWKB(@WKB,@SRID); INSERT INTO [United States] ([STATEFP], [STATENS], [STUSPS], [NAME], [LSAD], [MTFCC], [UR], [FUNCSTAT], [SpatialData]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, @G)'

 

Cause

The issue is that SQL Server doesn't like the structure of the geometry you're trying to load. This is apparently a relatively common issue with SQL Server Geography - which is very fussy about the geometry structure. When loading spatial data into the SQL Server Geography column, the data must be clean with no self-intersections, duplicate points, spikes, or other inconsistencies. Apparently, this is also a relatively common issue when loading US Census data.
 

Resolution

FME has several transformers that can be used to clean-up the geometry: SpikeRemover, SelfIntersector, Generalizer (Thin).

Alternatively, you can use the MakeValid() SQL Server tool.

Additional information on using the MakeValid() command and how to set this up as a post-processing step is detailed in FME is loading features with invalid geometries into my Database.
 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.