Difference between revisions of "Vector Format Conversion Using ogr2ogr"

From Tuflow
Jump to navigation Jump to search
Line 1: Line 1:
 
This page lists useful batch file examples for using ogr2ogr.exe. For complete documentation on this tool please visit '''<u>[https://gdal.org/programs/ogr2ogr.html#ogr2ogr gdal.org/programs/ogr2ogr]</u>'''<br>
 
This page lists useful batch file examples for using ogr2ogr.exe. For complete documentation on this tool please visit '''<u>[https://gdal.org/programs/ogr2ogr.html#ogr2ogr gdal.org/programs/ogr2ogr]</u>'''<br>
  
===Basic Format Conversion===
+
==Basic Format Conversion==
 
Format conversion can be done using "<tt>-f <format_name></tt>" then specifying the "<tt><destination_filename> <source_filename></tt>".<br>
 
Format conversion can be done using "<tt>-f <format_name></tt>" then specifying the "<tt><destination_filename> <source_filename></tt>".<br>
  
Line 9: Line 9:
 
<pre>ogr2ogr.exe -f "ESRI Shapefile" 2d_code_M01_R.shp 2d_code_M01.mif</pre>
 
<pre>ogr2ogr.exe -f "ESRI Shapefile" 2d_code_M01_R.shp 2d_code_M01.mif</pre>
  
===Bulk Format Conversion===
+
==Bulk Format Conversion==
 
<Br>
 
<Br>
 
'''Convert All Files Within Folder to GPKG'''<br>
 
'''Convert All Files Within Folder to GPKG'''<br>
Line 18: Line 18:
 
<pre>ogr2ogr.exe -f GPKG ./path/to/outdir all_layers.gpkg</pre>
 
<pre>ogr2ogr.exe -f GPKG ./path/to/outdir all_layers.gpkg</pre>
  
===Convert Single Layer From GPKG===
+
==Convert Single Layer From GPKG==

Revision as of 20:52, 11 April 2022

This page lists useful batch file examples for using ogr2ogr.exe. For complete documentation on this tool please visit gdal.org/programs/ogr2ogr

Basic Format Conversion

Format conversion can be done using "-f <format_name>" then specifying the "<destination_filename> <source_filename>".

SHP to GPKG

ogr2ogr.exe -f GPKG 2d_code_M01_R.gpkg 2d_code_M01_R.shp

MIF to SHP - assuming only one geometry type exists in the MIF file

ogr2ogr.exe -f "ESRI Shapefile" 2d_code_M01_R.shp 2d_code_M01.mif

Bulk Format Conversion


Convert All Files Within Folder to GPKG

ogr2ogr.exe -f GPKG all_layers.gpkg ./path/to/dir

Convert All Files Within Folder to GPKG with Wildcard

ogr2ogr.exe -f GPKG all_layers.gpkg ./path/to/dir/*.shp

Convert All Files From a GPKG to a SHP

ogr2ogr.exe -f GPKG ./path/to/outdir all_layers.gpkg

Convert Single Layer From GPKG