[gdal-dev] ogr2ogr: dxf to postgis, is it possible to record dxf filename?

Pietro Rossin pierigis at gmail.com
Mon May 13 02:26:02 PDT 2013


Hello all
I must convert lots of dxf files to a postgis table
I wrote a python script to process a folder/subfolder and then create a
table into a postgis database and to load there all the features coming from
each dxf.
This script handle each single dxf file so I can track its name during the
loop process.
My question is,
is it possible to write the filename to the postgis table during each loop?

my loop is for the first dxf file:
ogr2ogr --config DXF_INLINE_BLOCKS FALSE --config DXF_MERGE_BLOCK_GEOMETRIES
FALSE -f "PostgreSQL" PG:"host= ' + host + " user=" + user + " dbname=" +
dbname + " password="+ pword + "\" " +" -lco DIM=3 " + file + " -where
\"Layer NOT LIKE 'X%'\"" +" -overwrite -a_srs EPSG:" + epsg + " entities"

All the others:

'ogr2ogr --config DXF_INLINE_BLOCKS FALSE --config
DXF_MERGE_BLOCK_GEOMETRIES FALSE -f "PostgreSQL" PG:"host= '	+ host + "
user=" + user + " dbname=" + dbname + " password="+ pword + "\" " + file + "
-where \"Layer NOT LIKE 'X%'\"" +" -append " +  "entities"

in_workspace, host, dbname, user, pword, epsg are parameters asked at the
beginning of the process, file comes from  a for loop process.

This creates a postgis table like this:
  ogc_fid serial NOT NULL,
  wkb_geometry geometry(GeometryZ,3004),
  layer character varying,
  subclasses character varying,
  extendedentity character varying,
  linetype character varying,
  entityhandle character varying,
  text character varying,
  blockname character varying,
  blockscale double precision[],
  blockangle double precision


So, How can I tell the script to add a field (let's say filename) in the
first passage and to fill it with file name values?
Sorry, but i'm not so skilled in python/ogr coding..
Thanks to all for any help
Pietro



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/ogr2ogr-dxf-to-postgis-is-it-possible-to-record-dxf-filename-tp5052840.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list