4

GDAL introduces the geometry function OGR_G_BufferEx(OGRGeometryH, double dfDist, CSLConstList papszOptions) in version 3.10. The options are encoded as a list of key value pairs (key=value)

  • ENDCAP_STYLE=ROUND/FLAT/SQUARE
  • JOIN_STYLE=ROUND/MITRE/BEVEL
  • MITRE_LIMIT=double
  • QUADRANT_SEGMENTS=integer
  • SINGLE_SIDED=YES/NO as a string list in the C or C++ language context.

Question: Is there a description for the corresponding SQL syntax for the tool ogr2ogr in the SQLite dialect for the extended attributes (JOIN_STYLE, END_CAP)?

NOTE: I have noticed the gdal vector pipeline which is available since version 3.11. The command gdal vector buffer ... addresses the "extended" options

  • --endcap-style STYLES=round|flat|square (default: round)
  • --join-style STYLES=round|mitre|bevel (default: round)
  • --mitre-limit

etc. directly. But for the gdal vector sql ... calling context, no information is provided for the extended buffer context too.

3
  • The SQLite dialect can only run common SQLite functions sqlite.org/lang.html and SpatiaLite functions gaia-gis.it/gaia-sins/spatialite-sql-latest.html. Prelude statements as open options do not work in general case. They work if the source dataset is SQLite based (GeoPackage or SpatiaLite), but if source dataset is of some other format, using -dialect SQLite triggers a creation of a temporary SQLite database, and prelude statements are not applied to that. The "with" trick may work. I am curious to see an example, or maybe I will try myself. Commented Oct 14 at 6:35
  • @user30184: According to the GDAL documentation gdal.org/en/stable/user/sql_sqlite_dialect.html the "GDAL SQLite dialect" is not so straight forward as commented for SQLite/GeoPackage. There are different patches to resolve the syntax, addressing functions spatial indexes etc. on different levels of the SQL query (SELECT ogr_layer_Extent('poly') ...). The documentation is not comlete with regard to the geometric functions. Commented Oct 15 at 7:33
  • You are right, GDAL defines some additional functions for the SQLite dialect. The spatial index one gdal.org/en/stable/user/… is pure SpatiaLite, though. If you find issues in the documentation, please suggest edits. Every page has an Edit on GitHub button. Commented Oct 15 at 8:04

1 Answer 1

3

You're asking about a GDAL/OGR C function but linking to the spatialite based SQLite dialect which uses SQLite and spatialite functions, not GDAL/OGR C or C++ functions (some additional GDAL SQL functions are available though).

Instead, you can specify spatialite global buffer settings via:

E.g below I use both to set flat end caps on my buffered line:

# Non-SQLite format
ogr2ogr -sql "with P as (SELECT BufferOptions_SetEndCapStyle('FLAT')) SELECT id, ST_Buffer(geometry, 100) AS geometry FROM line, P" -dialect sqlite poly.shp line.shp

# GDAL 3.11+ and SQLite based formats only
ogr2ogr -sql "SELECT id, ST_Buffer(geom, 100) AS geom FROM line" -dialect sqlite -oo PRELUDE_STATEMENTS="SELECT BufferOptions_SetEndCapStyle('FLAT')" poly.shp line.gpkg 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.