In this article we would be discussing about conversion of GeoJSON data to KML (Keyhole Markup Language). This conversion is required when you are using software such Google earth to see the data. KML works great with Google earth. There is simple step to Convert GeoJSON to KML using ogr2ogr utility from GDAL library. Before that we must go through specification of GeoJSON and KML.
Specification of GeoJSON – Convert GeoJSON to KML
Geojson data is open standard format, contains simple geographical feature with non-spatial data. In type element it has feature collection. That contains name, CRS (coordinate reference system) and features. These features can be line, point, polygon, Multi-Line string and multi-polygon.
Specification of KML- Convert GeoJSON to KML
The KML (Keyhole Markup language) this data format contains information in tags. SimpleField contains attribute information with name and type. Style tag contains the style of file as color of lines, points and polygons. Geometry is stored as coordinates in file.
Convert GeoJSON to KML using GDAL Utility-
The conversion requires Gdal utility. This utility can be installed in the system by following the given commands.
By typing ogr2ogr in command prompt you can get the following result. This result shows the presence of ogr2ogr utility in system.
To know the version of installed GDAL library you can type,
–> gdalinfo –version
Before executing the conversion command, you should check the drivers. The drivers can be checked by typing
–> ogr2ogr –formats
in your command prompt. Now check for the GeoJSON and KML driver.
After checking the drivers you can execute the following command.
–> ogr2ogr -f ‘KML’ -a_srs EPSG:4326 Output_fileName.kml Input_FileName.geojson
Output of Convert GeoJSON to KML-
The generated output file can be open in editor to see the content.
In the similar way you can also convert shape file to MIF, shapefile to sql and shape file to excel file.
You can also comment in given comment box for any query, help or suggestions.