Forrest logo
back to the ogr2ogr tool

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

The command "ogr2ogr" is a utility command in GDAL (Geospatial Data Abstraction Library) that is used to convert and transform various geospatial data formats.

In this specific command, the "-spat" option is used to specify a spatial extent or a bounding box. The "min_x" and "min_y" values represent the minimum longitude and latitude coordinates respectively, while the "max_x" and "max_y" values represent the maximum longitude and latitude coordinates respectively. This option is used to subset or filter the input data based on the specified spatial extent.

The "-f" option is used to specify the output format, in this case, "GPKG" which stands for GeoPackage. GeoPackage is an open standard format for storing geospatial data.

The "${path-to-output}.gpkg" represents the output file path and name with the .gpkg extension for the GeoPackage file.

Similarly, the "${path-to-input}.gpkg" represents the input file path and name with the .gpkg extension for the GeoPackage file.

Overall, this command is used to subset or filter the input GeoPackage file based on a specified spatial extent and save the resulting data into a new GeoPackage file. The resulting file will contain only the features that fall within the specified bounding box.

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