I'm writing a shapefile using OGR in python, creating fields on-the-fly from a python data source. Creation of a new field requires an OGR data type, is there a mapping between OGR and python data types?
For example, this would be the norm:
new_field = ogr.FieldDefn('MYFLD', ogr.OFTInteger)Ideally:
ogr_datatype = get_ogr_data_type(python_data)new_field = ogr.FieldDefn('MYFLD', ogr_datatype)Currently my conversions are hard coded (e.g. int = ogr.OFTInteger), but this is a bit of a pain and relies on me coding all possible data types.
أكثر...
For example, this would be the norm:
new_field = ogr.FieldDefn('MYFLD', ogr.OFTInteger)Ideally:
ogr_datatype = get_ogr_data_type(python_data)new_field = ogr.FieldDefn('MYFLD', ogr_datatype)Currently my conversions are hard coded (e.g. int = ogr.OFTInteger), but this is a bit of a pain and relies on me coding all possible data types.
أكثر...