문제

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) ???
도움이 되었습니까?

해결책

다른 팁

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.

My instinct is so strongly in the direction of the fact that you will be unable to find such a public data source that I'm posting as an answer rather than as a comment that "I don't think there is one." Just pull out a map and write up your own, it should take you... half hour or so?

And honestly, if what you're doing you or your company plans to make money on, this CAN be a good thing. You can either open-source it for "the next guy" or you can make money off of the barrier to entry in that you had to create something not technologically difficult but something that took building.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top