Forrest logo
back to the ogr2ogr tool

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

The given command is using the ogr2ogr utility, which is part of the GDAL (Geospatial Data Abstraction Library) toolkit. This command is used to convert data from a CSV file format to a GeoPackage (.gpkg) file format.

Here's a breakdown of the command:

  • ogr2ogr: This is the command-line utility used for data conversion and manipulation in GDAL.
  • -f GPKG: Specifies the output format as GeoPackage.
  • ${path-to-output}.gpkg: The path and filename where the output GeoPackage file will be saved. You would need to replace ${path-to-output} with the desired directory path.
  • ${path-to-input}.csv: The path and filename of the input CSV file that you want to convert. Again, you would need to replace ${path-to-input} with the actual directory path.
  • -oo X_POSSIBLE_NAMES=${longitude}: Specifies the column name in the CSV file that contains the longitude values. Replace ${longitude} with the actual column name.
  • -oo Y_POSSIBLE_NAMES=${latitude}: Specifies the column name in the CSV file that contains the latitude values. Replace ${latitude} with the actual column name.
  • -a_srs ${EPSG:4326}: Specifies the spatial reference system (SRS) of the output file. In this case, EPSG:4326 represents the WGS 84 coordinate system, which is commonly used for latitude and longitude data.

By executing this command, ogr2ogr will read the specified CSV file, extract the longitude and latitude values from the respective columns, convert them into a GeoPackage format, and save the resulting file at the specified output path.

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