Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

By custom, I don't mean a different structure of KML file, but in <description></description> section, I have data with HTML tags of this kind:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="">
  <name>New York City</name>
      <tr><td colspan='2'>Attributes</td></tr>

I want to easily import all this data, for each placemark, to a table with corresponding columns in the database, how to do this?

share|improve this question
There are many ways to accomplish this. Can you tell us more about what tools you are familiar with? Are you looking for a programming-oriented solution (what language do you like?) or a tool-based solution (e.g., ArgGIS, QGIS)? – katahdin Sep 10 '12 at 0:14
up vote 14 down vote accepted

you can use ST_GeomFromKML as this page.


or you can use ogr2ogr as following to process entire KML files;

ogr2ogr -f "PostgreSQL" PG:"host=yourhost user=youruser dbname=yourdb 
                            password=yourpass" inputfilename.kml

i hope it helps you...

share|improve this answer
ogr2ogr: you're saying go from KML to SHP then to PG. Why he can't use from KML to PG with one step? – nickves Sep 10 '12 at 12:04
It works! and for reference, I want to add some comments: I've found ogr2ogr in /Library/Frameworks/GDAL.framework/Programs/ (on a Mac) and there's warnings if content of <description> section contains more than 80 caracters. Thank you! – elbaid Sep 11 '12 at 0:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.