php - 使用 PHP 将 shapefile 存储到 postgresql

标签 php postgresql postgis shapefile

我正在尝试开发一个 PHP 脚本,让用户可以上传 shapefile 以导入到 postGIS 数据库。

首先,对于转换部分,AFAIK 我们可以使用 shp2pgsql 将 shapefile 转换为 postgresql 表;我想知道是否有另一种方法进行转换,因为我不想使用 exec() 命令。

我也很感激任何以不需要数十个唯一命名表的方式存储数据的想法。

最佳答案

除了使用 postgresql 的二进制文件转换 shapefile 之外似乎没有其他方法。虽然这确实不是一个糟糕的选择,但如果有 PHP native 函数或 apache 模块来执行此操作,我宁愿不使用 exec()! 但是,听起来 exec 是唯一可用的理智选项。所以我要用它。 别往心里放! :)

关于最后一部分,这是一个不同的问题,应该单独提出。虽然,恐怕没有其他办法。

更新 添加示例

$queries = shell_exec("shp2pgsql -s ".SRID." -c $shpfilpath $tblname")
                    or respond(false, "Error parsing the shapfile.");
pg_query($queries) or respond(false, "Query failed!");
  • SRID 是包含“SRID”的常量!
  • $shpfilpath 是所需 ShapeFile 的路径
  • $tblname 是表格所需的名称

关于php - 使用 PHP 将 shapefile 存储到 postgresql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17596185/

相关文章:

php - 具有四个条件的密码正则表达式

PHP,如何仅以某种格式获取当前时间

postgresql - 具有多个 PK insertOrUpdate() 的 Scala 的 Slick 抛出异常 ERROR : syntax error at end of input

postgresql - Postgis 中 2 个点之间的距离,单位为 srid 4326,以米为单位

postgresql - Heroku - 禁用 Postgresql SSL?

javascript - 使用 Leafletjs 显示 PostGIS 数据

php - 如何在 PHP 中通过 PDO 循环遍历 MySQL 查询?

php - 我如何设置默认默认图像 (no_pic.gif) php?

ruby-on-rails-3 - 导轨 3 : How to simply test pessimistic locking on console

postgresql - 如何在ecto中编写复杂的子查询作为from子句?