如何在 php 中添加形状文件 (.shp) 并在 php 文件中使用该形状文件数据?

发布于 2025-01-07 13:38:07 字数 417 浏览 6 评论 0原文

我必须在 php 中开发一个项目,并且必须包含形状文件,并且该形状文件需要转换为 kml 文件。

我知道如何将 shape 文件转换为 kml 文件,但我不知道如何将 shape 文件导入/导入到 php 项目中。
我还有包含更多信息的形状文件的支持文件。其中一些是 .dbf、.shx 等。所有文件的信息也应该与形状文件信息一起存储。

是否有任何工具可以导入形状文件或任何其他帮助,以便我可以将形状文件添加到 php 站点中的项目中? 或者是否可以存储所有形状文件(.shp)、.dbf、. shx 数据存入数据库,然后使用该数据进行 kml 结构化。

我还想知道,所有形状文件都遵循任何结构或格式吗?形状文件有什么标准吗 比如xml文件有哪些?

xml 文件应强制包含起始标记。
它们应该遵循结构,否则查看者将无法看到 xml 文件。

I have to develop one project in php and in that I have to include shape file and that shape file needs to be converted in to kml file.

I know how to convert shape file into kml file but I don't know how to take/import shape file into php project.
and I also have the supporting files with the shape file which contain more information.some of them are .dbf, .shx etc. And this all file's information should also be stored with the shape file information.

Is there any tool to import shape file or any other help so that I can add shape file into my project in php site?
or is it possible to store all the shape file(.shp), .dbf, . shx data into database and then use that data for the kml structuring.

I also want to know that,all shape files follow any structure or formatting?Is there any standard for the shape file
such as the xml file have?

xml file should have the starting tag mandatory.
They should follow the structure otherwise the viewer is unable to see the xml file.

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

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

发布评论

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

评论(2

山川志 2025-01-14 13:38:07

更新2:

对于 v3.0.0 版本,该库已完全重写采用面向对象的方法:它现在公开了一些方便的 ShapefileReaderShapefileWriter 和不同类型的 Geometry 对象(多点线串多线串多边形多多边形)。

它增加了对自定义字符集(CPG 文件)、备注字段(DBT 文件)的支持,最重要的是,它现在能够编写shapefile 也是如此!

目前,它的目标是成为最完整的用于读写 shapefile 的免费开源 PHP 库,并且在过去几年中它已被许多用户广泛使用,但应该如果您发现任何错误,请报告它和/或提出问题,我们将立即修复。


更新1:

自 v2.0.0 起,PHP Shapefile 能够读取 Z 和 M shapefile、本机访问 DBF、与 PHP 7 兼容等等。我正在积极开发此功能,因此可以提供功能请求。


我不想在一个老问题中违反关于我自己的库的任何规则,但是当在 Google 上搜索 php shapefile 时,此页面会在第一个结果中弹出,所以我认为它可能有用对于像我一样正在寻找这样的图书馆的人。

我一直在寻找一个像样的库来自己在 PHP 中导入 ESRI Shapefiles,最后我构建了自己的库。它可以读取所有 2D shapefile 类型的 shapefile 和 DBF 数据,并且应该 100% 无错误。
它已经在生产中使用了几个月了,所以我向任何想要使用它的人公开发布:

https://github.com/gasparesganga/php-shapefile

UPDATE 2:

For v3.0.0 release, the library has been completely rewritten with an object-oriented approach: it now exposes some convenient ShapefileReader, ShapefileWriter and different kinds of Geometry objects (Point, MultiPoint, Linestring, MultiLinestring, Polygon and MultiPolygon).

It has been added support for custom charsets (CPG files), memo fields (DBT files) and, most importantly, it is now able to write shapefiles too!

At this point, it aims to be the most complete free and open source PHP library to read and write shapefiles out there and it's been used widely by many users in the last few years, but should you find any bug with it, please report it and/or open an issue and it will be promptly fixed.


UPDATE 1:

Since v2.0.0, PHP Shapefile is capable of reading Z and M shapefiles, natively access DBF, is PHP 7 compatible and much more. I am actively developing this, so feature requests are available.


I don't want to break any rule posting about my own library in an old question, but this page pops up in the firsts result when searching for php shapefile on Google, so I thought it might be useful for someone who is looking for such a library as I used to.

I've been looking for a decent library to import ESRI Shapefiles in PHP myself, and I ended up building my own. It can read all 2D shapefiles kinds of shapefiles and DBF data and it should be 100% bug free.
It's been used in production for a few months by now, so I made public release for anybody who would like to use it:

https://github.com/gasparesganga/php-shapefile

终陌 2025-01-14 13:38:07

有几个 PHP 类:

并且至少gis.stackexchange.com

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