2

So I have a KML file (it contains a point):

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Folder>
    <Placemark id="linestring1">
        <name>My path</name>
        <ExtendedData>
            <Data name="curp">
                <value>GOCE850925HQRNND05</value>
            </Data>
        </ExtendedData>
        <description/>
        <Point>
            <coordinates>19.38695565339294,-99.2836972</coordinates>
        </Point>
    </Placemark>
</Folder>

what I need is to save in my PostGIS database, I use the following command line with ogr2ogr :

ogr2ogr  -f PostgreSQL PG:"host=127.0.0.1 dbname=postgis_24_sample port=5432 user=postgres password=123456" 1597780353.kml  -nln  ppb_curp_webmerc 2>&1 

But I get the following error

local.DEBUG: Warning 1: Geometry to be inserted is of type Point, whereas the layer geometry type is 
Multi Polygon.
Insertion is likely to fail
ERROR 1: ERROR:  Geometry type (Point) does not match column type (MultiPolygon)
ERROR 1: INSERT command for new feature failed.
ERROR:  Geometry type (Point) does not match column type (MultiPolygon)
Command: INSERT INTO "ppb_curp_webmerc" ("geom" , "curp", "name", "description", "tessellate", "extrude", "visibility") VALUES ('0101000000D7BD04C4E3633340E0FD4C1828D258C0'::GEOMETRY, 'GOCE850925HQRNND05', 'My path', '', -1, 0, -1) RETURNING "gid"
ERROR 1: Unable to write feature 1 from layer 1597780353.
ERROR 1: Terminating translation prematurely after failed
translation of layer 1597780353 (use -skipfailures to skip errors)

Any comment?

1
  • 2
    GDAL, for some reason, has initialized the PostGIS table to contain multipolygons and because of that point geometry is not accepted. If you know that your KML files contain just points add -nlt POINT into your command. To accept any kind of geometries use -nlt GEOMETRY.
    – user30184
    Aug 19 '20 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.