将 ESRI Shape SHP 文件的子集拆分或保存到新文件?
我正在 GeoDjango 中处理形状文件。现在我正在尝试编写一个测试代码,该代码加载到形状文件中并将其保存到数据库中。 shape 文件当前的特征数为 64,118。我想将其减少到少数,以便测试可以快速加载它并确认一切正确。
由于形状文件不是文本格式,是否有免费的应用程序或库可以用来提取一些特征并将它们保存到新文件中?
我应该指出,我没有许可证,也没有访问任何 ESRI 产品线的权限。
I'm working with shape files in GeoDjango. Right now I'm trying to write a test for code that loads in a shape file and saves it to a database. The shape file currently has a feature count of 64,118. I'd like to reduce this to a handful so the test can quickly load it and confirm everything is right.
Since shape files aren't in a text format, is there a free application or library I can use to pluck out a handful of features and save them to a new file?
I should mention I don't have a license nor access to any of the ESRI product line.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用多种选项从 shapefile 中导出记录子集。
任何开源桌面 GIS 都能够执行此操作。一些比较流行的有 Quantum GIS、gvSIG 或 openJUMP。每个文件的确切步骤会有所不同,但基本上您必须加载形状文件,开始编辑,选择所需的记录并将它们导出到新的形状文件。
ogr2ogr 工具是 GDAL 包的一部分,允许您在不同的地理矢量格式之间进行转换(或相同格式),并且可以指定类似SQL的表达式来过滤原始数据集。
如果您正在使用 PostGIS 并且不想安装任何以前的应用程序,则可以使用 pgsql2shp 工具,用于将 PostGIS 表的子集导出到 shapefile。
编辑:在这三个选项中的任何一个中,您都可以执行空间过滤器(即落在边界框内的要素),而不是基于属性的选择。
You have several options to export a subset of records from a shapefile.
Any Open Source desktop GIS will be able to perform this. Some of the more populars are Quantum GIS, gvSIG or openJUMP. The exact steps will vary in each of them, but basically you have to load the shape file, start editing, select the records you want and export them to a new shapefile.
The ogr2ogr tool, part of the GDAL package allows you to transform between different geographic vector formats (or within the same format), and you can specify an SQL-like expression to filter the original dataset.
If you are using PostGIS and don't want to install any of the previous apps, you can use the pgsql2shp tool to export a subset of your PostGIS table to a shapefile.
Edit: In any of the three options you can perform a spatial filter (ie features that fall within a bounding box) rather than a selection based on attributes.