sql-servergeolocationgeospatialgeographyopendata

Get the neighboring states of a given USA state


I created the SQL table with the US states using this page: http://www.john.geek.nz/2009/01/sql-tips-list-of-us-states/

CREATE TABLE [dbo].[UsaStates] (
    [Code] CHAR (2)     NOT NULL,
    [Name] VARCHAR (50) NOT NULL,
    CONSTRAINT [PK_UsaStates] PRIMARY KEY CLUSTERED ([Code] ASC)
);

I created another SQL table called "NeighborStates" with 2 columns: State and NeighborState.

CREATE TABLE [dbo].[NeighborStates](
    [StateCode] [char](2) NOT NULL,
    [NeighborStateCode] [char](2) NOT NULL,
 CONSTRAINT [PK_NeighborStates] PRIMARY KEY CLUSTERED 
(
    [StateCode] ASC,
    [NeighborStateCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[NeighborStates]  WITH CHECK ADD  CONSTRAINT [FK_NeighborStates_NeighborStates_Neighbors] FOREIGN KEY([NeighborStateCode])
REFERENCES [dbo].[UsaStates] ([Code])
GO

ALTER TABLE [dbo].[NeighborStates]  WITH CHECK ADD  CONSTRAINT [FK_NeighborStates_UsaStates] FOREIGN KEY([StateCode])
REFERENCES [dbo].[UsaStates] ([Code])
GO

But now, I'm looking for some geospatial data or even a hard-coded list (list of neighbors states for each state) to fill my table "NeighborStates".

Do you know where to find a datasource with the neighboring states of a given USA state?

INSERT INTO [NeighborStates](StateCode,NeighborStateCode) ???

Solution

  • I wanted to check if the state of Boston and the state of NYC share a border. My internet-research led me to this dataset

    http://state.1keydata.com/bordering-states-list.php

    The page lists bordering states for each of the 50 states in the United States. You can view the information either alphabetically by state or by the number of bordering states.