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

Ralf Suhr Ralf.Suhr at itc-halle.de
Mon May 13 09:01:29 PDT 2013


Hello Pietro,

you can use the -sql switch to add a extra value.

ogrinfo -sql "SELECT 'filename' AS source,* FROM entities" File.dxf


Gr
Ralf

On Montag 13 Mai 2013 11:26:02 Pietro Rossin wrote:
   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.
   _______________________________________________
   gdal-dev mailing list
   gdal-dev at lists.osgeo.org
   http://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130513/dd4a0f18/attachment-0001.html>


More information about the gdal-dev mailing list