Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8647225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:00:46+00:00 2026-06-12T13:00:46+00:00

I have about 2 million records in a table in PostgreSQL database with columns

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:00:47+00:00Added an answer on June 12, 2026 at 1:00 pm

    Let’s assume that your data is in the table foo. First add geometry columns:

    SELECT AddGeometryColumn('foo', 'source_geom', 4326, 'POINT', 2);
    SELECT AddGeometryColumn('foo', 'destination_geom', 4326, 'POINT', 2);
    

    Than you can set values of geometry columns:

    UPDATE foo SET
      source_geom =
        ST_SetSRID(ST_MakePoint(source_lon, source_lat), 4326),
      destination_geom = 
        ST_SetSRID(ST_MakePoint(destination_lon, destination_lat), 4326);
    

    As a result you can use columns source_geom and destination_geom in spatial queries:

    SELECT * FROM foo
    WHERE ST_Distance_Sphere(source_geom, destination_geom) > 1000000;
    

    This query returns all records where distance between source and destination > 1000 kilometers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very large database with about 120 Million records in one table.I
I have a table with 30 columns and about 3.4 million records. Is it
I have about 1 million records in my contact table in the DB, now
I have about 40 workbooks with 1000+ columns and near 1 million records. Unfortunately,
I have a very large table being filled with about 100s of million records
I have a table with about 20+ million records. Structure is like: EventId UNIQUEIDENTIFIER
I have about 28 million records to import into a mySql database. The record
I have a big Table , about 1 million records , and it's increasing
I have a InnoDB table that has about 17 normalized columns with ~6 million
I have a very large table (few million records). The columns in the table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.