Accurate Bounding Box From Geography Polygon

357 views Asked by At

Given a table with a column

polygon geography(Polygon,4326)

I want to add another column

bounding_box geography(Polygon,4326)

that accurately represents the bounding box of the polygon column. The functions ST_Extent and ST_Envelope create bounding boxes, but they only accept and return geometries, so using them means that the bounding_box assignment looks something like bounding_box = geography::ST_Envelope(geometry::polygon). I am concerned about the loss of accuracy. If I do a point-in-poly query on bounding_box before doing an ST_Covers query on polygon, is it possible I will not get some hits that I should be getting because the bounding_box loses some of the size it should have in the conversion back and forth between types?

So my questions are:

  • Is there any accuracy lost in geography::ST_Envelope(geometry::polygon)?
  • If so, what is a more accurate solution?

P.S. The reason for the bounding_box column is so it can be indexed. The values in the polygon column are too big to be indexed. The point-in-poly query would look like this: find_point && bounding_box AND ST_Covers(polygon, find_point) where find_point is of type geography(Point,4326).

0

There are 0 answers