2

I have schema for a table called "places" that looks like this with about 6000 rows:

name | county| long | lat | the_geom | id

Tuthilltown | Ulster | -74.1789 | 41.6843271513 | 0101000020E61000004850FC18738B52C0974C370898D74440 |  1

the_geom was created following a tutorial from the lat/long of each places like so:

UPDATE places SET the_geom = ST_GeomFromText('POINT(' || long || ' ' || lat || ')',4326);

These are places scattered across the state of NY.

I am currently in the far north, but when I attempt to search for my nearest neighbor, it returns points in the far east e.g. Montauk.

The basic query for nearest neighbor is supposed to look like this:

SELECT name, lat, long
FROM places
ORDER BY the_geom <-> st_setsrid(st_makepoint( "my coordinates" ),4326)
LIMIT 1;

My coordinates are not stored but rather given on the fly from my phone.

To fix this, I have thus far attempted to create an index on this table, but I am not sure how to search against the index or if it would give me the proper results.

Is this an issue with psql or is it my query (more likely)?

closed as off-topic by Vince, Midavalo Oct 21 '16 at 1:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – Vince, Midavalo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Wild guess: are "my coordinates" swapped lat for lon? – mkennedy Oct 20 '16 at 22:28
  • Couple things were a little off it looks like. Yes, the coordinates were reversed from my current location. Also, the data_type for the_geom was geometry and not geography. I am not sure which of those two fixed it but I'm glad it's working now! Thanks!! – ml242 Oct 20 '16 at 23:39