Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

1 Answer 1

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

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.