Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

So I want to convert KML files to SHP shapefiles to load it onto PostGIS. Currently I'm using ogr2ogr to do the conversion for me, but it wipes out all the attribute data. How do i preserve this attribute data in the resulting shapefile? Any better feature out there?

share|improve this question

Why don't you directly convert a KML file to PostGIS. You can do this using the following command:

ogr2ogr -overwrite -f "PostgreSQL" PG:"host=myIP user=myUser dbname=myDb password=myPassword" yourfile.kml

This will create a table named layer_0(if not already there) with all your attributes.

share|improve this answer
    
That's awesome. But I've gotta try it out before accepting this answer. Will do that. Thank you! – KaushikTD Apr 17 '12 at 14:02
    
I'm actually still losing all the attribute data. This command doesn't work. – KaushikTD Apr 18 '12 at 5:50
    
Does it convert your data? If you are still losing your attribute data, check your kml structure. I have used this command successfully. – thelastray Apr 18 '12 at 6:05
    
It converts the data fine. As in, the geometry is preserved, but i lose all my attribute data. I have about 10-12 attribute columns, but the resulting database has 4 tables - feature labels, features, geometry_columns and spatial_ref_sys. The layer_0 table isn't formed or anything. – KaushikTD Apr 18 '12 at 6:42
    
Does switching between the KML and libKML driver make any difference? – Ragi Yaser Burhum Sep 17 '14 at 19:16

the XTools Pro ArcMap addin has a free KML importing function which can retain the custom schema in the KML.

share|improve this answer

This tool, Export to KML developed by Kevin Martin does the work.

There are some issues with the styles but at least colours and attributes are correct, and it´s plenty of options to play with the attributes, labels, etc...

share|improve this answer
1  
This tool what tool? Got a link to it? – Spacedman Dec 9 '15 at 11:09
    
Sorry, forgot the link. Now is fine. – Pedraz Dec 9 '15 at 15:43

Your Answer

 
discard

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.