TileDB-Inc / TileDB-Py

Python interface to the TileDB storage engine
MIT License
181 stars 32 forks source link

Can't read attributes of type DataType.GEOM_WKB / GEOM_WKT with pytiledb 0.28 #1956

Closed rouault closed 3 weeks ago

rouault commented 2 months ago

with pytiledb 0.28, I get the following exception on a SparseArray with a GEOM_WKB attribute poly.tiledb.zip

>>> import tiledb
>>> db = tiledb.open('poly.tiledb')
>>> db.schema
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/even/gdal/gdal/build_cmake/pytiledb_0_28/lib/python3.8/site-packages/tiledb/array_schema.py", line 427, in __repr__
    output.write(f"    {repr(self.attr(i))},\n")
  File "/home/even/gdal/gdal/build_cmake/pytiledb_0_28/lib/python3.8/site-packages/tiledb/attribute.py", line 278, in __repr__
    attr_dtype = self.dtype
  File "/home/even/gdal/gdal/build_cmake/pytiledb_0_28/lib/python3.8/site-packages/tiledb/attribute.py", line 161, in dtype
    return DataType.from_tiledb(self._tiledb_dtype, self._ncell).np_dtype
  File "/home/even/gdal/gdal/build_cmake/pytiledb_0_28/lib/python3.8/site-packages/tiledb/datatypes.py", line 64, in from_tiledb
    base_dtype = _TILEDB_TO_NUMPY[tiledb_type]
KeyError: <DataType.GEOM_WKB: 42>
kounelisagis commented 2 months ago

Will be fixed by #1912.

kounelisagis commented 3 weeks ago

Seems to work for me after merging the PR.

>>> import tiledb
>>> db = tiledb.open('poly.tiledb')
>>> db.schema
ArraySchema(
  domain=Domain(*[
    Dim(name='_X', domain=(-40071412.625353545, 40071412.625353545), tile=8014282.525070709, dtype='float64'),
    Dim(name='_Y', domain=(-40071412.625353545, 40071412.625353545), tile=8014282.525070709, dtype='float64'),
  ]),
  attrs=[
    Attr(name='FID', dtype='int64', var=False, nullable=False, enum_label=None),
    Attr(name='wkb_geometry', dtype='wkb', var=True, nullable=False, enum_label=None),
    Attr(name='AREA', dtype='float64', var=False, nullable=True, enum_label=None),
    Attr(name='EAS_ID', dtype='int64', var=False, nullable=True, enum_label=None),
    Attr(name='PRFEDEA', dtype='<U0', var=True, nullable=True, enum_label=None),
  ],
  cell_order='row-major',
  tile_order='row-major',
  capacity=10000,
  sparse=True,
  allows_duplicates=True,
)