-
Notifications
You must be signed in to change notification settings - Fork 203
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
Writing np.int64 or np.int32 scalars raises an error #365
Comments
@fmaussion That's because these are aliases for the builtin python types. Also note that specifying 'str' in the schema does not matter, you get the same error when specifying 'int'. It is the numpy scalar that cannot be handled.
|
@fmaussion thanks for the report. Currently, Fiona obliges developers to cast values to Python types that map to the OGR field types. If your feature property was |
@sgillies thanks! Intuitively, I would say that as a scientific tool such as Fiona should be able to handle numpy dtypes (somehow, At the same time, my use case is a bit of a corner case (slight misuse of GeoSeries and GeoDataFrames with Geopandas), and if nobody complained until now this is probably not very relevant for most of your users. So that's up to you I would say! |
I would certainly like Geopandas to support int64 writes, I am working with spatial data the has long int64 integer keys, I would like to be able to retain the datatype throughout instead of converting everything to string. In my case though I am limited to how many digits are supported by the Shapefile standard: I'm pretty sure that Fiona will return an exception if the data being written does not conform to the standard. a 12-digit integer will need to be converted to string before Fiona will write it. |
@jasonwheritage no need to convert to strings : python's |
Just use float:
before writing convert the np.float32 value to float. |
Hi, this is on python3 with fiona
1.7.0.post2
. Attempting to write properties as numpy scalars can fail for certain types. The following example reproduces the problem:will raise:
Note that
np.int
ornp.float
would work. (see geopandas/geopandas#348 and pandas-dev/pandas#13468 for more background).The text was updated successfully, but these errors were encountered: