• Blog posts

    Bio

    Question

    When displaying a MapThat layer from a SQL Database I am getting a Geometry error message that states cannot Make Valid. The Table displays ok within SQL Management Studio, but causes the error message when opened in MapThat?

     

    Answer

    The Geometry cannot Make Valid error message in MapThat means that the underlying spatial table has one or more records which has incorrect geometry. This can often occur if you are importing spatial data from a Shapefile where the rules for correct geometry are not as strict as those applied in a spatial database. MapThat will recognise this incorrect geometry and fail to load the layer. To fix this issue, you can correct the geometry within SQL by running the following SQL syntax:

    Update Database.dbo.TableName SET geometry = geometry.MakeValid() where geometry.STIsValid()=0

    The geometry for any incorrect records will now be fixed in the underlying spatial table and the layer will display as required within MapThat. Note that you may wish to go back to the source data (i.e. the Shapefile), identify the geometry issues and correct these yourself, instead of relying on the Make valid command.

    Follow this thread to find out more:

    http://boomphisto.blogspot.co.uk/2011/06/sql-server-invalid-geometry.html

    https://docs.microsoft.com/en-us/sql/t-sql/spatial-geometry/makevalid-geometry-data-type