使用PHP将KML导入postgis数据库

时间:2016-03-10 22:05:24

标签: php postgresql postgis

如何在postgis数据库中导入KML文件?

我需要导入KML文件并将其插入到具有多边形类型的特定列中。

由于

2 个答案:

答案 0 :(得分:1)

在SQL界面中,您可以尝试使用ST_GeomFromKML为KML文件的片段提供文本。

SELECT ST_GeomFromKML('
<Polygon>
      <outerBoundaryIs>
        <LinearRing>
          <coordinates>
            -122.377830,37.830445,0
            -122.377576,37.830631,0
            -122.377840,37.830642,0
            -122.377830,37.830445,0
          </coordinates>
        </LinearRing>
      </outerBoundaryIs>
    </Polygon>'
);

答案 1 :(得分:0)

对于完全自动化的导入使用ogr2ogr

ogr2ogr -f PostgreSQL PG:"dbname='database_geo' host='localhost' port='5432' user='xxx password='xxx'" KML_Samples.kml