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)
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:
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