Forrest logo
tool overview
On this page you find all important commands for the CLI tool ogr2ogr. If the command you are looking for is missing please ask our AI.

ogr2ogr

  1. ogr2ogr is a powerful command line tool used for converting geospatial data between different formats.
  2. It is part of the Geospatial Data Abstraction Library (GDAL), an open-source software library for handling various geospatial data formats.
  3. ogr2ogr supports over 70 data formats, including shapefiles, GeoJSON, KML, PostGIS, and many more.
  4. The tool allows you to convert data from one format to another, such as converting a shapefile to a GeoJSON file.
  5. ogr2ogr supports both vector and raster data, making it versatile for handling different types of geospatial data.
  6. It offers various data transformation capabilities, such as coordinate system transformation and spatial filtering.
  7. ogr2ogr allows you to perform spatial queries, extracting specific features or subsets of data based on spatial criteria.
  8. The command line tool provides options for data simplification, attribute selection, and attribute filtering during conversion.
  9. ogr2ogr is highly customizable, allowing users to specify output file properties, attribute mappings, and data transformation operations.
  10. It is widely used in geospatial data processing workflows, scripting, and automation due to its command line interface and flexibility.

List of commands for ogr2ogr:

  • ogr2ogr:tldr:309b1 ogr2ogr: Clip layers of a GeoPackage file to the given bounding box.
    $ ogr2ogr -spat ${min_x} ${min_y} ${max_x} ${max_y} -f GPKG ${path-to-output}.gpkg ${path-to-input}.gpkg
    try on your machine
    explain this command
  • ogr2ogr:tldr:6395f ogr2ogr: Convert a CSV file into a GeoPackage, specifying the names of the coordinate columns and assigning a coordinate reference system.
    $ ogr2ogr -f GPKG ${path-to-output}.gpkg ${path-to-input}.csv -oo X_POSSIBLE_NAMES=${longitude} -oo Y_POSSIBLE_NAMES=${latitude} -a_srs ${EPSG:4326}
    try on your machine
    explain this command
  • ogr2ogr:tldr:90ae5 ogr2ogr: Reduce a GeoJSON to features matching a condition.
    $ ogr2ogr -where '${myProperty > 42}' -f ${GeoJSON} ${path-to-output-geojson} ${path-to-input-geojson}
    try on your machine
    explain this command
  • ogr2ogr:tldr:eb106 ogr2ogr: Convert a Shapefile into a GeoPackage.
    $ ogr2ogr -f GPKG ${path-to-output}.gpkg ${path-to-input}.shp
    try on your machine
    explain this command
  • ogr2ogr:tldr:f6382 ogr2ogr: Load a GeoPackage into a PostGIS database.
    $ ogr2ogr -f PostgreSQL PG:dbname="${database_name}" ${path-to-input}.gpkg
    try on your machine
    explain this command
  • ogr2ogr:tldr:fcda1 ogr2ogr: Change coordinate reference system of a GeoPackage from `EPSG:4326` to `EPSG:3857`.
    $ ogr2ogr -s_srs ${EPSG:4326} -t_srs ${EPSG:3857} -f GPKG ${path-to-output}.gpkg ${path-to-input}.gpkg
    try on your machine
    explain this command
tool overview