1

I need to get all points within a box to display them in a flat map. The column in the database is a geographic point. I'm using the following query:

SELECT * FROM asset a WHERE a.point::geometry && ST_MakeEnvelope(28.715242, -96.730798, 30.684093, -94.559248, 4326) 

I have the following points already stored in the asset table.

SRID=4326;POINT(-95.9681015014648 29.8167991638184) SRID=4326;POINT(-95.3429565429688 29.6000289916992) SRID=4326;POINT(-94.9028167724609 29.3941402435303) SRID=4326;POINT(-95.5656051635742 29.7831516265869) SRID=4326;POINT(-95.385986328125 29.5799331665039) SRID=4326;POINT(-93.7581100463867 29.4718837738037) 

It won't give an error. There are records inside that box, but it just simply won't return any records.

2
  • 2
    Are you getting an error, or just no results? What v. are you using? I think you used to need to set the SRID in your St_MakeEnvelope constructor. Commented Feb 24, 2016 at 17:07
  • 2
    this question says that ST_MakeEnvelope is specificed in (left,bottom,right,top,srid) order. Commented Feb 24, 2016 at 21:23

1 Answer 1

2

This is the #1 most common issue: swap the axis order to be X/Y (lng/lat)

ST_MakeEnvelope(-96.730798, 28.715242, -94.559248, 30.684093, 4326) 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.