Skip to main content
edited body
Source Link
Evan Carroll
  • 7.1k
  • 2
  • 33
  • 62

I have PostGIS table with a geometry column of multipolygons, SRID 4269.

Google maps returns all results in SRID 4326. So you need to first either.

  • ST_Transform() your input coordinates to 4326 on the table.
  • Create an index on the result of the ST_Transform.

Let's assume the latter.

CREATE INDEX ON myTable USING GIST (ST_Transform(myGeom, 4326));
VACUUM ANALYZE myTable;

Then what you can do is, is build a bounding box with ST_MakeEnvelope, and run the query. The end query will look something like,

SELECT *
FROM myTable
WHERE ST_MakeEnvelope(xmin,ymin,xmax,ymax) && ST_TranslateST_Transform(myTable.geom,4326);

I have PostGIS table with a geometry column of multipolygons, SRID 4269.

Google maps returns all results in SRID 4326. So you need to first either.

  • ST_Transform() your input coordinates to 4326 on the table.
  • Create an index on the result of the ST_Transform.

Let's assume the latter.

CREATE INDEX ON myTable USING GIST (ST_Transform(myGeom, 4326));
VACUUM ANALYZE myTable;

Then what you can do is, is build a bounding box with ST_MakeEnvelope, and run the query. The end query will look something like,

SELECT *
FROM myTable
WHERE ST_MakeEnvelope(xmin,ymin,xmax,ymax) && ST_Translate(myTable.geom,4326);

I have PostGIS table with a geometry column of multipolygons, SRID 4269.

Google maps returns all results in SRID 4326. So you need to first either.

  • ST_Transform() your input coordinates to 4326 on the table.
  • Create an index on the result of the ST_Transform.

Let's assume the latter.

CREATE INDEX ON myTable USING GIST (ST_Transform(myGeom, 4326));
VACUUM ANALYZE myTable;

Then what you can do is, is build a bounding box with ST_MakeEnvelope, and run the query. The end query will look something like,

SELECT *
FROM myTable
WHERE ST_MakeEnvelope(xmin,ymin,xmax,ymax) && ST_Transform(myTable.geom,4326);
added 4 characters in body
Source Link
Evan Carroll
  • 7.1k
  • 2
  • 33
  • 62

I have PostGIS table with a geometry column of multipolygons, SRID 4269.

Google maps returns all results in SRID 4326. So you need to first either.

  • ST_Transform() your input coordinates to 4326 on the table.
  • Create an index on the result of the ST_Transform.

Let's assume the latter.

CREATE INDEX ON myTable USING GIST (ST_Transform(myGeom, 4326));
VACUUM ANALYZE myTable;

Then what you can do is, is build a bounding box with ST_MakeEnvelope, and run the query. The end query will look something like,

SELECT *
FROM myTable
WHERE ST_MakeEnvelope(xmin,ymin,xmax,ymax) && ST_Translate(foomyTable.geom,4326);

I have PostGIS table with a geometry column of multipolygons, SRID 4269.

Google maps returns all results in SRID 4326. So you need to first either.

  • ST_Transform() your input coordinates to 4326 on the table.
  • Create an index on the result of the ST_Transform.

Let's assume the latter.

CREATE INDEX ON myTable USING GIST (ST_Transform(myGeom, 4326));
VACUUM ANALYZE myTable;

Then what you can do is, is build a bounding box with ST_MakeEnvelope, and run the query. The end query will look something like,

SELECT *
FROM myTable
WHERE ST_MakeEnvelope(xmin,ymin,xmax,ymax) && ST_Translate(foo.geom,4326);

I have PostGIS table with a geometry column of multipolygons, SRID 4269.

Google maps returns all results in SRID 4326. So you need to first either.

  • ST_Transform() your input coordinates to 4326 on the table.
  • Create an index on the result of the ST_Transform.

Let's assume the latter.

CREATE INDEX ON myTable USING GIST (ST_Transform(myGeom, 4326));
VACUUM ANALYZE myTable;

Then what you can do is, is build a bounding box with ST_MakeEnvelope, and run the query. The end query will look something like,

SELECT *
FROM myTable
WHERE ST_MakeEnvelope(xmin,ymin,xmax,ymax) && ST_Translate(myTable.geom,4326);
Source Link
Evan Carroll
  • 7.1k
  • 2
  • 33
  • 62

I have PostGIS table with a geometry column of multipolygons, SRID 4269.

Google maps returns all results in SRID 4326. So you need to first either.

  • ST_Transform() your input coordinates to 4326 on the table.
  • Create an index on the result of the ST_Transform.

Let's assume the latter.

CREATE INDEX ON myTable USING GIST (ST_Transform(myGeom, 4326));
VACUUM ANALYZE myTable;

Then what you can do is, is build a bounding box with ST_MakeEnvelope, and run the query. The end query will look something like,

SELECT *
FROM myTable
WHERE ST_MakeEnvelope(xmin,ymin,xmax,ymax) && ST_Translate(foo.geom,4326);