[gdal-dev] DXF to Postgis using ogr2ogr

Ralf Suhr Ralf.Suhr at itc-halle.de
Mon Dec 19 11:52:20 EST 2011


http://www.gdal.org/ogr/drv_dxf.html

Does ogrinfo print out the "blocks" layer?
ogrinfo --config DXF_INLINE_BLOCKS FALSE File.dxf 
INFO: Open of `File.dxf'
      using driver `DXF' successful.
1: blocks
2: entities

To see what can be imported by ogr use a dxfviewer that display only the model 
space. I have tested ogr with dxf version up to AC1018 without problems except 
the paper space.


Gr
Ralf

On Montag 19 Dezember 2011 17:21:58 Bob Pawley wrote:
> Thanks Ralf
> 
> So far, I haven’t been able to populate the block columns unless I use a
> DXF file which has been exploded before saving.
> 
> In all of my searching, I have not come across your suggestion of
> dereferencing the block. Can you point me to some documentation?
> 
> Bob
> 
> 
> From: Ralf Suhr
> Sent: Monday, December 19, 2011 12:58 AM
> To: gdal-dev at lists.osgeo.org
> Cc: Bob Pawley
> Subject: Re: [gdal-dev] DXF to Postgis using ogr2ogr
> 
> Hi Bob,
> 
> 
> 
> the dxf driver writes to tables "entities" and "blocks". You have to
> dereference the block layer yourself.
> 
> 
> 
> SELECT Translate( Scale( Rotate((Dump(b.wkb_geometry)).geom, e.blockangle /
> 180 * PI()), e.blockscale[1], e.blockscale[2]), ST_X(e.wkb_geometry),
> ST_Y(e.wkb_geometry)) AS wkb_geometry,
> 
> CASE WHEN b.ogr_style IS NOT NULL THEN b.ogr_style ELSE e.ogr_style END AS
> ogr_style,
> 
> e.layer,
> 
> e.linetype,
> 
> e.subclasses,
> 
> b.text
> 
> FROM entities e
> 
> INNER JOIN
> 
> blocks b USING (blockname);
> 
> 
> 
> Sometimes you have blocks with world coordinates and no connection in
> entities.
> 
> SELECT (Dump(b.wkb_geometry)).geom AS wkb_geometry,
> 
> b.ogr_style,
> 
> b.layer,
> 
> b.linetype,
> 
> b.subclasses,
> 
> b.text
> 
> FROM blocks b
> 
> WHERE blockname NOT IN
> 
> (
> 
> SELECT DISTINCT blockname
> 
> FROM entities
> 
> WHERE blockname IS NOT NULL
> 
> );
> 
> 
> 
> Some newer DXF Formats can have features in paper space. This is now not
> supported by ogr2ogr.
> 
> 
> 
> 
> 
> Gr
> 
> Ralf
> 
> On Freitag 16 Dezember 2011 22:14:38 Bob Pawley wrote:
> > I have imported a dxf file into Postgis using the following command line
> > -
> > 
> > 
> > 
> > set DXF_INLINE_BLOCKS=FALSE&set DXF_MERGE_BLOCK_GEOMETRIES=FALSE&set
> > 
> > PGCLIENTENCODING=LATIN1&&ogr2ogr -f "PostgreSQL" PG:"host=localhost
> > 
> > user=postgres dbname=dbname password=pass" W_Works.dxf -nln Import_PID
> > 
> > -overwrite –skipfailures
> > 
> > 
> > 
> > All geometries are intact.
> > 
> > 
> > 
> > However, the text is part of the Linestring layer and not in the text
> > 
> > column of the Postgresql table.
> > 
> > 
> > 
> > Is this to be expected?
> > 
> > 
> > 
> > Is there some way of screening out the text as text and point geometry?
> > 
> > 
> > 
> > Bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20111219/60186d1e/attachment-0001.html


More information about the gdal-dev mailing list