You can use the gdal
and ogr
command lines utilities.
More info at:
For example, to convert between two vector layers (Shapefile to KML) you could use the following command line:
ogr2ogr -f KML output.kml input.shp
Another option is to call this same line from python in the following way:
import os
import subprocess
os.chdir(r"directory with the files")
result = subprocess.call('ogr2ogr -f KML output.kml input.shp')
In the case of raster files you can use the gdal_translate
utility. For example to convert a GeoTIFF to a NetCDF file you can use:
gdal_translate -of NetCDF input.tif output.nc
or calling it form python:
import os
import subprocess
os.chdir(r"directory with the files")
result = subprocess.call('gdal_translate -of NetCDF input.tif output.nc')
Note: be aware that the are multiple creations options for each one of these utilities and that not every format support the same things. You should check out the documentation for the ogr2ogr
and gdal_translate
utilities.