5

I've saved country borders in my sql server 2012 as geography data from geojson files.

It turns out that when I query all the boundaries that have an administration level 2, not all the polygons are shown in the "spatial results" tab.

Clearly this issue is not specific to just admin level 2 but also the rest of the levels are affected. I'll use Austria admin level 2 as an example.

The error message I get is: "One or more spatial objects were too large to display. Please refine your query". enter image description here

As you can see Austria(Österreich) is present in the query result but is not present in the "Spatial result" tab: enter image description here

This is my query:

SELECT TOP 10 [Id]
      ,[AdminLevel]
      ,[Name]
      ,[CountryId]
      ,[OpenstreetmapId]
      ,[BoundaryPolygon]
  FROM [WorldLocation].[dbo].[GeographyBoundary]
WHERE [AdminLevel] = 2

Questions:

  1. What is the cause of the issue displaying the error message in the spatial results tab?
  2. How can I fix the error?
  3. Is there a query I can write to solve the problem?
Carlo Luther
  • 2,402
  • 7
  • 46
  • 75
  • If you run the query "SELECT BoundaryPolygon.ReorientObject() FROM GeographyBoundary WHERE Id = 9737" does it work? My first thought is that it was drawn backwards so SQL Server thinks the polygon is the entire earth except for Osterreich. – hcaelxxam Nov 19 '15 at 19:21
  • @hcaelxxam Yes that was the first thing I've tried. Before loading the spatial data I've filtered all the polygons to the correct orientation. Unfortunately this is not the issue. – Carlo Luther Nov 19 '15 at 19:48
  • hmmm does the polygon appear if you query it directly, or do you get the same error? I am assuming it doesn't, but I want to verify. Have you looked at STLength compared with similarly sized countries and looked to see if it is approximately the same? If one of the verticies is wrong for some reason, it could make the polygon too big, and STLength might be helpful to determine if that is the case. – hcaelxxam Nov 19 '15 at 20:30

1 Answers1

4

Use sql geo-spatial function like Reduce(), to simply the dots.

You can review the shape in the spatial results tab.

Sachith Muhandiram
  • 2,819
  • 10
  • 45
  • 94
Mick Wang
  • 41
  • 4