LinuxCommandLibrary

ogr2ogr

converts vector geospatial data

TLDR

Convert shapefile to GeoJSON

$ ogr2ogr -f "GeoJSON" [output.json] [input.shp]
copy
Convert GeoJSON to shapefile
$ ogr2ogr -f "ESRI Shapefile" [output.shp] [input.json]
copy
Reproject data
$ ogr2ogr -t_srs EPSG:4326 [output.shp] [input.shp]
copy
Import to PostGIS
$ ogr2ogr -f "PostgreSQL" PG:"dbname=[db]" [input.shp]
copy
Select specific fields
$ ogr2ogr -select [field1,field2] [output] [input]
copy

SYNOPSIS

ogr2ogr [options] dst src

DESCRIPTION

ogr2ogr converts vector geospatial data. Supports many formats.
The tool transforms between GIS formats. Part of GDAL suite.

PARAMETERS

DST

Destination dataset.
SRC
Source dataset.
-f FORMAT
Output format.
-t_srs SRS
Target coordinate system.
-s_srs SRS
Source coordinate system.
-select FIELDS
Select fields.
-where EXPR
Filter expression.
--help
Display help information.

CAVEATS

Part of GDAL. Format support varies. Coordinate system important.

HISTORY

ogr2ogr is part of GDAL/OGR library for geospatial data processing.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community