-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Write columns with "short" type in gdb with OpenFileGDB driver #1321
Comments
@remi-braun Happy new year! OGR doesn't have a short integer type, only 32 and 64-bit integers. Neither does Fiona at this time, thus your layers are being constructed with 32 bit wide integer fields. I don't think there is any logic in the GDB driver to reduce the width at creation time. Do you see different behavior if you use ogr2ogr or pyogrio? |
Happy new year to you too 😉 I think pyogrio doesn't handle schemas, so I haven't tried. What's weird is that for ESRI a short isn't an And we made it all work for Shapefiles, so other drivers handle this mechanism. |
Pyogrio doesn't support the import geopandas
from shapely.geometry import Point
gdf = geopandas.GeoDataFrame({"col": np.array([1, 2, 3], dtype="int16"), "geometry": [Point(i, i) for i in range(3)]})
gdf
# col geometry
# 0 1 POINT (0 0)
# 1 2 POINT (1 1)
# 2 3 POINT (2 2)
gdf.to_file("test_gdb.gdb", driver="OpenFileGDB", engine="pyogrio") I am not fully sure how then to check independently whether it has actually written the correct data type to the OpenFileGDB, but
|
And if you want to control the exact OpenFIleGDB types being used by GDAL, it seems to have a creation option @sgillies OGR indeed only uses int32 or int64 data in its internal data model, but there is the concept of "sub type" to annotate a type with additional information (I assume it doesn't change how the data is represented internally, still int32, but then it is used as a hint when writing): https://gdal.org/api/vector_c_api.html#_CPPv415OGRFieldSubType, and there is has a Lines 102 to 105 in 195579d
and could set it like is already done for bool subtype as well: Lines 1293 to 1295 in 195579d
|
@remi-braun I've begun working on this and have 2 questions.
|
@sgillies thanks for taking this seriously!
|
* Add an "int16" property type Resolves #1321 * Update reference in change log * Code cleanup to improve readability
* Add an "int16" property type Resolves #1321 * Update reference in change log * Code cleanup to improve readability * Refactor OGR and Fiona feature builders to replace ugly conditionals Instead we dispatch to cdef classes kept in several new mappings. * Refactor OGR and Fiona feature builders to replace ugly conditionals Instead we dispatch to cdef classes kept in several new mappings. * xfail a JSON property test for GDAL < 3.5 * xfail another * New feature builder implementation with cleaner OO logic * Fix imports and update change log * Fix detection of tz support in DateTimeField * Register property setters to OGR field type and value type To reproduce behavior of Fiona 1.9 * Make lists JSON serializable
Hello,
I am currently struggling to write a column with a
short
type in a GDB.After some research, I found a way to write shapefiles with a difference between long a short integers with this solution (which works).
Expected behavior and actual behavior.
Both
'int32:4'
and'int32:10'
types in schema give along
column in a GDB, instead of giving ashort
and along
column.Steps to reproduce the problem.
Code
PS: I know I am using geopandas, but they implement seamlessly the Fiona schemas, this is why I am iting the issue here.
Output
Operating system
Windows
Fiona and GDAL version and provenance
Conda (conda-forge)
The text was updated successfully, but these errors were encountered: