ogrmerge
いくつかのベクターデータセットを1つにマージします.
概要
ogrmerge [--help] [--help-general]
-o <out_dsname> <src_dsname> [<src_dsname>]...
[-f format] [-single] [-nln <layer_name_template>]
[-update | -overwrite_ds] [-append | -overwrite_layer]
[-src_geom_type <geom_type_name>[,<geom_type_name>]...]
[-dsco <NAME>=<VALUE>]... [-lco <NAME>=<VALUE>]...
[-s_srs <srs_def>] [-t_srs <srs_def> | -a_srs <srs_def>]
[-progress] [-skipfailures] [--help-general]
オプション -single に特有のオプション:
[-field_strategy FirstLayer|Union|Intersection]
[-src_layer_field_name <name>]
[-src_layer_field_content <layer_name_template>]
説明
Added in version 2.2.
ogrmerge は複数のベクターデータセットを入力として受け取り,それぞれが1つ以上のベクターレイヤーを持ち,それらをターゲットデータセットにコピーします.
基本的に2つのモードがあります:
デフォルトのモードでは,各入力ベクターレイヤーが別々のレイヤーとしてターゲットデータセットにコピーされます.
another one, activated with the -single switch, where the content of all input vector layers is appended into a single target layer. This assumes that the schema of those vector layers is more or less the same.
Internally this generates a VRT -- Virtual Format file, and if the
output format is not VRT, final translation is done with ogr2ogr
or gdal.VectorTranslate()
. So, for advanced uses, output to VRT,
potential manual editing of it and ogr2ogr can be done.
注釈
ogrmerge is a Python utility, and is only available if GDAL Python bindings are available.
- --help
Show this help message and exit
- --help-general
Gives a brief usage message for the generic GDAL commandline options and exit.
- -o <out_dsname>
Output dataset name. Required.
- <src_dsname>
One or several input vector datasets. Required
- -f <format>
Select the output format. Starting with GDAL 2.3, if not specified, the format is guessed from the extension (previously was ESRI Shapefile). Use the short format name
- -single
If specified, all input vector layers will be merged into a single one.
- -nln <layer_name_template>
Name of the output vector layer (in single mode, and the default is "merged"), or template to name the output vector layers in default mode (the default value is
{AUTO_NAME}
). The template can be a string with the following variables that will be substituted with a value computed from the input layer being processed:{AUTO_NAME}
: equivalent to{DS_BASENAME}_{LAYER_NAME}
if both values are different, or{LAYER_NAME}
when they are identical (case of shapefile).{DS_NAME}
: name of the source dataset{DS_BASENAME}
: base name of the source dataset{DS_INDEX}
: index of the source dataset{LAYER_NAME}
: name of the source layer{LAYER_INDEX}
: index of the source layer
- -update
Open an existing dataset in update mode.
- -overwrite_ds
Overwrite the existing dataset if it already exists (for file based datasets)
- -append
Open an existing dataset in update mode, and if output layers already exist, append the content of input layers to them.
- -overwrite_layer
Open an existing dataset in update mode, and if output layers already exist, replace their content with the one of the input layer.
- -src_geom_type <geom_type_name>[,<geom_type_name>]...
Only take into account input layers whose geometry type match the type(s) specified. Valid values for geom_type_name are GEOMETRY, POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION, CIRCULARSTRING, CURVEPOLYGON, MULTICURVE, MULTISURFACE, CURVE, SURFACE, TRIANGLE, POLYHEDRALSURFACE and TIN.
- -dsco <NAME>=<VALUE>
Dataset creation option (format specific)
- -lco <NAME>=<VALUE>
Layer creation option (format specific)
- -a_srs <srs_def>
Assign an output SRS
- -t_srs <srs_def>
Reproject/transform to this SRS on output
- -s_srs <srs_def>
Override source SRS
- -progress
Display progress on terminal. Only works if input layers have the "fast feature count" capability.
- -skipfailures
Continue after a failure, skipping the failed feature.
- -field_strategy FirstLayer|Union|Intersection
Only used with
-single
. Determines how the schema of the target layer is built from the schemas of the input layers. May be FirstLayer to use the fields from the first layer found, Union to use a super-set of all the fields from all source layers, or Intersection to use a sub-set of all the common fields from all source layers. Defaults to Union.
- -src_layer_field_name <name>
Only used with
-single
. If specified, the schema of the target layer will be extended with a new field 'name', whose content is determined by -src_layer_field_content.
- -src_layer_field_content <layer_name_template>
Only used with
-single
. If specified, the schema of the target layer will be extended with a new field (whose name is given by-src_layer_field_name
, or 'source_ds_lyr' otherwise), whose content is determined bylayer_name_template
. The syntax oflayer_name_template
is the same as for-nln
.
Examples
Create a VRT with a layer for each input shapefiles
ogrmerge -f VRT -o merged.vrt *.shp
Same, but creates a GeoPackage file
ogrmerge -f GPKG -o merged.gpkg *.shp
Concatenate the content of france.shp and germany.shp in merged.shp, and adds a 'country' field to each feature whose value is 'france' or 'germany' depending where it comes from.
ogrmerge -single -o merged.shp france.shp germany.shp -src_layer_field_name country