-
Notifications
You must be signed in to change notification settings - Fork 18
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
ENH: Add index_as_fid option to write_dataframe? #287
Comments
Do you know if GDAL exposes some information or metadata about this? For example so that we can raise an error if the file format actually does not support it? |
Yes, if OGR_L_GetFIDColumn() returns "", the file type cannot save Examples:
|
Nice, in that case this sounds as a good option to me. |
I just encountered another way to save the index of the GeoDataFrame as "fid" (primary key) in a GPKG: if the name of the index is "fid" it will also be saved as "fid" in the file. PS: Fiona treats this the same way. xref: geopandas/geopandas#3217 |
(moved this to the next milestone) |
There is an
fid_as_index
option inread_dataframe
to be able to... read thefid
. However, there is no explicit option to e.g.index_as_fid
inwrite_dataframe
to write it again.For e.g. shapefiles writing fid's is not relevant at all as they don't save fid's.
For Geopackages there is a workaround: if you add the index as a column named "fid" to the dataframe you will write the
fid
.Not sure if an explicit option is needed... an alternative could be to just document the "workaround" or use this issue as documentation :-).
The text was updated successfully, but these errors were encountered: