简体   繁体   English

获取给定美国州的邻近州

[英]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/ 我使用此页面使用美国各州创建了SQL表: 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. 我创建了另一个名为“ NeighborStates”的SQL表,其中包含2列:State和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". 但是现在,我正在寻找一些地理空间数据,甚至是一个硬编码列表(每个州的邻居状态列表)来填充我的表“ NeighborStates”。

Do you know where to find a datasource with the neighboring states of a given USA state? 您知道在哪里可以找到具有给定美国州的相邻州的数据源吗?

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

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. 您可以将其开源以供“下一个家伙”使用,也可以通过进入壁垒赚钱,因为您必须创造出某种技术上不是很困难的东西,而是需要建造的东西。

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 http://state.1keydata.com/bordering-states-list.php

The page lists bordering states for each of the 50 states in the United States. 该页面列出了美国50个州中每个州的毗邻州。 You can view the information either alphabetically by state or by the number of bordering states. 您可以按州或毗邻州的数目按字母顺序查看信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM