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 8704905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:13:39+00:00 2026-06-13T03:13:39+00:00

I used a very helpful program to take spatial data and put it into

  • 0

I used a very helpful program to take spatial data and put it into a SQL Server database. I’m curious if it’s possible using the geometry data type to find US states that border each other?

edit: I’m assuming that if two states border each other a decent portion of the geometry data for those states will be the same (since they share a contour along their borders)

  • 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-13T03:13:40+00:00Added an answer on June 13, 2026 at 3:13 am

    I did this some time ago using SQL2005 but I believe the logic may still apply. Having gotten the spatial data, similar to you I loaded into SQL. Once there, I decided to break-up and write out each Coord (in my case lat/longs stored in a boundary geom field) with its corresponding State into a new table. Although not entirely necessary, it helped me see the data and caused the proceeding logic to be less complex. Coming into this, I suspected (but wasn’t certain) that the points listed for a border shared by a different State would be the same points listed for both states (thankfully they were). Once I had the new one-to-many (state-to-coords) table, the following pseudo code explains what I did. My working code (done in .Net) had complexities not mentioned here such as establishing a sequence number, bordering distance, etc.

    Outline:

    Loop through each State (StatePoints table)
        Get all coords/points of current State (coords in my case are lat/long combos)
        Loop through each coord of current State
            _lat = row["Latitude"]
            _long = row["Longitude"];
    
            //Using the above, locate other States in the same table with shared Coords. Something like the following.
            //the where condition state_id <> currState_id is simply to omit the current state's borders since you're only bordering Contiguous states. 
    
            strSQL = "SELECT state_id, Latitude, Longitude from ..." +
                     " WHERE (ROUND(Latitude, 6, 1) = " + _lat + ") AND (ROUND(Longitude, 6, 1) = " + _long + ") AND (state_id <> " + currState_id + ")" +
    
            dtStateSharedPoints = db.ExecuteDataSet(CommandType.Text, strSQL).Tables[0];
    
            //--------------------------------------------------
            //Loop through the shared lat/long matches. Note: typically there will only be one, 
            //however several States can meet at a single point
            //--------------------------------------------------
                 Loop through the shared lat/long matches (dtStateSharedPoints).
                     borderState_id = Convert.ToInt32(row["state_id"]);
                     strSQL = "INSERT INTO ContigStates(state_id, borderState_id, Latitude, Longitude) ..."
                     db.ExecuteNonQuery(CommandType.Text, strSQL);
    

    Some counties and states have boundaries to the edge of waterways (not center). According to the data you are using, those may not show as contiguous. You may have to account for those.

    I probably spent a good two-plus days on this at the time. Unless you have a reason otherwise, even if it only takes a day it is probably more feasible to just buy this from a data company when you compare man-hours to dollars. You can get contiguous counties here and I’m sure they would do the states if you asked. Beyond that, having not bought it, I don’t know who to recommend… it’s probablly worth binging.

    I hope this helps

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

Sidebar

Related Questions

I used a simple fork() to simulate client / server then a very simple
I've used valgrind before and it has been very helpful. I recently setup a
I have used Jim McCurdy's very helpful answer to this StackOverflow question to avoid
I am working on optimizing a query which is used very frequently on our
I have a question about DFA minimization. So I've used very well known techniques
I was wondering what is the effective weight of extension methods, if used very
I'm not very used to programming with flags, but I think I just found
I used once a very nice emacs function that set all my windows (emacs
I am very new to this and have used the Qt Designer to make
I am very new at jQuery ... I've used Javascript many times and am

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.