I have bunch (1000+) of KML files like this:
<Document>
<name>Shape 10</name>
...
<Placemark>
<name></name>
<MultiGeometry>
...
</MultiGeometry>
</Placemark>
</Document>
which need to be imported into PostgreSQL database.
I can import all files using ogr2ogr
:
find data -name '*.kml' | \
xargs -n1 ogr2ogr -f "PostgreSQL" -dim 2 -nln shapes -append PG:dbname=${db}
but:
- importing w/o
-nln
options creates one table per KML file with name from/Document/name
element ("Shape 10") which is not ideal - importing w/
-nln
creates single table but shape name ("Shape 10") is lost (not recorded in table - columnname
is empty probably becauseDocument/Placemark/name
is empty
How I could import 1000's of KML files into single table with preserving / storing layer name in output table?