Forrest logo
back to the ogr2ogr tool

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

This command is using the ogr2ogr tool to convert a vector dataset from one coordinate reference system (CRS) to another CRS, and save the result as a GeoPackage (.gpkg) file.

Here is a breakdown of the command:

  • ogr2ogr: This is the command-line tool for converting between different geospatial file formats, provided by the GDAL library.

  • -s_srs ${EPSG:4326}: Specifies the source CRS for the input dataset. EPSG:4326 represents the WGS84 CRS, which is commonly used for representing geographic coordinates with latitude and longitude values.

  • -t_srs ${EPSG:3857}: Specifies the target CRS for the output dataset. EPSG:3857 corresponds to the Web Mercator projection, which is widely used for displaying maps on web applications.

  • -f GPKG: Specifies the output format as GeoPackage. GeoPackage is an open, non-proprietary format for storing geospatial data.

  • ${path-to-output}.gpkg: Specifies the path and filename for the output GeoPackage file. The ${path-to-output} placeholder should be replaced with the desired file path.

  • ${path-to-input}.gpkg: Specifies the path and filename for the input GeoPackage file. The ${path-to-input} placeholder should be replaced with the file path of the existing input dataset.

To use this command, you would need to have GDAL installed on your computer and have the ogr2ogr tool accessible from the command line.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the ogr2ogr tool