Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: append new df to old GDB file failed #3285

Open
liuhao0826 opened this issue May 14, 2024 · 4 comments
Open

BUG: append new df to old GDB file failed #3285

liuhao0826 opened this issue May 14, 2024 · 4 comments

Comments

@liuhao0826
Copy link

i generate source openFileGDB with a geopandas dataframe used:
gpd_linestring_df.to_file(filename2, driver="OpenFileGDB")
and dtyps:
uid object
agmach_id object
calc_date object
work_start_time object
work_end_time object
work_area float64
geometry geometry
agmach_type_name object
pro_ent_name object
mdl_name object
feed_rate float64
machine_width float64
area_name object
parent_area_name object

then i with the same type df,used:gpd_linestring_df.to_file(filename2, driver="OpenFileGDB",mode='a')
i am sure the diff df is the same dtyps,why failed with:
File "fiona\ogrext.pyx", line 1397, in fiona.ogrext.WritingSession.writerecs
ValueError: Record does not match collection schema: ['uid', 'agmach_id', 'calc_date', 'work_start_time', 'work_end_time', 'work_area', 'agmach_type_name', 'pro_ent_name', 'mdl_name', 'feed_rate', 'machine_width', 'area_name', 'parent_area_name'] != []

@liuhao0826
Copy link
Author

generate old file path is ./linestring/北京市-202403010505.dgb
and it is generate sucess with
1715680518718

and append the same path failed;

@liuhao0826
Copy link
Author

I'm not very familiar with the GDB file format, and I also want to ask why the directory I generated is a directory that contains sub files. shouldn't it have only one main file?

@brendan-ward
Copy link
Member

ESRI File GDB is structured as a directory containing a lot of files. That is entirely expected here.

I'm not sure about why Fiona is failing here (probably an error to report there instead), as you are passing the same dataset each time, but this should be possible using engine='pyogrio' if you have that installed; it worked for me with the latest version of pyogrio / GDAL 3.8.3.

@liuhao0826
Copy link
Author

liuhao0826 commented May 15, 2024

ESRI File GDB is structured as a directory containing a lot of files. That is entirely expected here.

I'm not sure about why Fiona is failing here (probably an error to report there instead), as you are passing the same dataset each time, but this should be possible using engine='pyogrio' if you have that installed; it worked for me with the latest version of pyogrio / GDAL 3.8.3.

Although the geometry in my geopandas df is a linestring and polygon, when it is written to gdb and read out again, it shows that the geometry is a multilining and multipolygon, which causes the prompt format to not match and results in failure. Therefore, my current solution is to convert the linestring and polygon of the geometry in my df to multi (xx)
with the code:

gpd_convex_Hull_df = gpd.GeoDataFrame(pd_polygon_df, geometry="geometry", crs="EPSG:4326")
gpd_convex_Hull_df['geometry'] = gpd_convex_Hull_df['geometry'].apply(
lambda x: MultiPolygon([x]) if isinstance(x, Polygon) else x)
gpd_linestring_df = gpd.GeoDataFrame(pd_linestring_df, geometry="geometry", crs="EPSG:4326")
gpd_linestring_df['geometry'] = gpd_linestring_df['geometry'].apply(
lambda x: MultiLineString([x]) if isinstance(x, LineString) else x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants