Hi, The best I can suggest to do by using just GDAL utilities is to run this kind of ogrinfo command for each text field that you have in the shapefile schema:
ogrinfo my_shape.shp -sql "alter table my_shape alter column STRING_1 TYPE character(254)" (right, the max length is 254). -Jukka Rahkonen- -----Alkuperäinen viesti----- Lähettäjä: matteo <matteo.ghe...@gmail.com> Lähetetty: perjantai 8. lokakuuta 2021 11.20 Vastaanottaja: Rahkonen Jukka (MML) <jukka.rahko...@maanmittauslaitos.fi>; Even Rouault <even.roua...@spatialys.com>; gdal-dev@lists.osgeo.org Aihe: Re: [gdal-dev] ogr2ogr changes field length Hi Jukka, > The strings fields are created by default with width 80. If there are longer > strings in the data the width is automatically extended up till 255 > characters that is the maximum that dBase format supports. If strings are > shorter than 80 charaters it is possible to use RESIZE and shrink the width > to match the longest string used in that field. > > If you need better control on field widths I suppose you must create an empty > shapefile for ogr2ogr to append by your own code. > > # Add a new field. > field_defn = ogr.FieldDefn('NEWFLD', ogr.OFTString) > field_defn.SetWidth(12) > > Do you have some concrete problem with field widths that you want to resolve? I'm "dumping" empty tables of a schema to shapefile and actually yes, I need that the fields with unlimited text set up in PG should be the maximum (so 254) in the final shapefiles. All the tables are empty so I guess this is the "problem" I have Cheers and thanks Matteo _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev