[gdal-dev] DXF to Postgis using ogr2ogr

Ralf Suhr Ralf.Suhr at itc-halle.de
Mon Dec 19 03:58:31 EST 2011


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/623db32e/attachment.html


More information about the gdal-dev mailing list