So I'm working on a project that's been in development for over a year, but I only recently got involved. My task involves converting roughly 2,500 KML files into another format, importing these files into a Geoserver, and then copying over the associated style information for each file. I realize that Geoserver allows you to import KML files directly, however, our files never seem to render correctly, and my boss would like to move away from KML format for philosophical reasons.

Using ogr2ogr, I've tried to convert these files into ESRI Shapefiles, however the conversion process only worked on roughly a third of the files and erased some of the metadata called for in the style information. The files that didn't convert code for polygons and points, which I've read can be an error for other programs like QGIS.

I've also tried to put all of the KML files into a PostGIS database and convert them like that. However, that seems to delete all of the data leaving essentially blank tables for import.

TL;DR I need to find a way to convert 2,500 KML files into a format usable by Geoserver, and will work with XML style information. I'm a complete GIS noob and this is my first time posting, so I'm sorry if this seems a bit ridiculous.

  • Is the style essentially the same for all the KML files or are they all completely different? If the former you might find that you can simply hand roll a style file (or set of files) for GeoServer which uses SLD (an XML based format). – nmtoken Dec 5 '15 at 5:52
  • this in in relation to importing kml and style information into geoserver – GeoStoneMarten Dec 7 '15 at 20:04

In GeoServer data and style are separated, there is no way to mix them. You can autogenerate an SLD. So far, I don't know if a converter exist for kml style to geoserver style.


First, Geoserver style (SLD) and data (KML) are totaly different. Import the KML file in Geoserver and later, create SLD file in the style editor or create style within the viewer (like Mapfishapp) and next, save the .sld file to get the sld easily without write within XML (more difficult to realize classification or other specific style when some system realize it easily).

Later, i've used KML files to save GIS data and all the time, i lost attribute (=data lost). KML just keep geometry information. It's better to save your nativ data to another format (CSV keep attribute) or just create data table and, after, give the geographical information or directly create layer. (shapefile, Csv...).

I hope i help you...


The additional information in the kml file that you wish to use and you refer to as "metadata", could be in the KML jargon:

  1. Styles and Stylemaps
  2. ExtendedData
  3. Custom information in the Description field of a Placemark, usually in the form of html tables

Since each kml file is an ASCII file, it can be processed via a text-processing script. According to my understanding, a separate "layer" must be created for each type of object that you want to present and style in Geoserver. This means that from each kml file, you will end up with several files depending on your classification of object types.

Not a straightforward job for off-the-shelf tools. Hopefully, if all the 2.500 kml files are created with the same application, they will have the same structure. In that case, you shall need a detailed analysis of this structure and lots of custom scripting.


Open the kml and look inside it sounds like all you really want is the data as the other posters have suggested the styles are not on the cards so your problem is conversion of all the files which are essentially just text files learn some python

then hack something like this into shape: https://gist.github.com/linwoodc3/0306734dfe17076dfd34e09660c198c0

Your Answer

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

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