Opened 6 years ago

Closed 6 years ago

#7112 closed defect (fixed)

Switch the default output format from Shapefile to GeoPackage

Reported by: jachym Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: normal Keywords: ESRI Shapefile, GeoPackage, GPKG
Cc:

Description

Hi. I'm attaching patch, which changes the default output vector format from ESRI Shapefile to OGC GeoPackage.

I've come trough most of the tools, but I expect, there are more. If you point me to missing code parts, I'll try to change them too.

Thank you for your help

Attachments (1)

shp2gpkg.diff (5.4 KB ) - added by jachym 6 years ago.

Download all attachments as: .zip

Change History (5)

by jachym, 6 years ago

Attachment: shp2gpkg.diff added

comment:1 by Even Rouault, 6 years ago

There's some intersection with https://trac.osgeo.org/gdal/wiki/rfc70_output_format_guess , which basically removes (or reduce it to a minimum proportion) any need for a default output format.

With your change, "ogr2ogr out.shp in.geojson" will generate a GeoPackage file called out.shp, which is unexpected, and violates a GeoPackage requirement that requires the .gpkg extension. And this would be quite a disruptive change for a lot of existing scripts.

With RFC70 (unimplemented yet), "ogr2ogr out.shp in.geojson" would generate a shapefile, and "ogr2ogr out.gpkg in.geojson" a GeoPackage. "ogr2ogr out in_with_several_layers.gml" would continue to create a 'out' directory with a shapefile per input layer in it.

comment:2 by jachym, 6 years ago

Hi Even,

whatever you think is the best.

I agree, having "guessing" mechanism of output file type would probably be the best option

P.S. Just asking: is there any reason, why GDAL interprets directory with shapefiles as data source with layers, but this does not apply on directory with geopackages?

comment:3 by Jukka Rahkonen, 6 years ago

About your question, initial reason is probably historical and I guess that it has been made so to help conversion to/from formats which support multiple layers. Unlike shapefiles geopackage can have however many layers so there is no such need. In addition I guess it could be complicated to handle the situation because either you need to open an own connection for each gpkg in the directory or to use one gpkg as a master and attach the other geopackages into that. I believe that it would get complicated to add new layers into such bunch-of-packages.

Last edited 6 years ago by Jukka Rahkonen (previous) (diff)

comment:4 by Even Rouault, 6 years ago

Resolution: fixed
Status: newclosed

In 40774:

RFC 70: Guess output format from extension of output filename, if no explicit format passed to C++ or Python utilities (also fixes #7112)

Note: See TracTickets for help on using tickets.