I have Point geometries created from lat,lon I loaded all the 10,000 stops in a certain city using gtfs
i would like to query my db to find the closest stop reference to my point.
the staypoint table is
CREATE TABLE stay_points
(
ad_id uuid NOT NULL,
latitude numeric NOT NULL,
longitude numeric NOT NULL,
start_utc_timestamp timestamp without time zone NOT NULL,
end_utc_timestamp timestamp without time zone NOT NULL,
cluster_id numeric NOT NULL,
radius numeric NOT NULL,
geom geometry(Point,4326)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
and the stop table is :
CREATE TABLE public.stops
(
stop_name text COLLATE pg_catalog."default",
stop_lon real NOT NULL,
stop_lat real NOT NULL,
stop_desc text COLLATE pg_catalog."default",
stop_code text COLLATE pg_catalog."default",
agency integer,
zone_id text COLLATE pg_catalog."default",
stop_url text COLLATE pg_catalog."default",
location_type numeric,
parent_station text COLLATE pg_catalog."default",
stop_id text COLLATE pg_catalog."default"
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
My current solution involves pandas and scipy kdtree and thought there must be a better way