1

can anyone tell me how to add an attribute of type Date during a shapefile creation?

For Integer works fine using the following code:

Layer1.CreateField(ogr.FieldDefn('NumberIndv', ogr.OFTInteger))

The same for String and Real, changing the type to ogr.OFTString or ogr.OFTReal.

What should I use for Date type?

1

You could use ogr.OFTDate to create a new date-type field so your line would look something like:

Layer1.CreateField(ogr.FieldDefn('DATE', ogr.OFTDate))

This and other OGR field types are documented in

http://www.gdal.org/ogr__core_8h.html#a787194bea637faf12d61643124a7c9fc

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.