I have about 2 million records in a table in PostgreSQL database with columns such as “source_location”, “destination_location”, “source_lat”,”source_long”,”destination_lat”,”destination_long” etc.
How do I make use of this table to convert it into Spatial table in PostGIS so that I can fire spatial queries on this data?
Let’s assume that your data is in the table
foo. First add geometry columns:Than you can set values of geometry columns:
As a result you can use columns
source_geomanddestination_geomin spatial queries:This query returns all records where distance between source and destination > 1000 kilometers.