如何将 ESRI Shape 文件转换为 SQL Server 2008?

发布于 2024-09-14 08:18:16 字数 221 浏览 2 评论 0原文

我有一个 shapefile,我想将其上传到空间 SQL Server 2008。我尝试使用此工具: SQL Server 2008 空间工具。但没有运气。

有谁知道任何其他(免费)工具可以做到这一点?

I have a shapefile that I would like to upload to a spatial SQL Server 2008. I have tried using this tool: SQL Server 2008 Spatial Tools. But without luck.

Does anyone know any other (free) tools for doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

灯角 2024-09-21 08:18:17

您可以使用 ogr2ogr 将 shapefile 转换为 GML(或许多其他格式),然后使用 SQL Server 的 GeomFromGML 导入。您需要为 shapefile 中的每个功能调用 GeomFromGML,但这是一个相对容易编写的程序。

You can use ogr2ogr to convert from shapefile to GML (or many other formats) and then use SQL Server's GeomFromGML to import. You will need to call GeomFromGML for each feature in your shapefile, but that's a relatively easy program to write.

海夕 2024-09-21 08:18:17

我已经在 arcbjects 中编写了代码来执行此任务。如果您有 arcview 或引擎许可证,您可以在 C# 中创建控制台应用程序并使用此代码:请参阅 https://gis.stackexchange.com/questions/33917/how-to-import-shapefiles-into-ms -sql-2008-and-then-view-that-data-using-qgis?lq=1

I have written code in arcbjects for do this task. If you have license arcview or engine you can create a console application in c# and use this code: see https://gis.stackexchange.com/questions/33917/how-to-import-shapefiles-into-ms-sql-2008-and-then-view-that-data-using-qgis?lq=1

陌路终见情 2024-09-21 08:18:17

更新:我决定将人们指向官方 Github 存储库:https:// github.com/zer0infinity/OGR2GUI

这个 [ogr2ogr fork] 工具将尝试解析输入文件的内容(在我的例子中,它是一个 shapefile)并将其输出为一堆不同格式的文件(在我的例子中,我需要将其作为 CSV 格式,但您甚至可以将文件导出为 SQLite 文件)。不幸的是,它不能直接执行 SQL,但您可以从 SQLite 查看器(例如 SQLite Browser)进行转储并导入它到 MS SQL 上。我确实注意到转换为 SQLite 时效率低下(我丢失了一些属性/表)。我还尝试使用 MobileMapper Office (MMO)(运气更好)导出到 CSV,它确实保留了大量数据,但您需要编写一个脚本将数据导入 SQL 。如果您打算走这条路,请告诉我,我目前正在编写一个 VBA 脚本来处理从 MMO 导出的数据。

如果您希望将其构建到您的应用程序(某种脚本)中,您可能会幸运地尝试使用ogr2ogr,但您永远不知道数据会是什么样子。文档可以在这里找到 http://www.gdal.org/ogr2ogr.html

原始答案:保存有时你自己使用这个神奇的工具: http://ogr2gui.ca/

它基于 ogr2ogr,但有一个很好的功能图形用户界面。

UPDATE: I decided I would just point people to the official Github repo instead: https://github.com/zer0infinity/OGR2GUI

This [ogr2ogr fork] tool will attempt to parse the content of the input file (in my case, it was a shapefile) and output it as a bunch of different formats (in my case, I needed it as a CSV, but you can even export your file as a SQLite file). Unfortunately it doens't do straight up SQL, but you can do a dump from a SQLite viewer such as SQLite Browser and import it onto MS SQL. I did notice some inefficiencies when converting to SQLite (I lost some attributes/tables). I also tried MobileMapper Office (MMO) (with better luck) to export to CSV and it did preserve a lot of the data, but you'd then need to write a script to import the data to SQL. If you are going that route, let me know, I'm currently writing a VBA script to deal with the exported data from MMO.

If you're hoping to build this into your application (a script of some sort), you may have some luck trying with ogr2ogr, but you never know what the data is going to look like. documentation is found here http://www.gdal.org/ogr2ogr.html

Original answer: Save yourself sometime and just use this amazing tool: http://ogr2gui.ca/

It's based off ogr2ogr, but with a nice GUI.

等你爱我 2024-09-21 08:18:17

我制作了一个用于将 shapefile 导入 SQL Server 的应用程序。它主要是为了满足我的需要而制作的,但我有一些空闲时间,所以我为您制作了一个安装程序。

您可以用它做一些不错的事情:

  1. 选择输入形状文件的编码
  2. 重命名/重新映射目标表列名称
  3. 选择目标表名称
  4. 设置目标表的主键

它有一个用户界面,您可以免费下载。

更多详细信息可以在我的博客上找到,链接如下: 将 shapefile 导入 SQL Server

I've made an app for importing shapefiles into SQL Server. It's made primarily to suit my needs but i had some spare time so i made an installer for you.

Some nice things you can do with it:

  1. choose encoding of input shapefile
  2. rename/remap destination table column names
  3. choose the destination table name
  4. set the primary key for the destination table

It has a user interface and you can download it for free.

More details can be found on my blog, here's the link: Import shapefiles into SQL Server

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文