Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some concerns about working of BOX3D PostGIS function. I tried to find places in square -158.721365889063 66.09275164148659, 154.608712235937 52.56807548751039(degrees). But this where statement

    some_place.point && SetSRID('BOX3D(-158.721365889063 66.09275164148659,
    154.608712235937 52.56807548751039)'::box3d,4326)

returns places in the biggest of two possible squares.

When I change order of angles or use 'xmin ymin,xmax ymax' order, I got the same result.

Also I used

     ST_Contains( SetSRID( ST_MakeBox2D( 
      ST_Point(-145.757498701563,51.37699768868392) ), 4326 ), some_place.point)

with the same result.

How can I do it for some specific order of angle's points?

P.S. I got bounds from google map api.

share|improve this question
I am confused by the data in this question. Could you please explain why it makes sense that 66... could be a ymin value while the smaller number, 52..., could be ymax? – whuber May 28 '12 at 19:04
@whuber I wrote that I tried right order. It's not ymax it's only one of the possibilities that I use, but I got the same answer for any order of angles' coordinates. – olga-in-space Jun 28 '12 at 12:44

PostGIS has the function ST_Shift_Longitude(). If I understand your question, you want the BBOX to be between 143E and 145W ? So something like (not tested):

SELECT ST_Contains(
GeomFromText('POLYGON((143 51, 143 66, -145 66, -145 51, 143 51))', 4326)),
ST_Shift_Longitude(GeomFromText('POINT(144 52)', 4326))

should return '1' (true), But if you set the POINT as 'POINT(142 52)' it should return '0'.

share|improve this answer
I don't know how I miss your answer. ST_Shift_Longitude is very helpful for me. Really, thanks. – olga-in-space Jun 28 '12 at 12:42
My quick view was wrong.. It doesn't work :( You query return 't'. But it can not be true. – olga-in-space Jun 28 '12 at 15:11
Could you give us some more specific details of what you're trying to achieve, and explain why "it can not be true". What query did to run, what results did you get, and what did you expect that came out wrong? – Micha Jun 29 '12 at 21:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.