Thanks a lot !

If you want to use only native python functions you can do like this.

binary_as_hex_string = bytes_value.hex()
feature.SetFieldBinaryFromHexString(field_name, binary_as_hex_string)

To restore bytes_value to bytes type :

bytes_value = bytes.fromhex(binary_as_hex_string)



Le mer. 16 déc. 2020 à 22:28, Even Rouault <[email protected]> a
écrit :

> Guilhain,
>
> On mercredi 16 décembre 2020 21:52:41 CET Guilhain Averlant wrote:
> > I wrote a ticket on gis.stackexchange.combut I didn't get a satisfactory
> > answer, so I ask my question here.
> >
> > I'm trying to create a memory layer with gdal/ogr python that contains a
> > Binary Field.
> >
> > But I didn't succeed, where am I wrong?
>
> Probably nothing. I'm not sure why we don't have an override for this.
> Perhaps
> because OFTBinary is rather exotic and nobody strongly needed it before.
> Perhaps some (past) Python2/3 dilemna too
>
> You can use f.SetFieldBinaryFromHexString(field_name,
>
>                         binary_as_hex_string)
>
> where e.g. binary_as_hex_string = binascii.hexlify(b'hello world')
>
> Even
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
>


-- 
Guilhain AVERLANT
119 rue Manin
75019 PARIS
06 28 22 83 05
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to