Skip to content

gdal vector create #14028

@geographika

Description

@geographika

Feature description

It seemed like a simple task, but had difficulty working out how to create a new empty dataset with gdal vector. I think the current recommended approach would be using gdal vector sql as described in #12951

gdal vector sql -i :memory: -o out.gpkg --output-layer=test --sql "select sqlite_version()"

Would it be useful to have a vector equivalent of gdal raster create?

This could use many of the parameters found in other tools such as gdal vector set-geom-type and gdal vector set-field-type. Providing a list of field definitions however could make this approach complicated:

gdal vector create \
  --format GPKG \
  --crs=EPSG:4326 \
  --geometry-type=POINT
  --output-layer test 
  --field name:String(80) \
  --field population:Integer \
  cities.gpkg

This could also take a --sql parameter to define the fields in the output.

Additional context

A real-world use of this tool would be to create standardised empty geopackages for users to add features to.

There may be good reasons not to have a create option, in which case I can close this and suggest the gdal vector sql approach in a cookbook page.

If there was a standardised way of defining fields, an associated command that would be useful would be gdal vector add-field to add a new field to an existing dataset.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions