0

I'd like to load a .shp and set the data type of one of the fields. I thought something like this would work:

uri = 'C:/myfile.shp?field=myfield:integer'
vlay = QgsVectorLayer(uri ,'some_name','ogr')

But the vlay loads empty (without error). Dropping everything in the uri after the '?' loads fine. I could do some data type changes after loading from the file, but I'm assuming its cleaner to do this during the call to ogr.

Where can I find documentation on the proper formatting of this uri string? (for ogr).

How can I load a .shp and have a field recognized as a specified type?

Your Answer

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

Browse other questions tagged or ask your own question.