OSGeo4W shell solution
IMHO the simplest way to extract the attribute table properties (schema) consists into opening the OSGeo4W shell ('cause you're on win os), change directory to your data folder and simply type something like:
ogrinfo -so inputLayerName.shp inputLayerName
It will show you the summary information like projection, schema, feature count and extents. Then, because you have a bunch of shapefiles, you can do a FOR
cycle like the following:
FOR %f IN (*.shp) DO ogrinfo -so %f %~nf >> properties.txt
This returns one txt-file with the properties of all the shapefiles in a directory (because the output redirection with >>
appends each single output to the properties.txt
file).
Alternatively, if you're interested in one properties file for each shapefile:
FOR %f IN (*.shp) DO ogrinfo -so %f %~nf > %~nf_properties.txt
About the standardization, there are several techniques. I suggest you to use the RESIZE
layer creation option after the merge in order to resize fields to their optimal size (e.g. text fields with excessive length will be shortened). For instance:
ogr2ogr -lco RESIZE=yes merge_resized.shp merge.shp
Processing script solution
Open the Processing toolbox in QGIS, create a new script (clicking on Scripts
--> Tools
--> Create new script
) and type:
##ogrinfo (summary only)=name
##input=vector
##output=output file
import os, subprocess
head, tail = os.path.split(input)
inputname = os.path.splitext(tail)[0]
cmd = 'ogrinfo -so ' + input + ' ' + inputname + ' > ' + output
subprocess.check_call(cmd, shell=True)
Save it as you like, e.g. ogrinfo_so.py
. Then, a new script ogrinfo (summary only)
will appear in the Processing toolbox --> Scripts
--> User script
group. It can be executed as it is or in batch mode.
The same operation is possible in order to resize the field length, as described before:
##Resize fields=name
##input=vector
##output=output vector
import subprocess
cmd = 'ogr2ogr -lco RESIZE=YES ' + output + ' ' + input
subprocess.check_call(cmd, shell=True)
A new script called Resize fields
will be available in the Processing toolbox --> Scripts
--> User scripts
group. Enjoy it!