gdal icon indicating copy to clipboard operation
gdal copied to clipboard

XLX/XLSX: point geometry from fields

Open landam opened this issue 8 months ago • 6 comments

Feature description

While CSV driver supports creating point geometry from fields (https://gdal.org/en/stable/drivers/vector/csv.html#building-point-geometries), the XLX/XLSX doesn't seem to support this feature (https://gdal.org/en/stable/drivers/vector/xlsx.html). Is there any particular reason why it's not supported by XLS/XLSX driver?

Additional context

No response

landam avatar Apr 18 '25 10:04 landam

Is there any particular reason why it's not supported by XLS/XLSX driver?

Such built-in logic needs to be implemented in each driver and thus has a initial and long term cost. Luckily there's a generic solution using a OGR VRT file like in https://gdal.org/en/stable/drivers/vector/vrt.html#example-odbc-point-layer

rouault avatar Apr 18 '25 10:04 rouault

Thanks for quick answer! It would be valuable to mention OGR VRT solution in XLX/XSLX documentation (add a new example)?

landam avatar Apr 18 '25 10:04 landam

Note: OGR VRT seems to be still limited when you what to create geography in PostGIS instead of geometry. While CSV supports geography type.

landam avatar Apr 18 '25 10:04 landam

While CSV supports geography type.

what makes you think so ? OGR itself (the abstraction) doesn't kow about PostGIS geography vs geometry, only the PostGIS driver does. The CSV driver itself is certainly not aware of that.

rouault avatar Apr 18 '25 11:04 rouault

<OGRVRTDataSource>
    <OGRVRTLayer name="lucas_grid">
        <SrcDataSource>LUCAS-Master-Grid.xlsx</SrcDataSource>
        <SrcLayer>Master_web</SrcLayer>
        <GeometryType>wkbPoint</GeometryType>
        <LayerSRS>WGS84</LayerSRS>
        <GeometryField encoding="PointFromColumns" x="X_WGS84" y="Y_WGS84"/>
    </OGRVRTLayer>
ogrinfo lucas_grid.vrt -so -al

works as expected:

INFO: Open of `lucas_grid.vrt'
      using driver `OGR_VRT' successful.

Layer name: lucas_grid
Geometry: Point

@rouault Thanks for support!

landam avatar Apr 18 '25 11:04 landam

If you know what to search, it is already documented in https://gdal.org/en/stable/drivers/vector/xlsx.html

Each sheet is presented as a OGR layer. No geometry support is available directly (but you may use the OGR VRT capabilities for that).

jratike80 avatar Apr 22 '25 19:04 jratike80