2

I want to export a PostgreSQL table of geometries in Multipoint Z to DXF using ogr2ogr

I tried this command

ogr2ogr -f "DXF" output.dxf PG:"host='127.0.0.1' port='5432' \
dbname='dbname' user='user' password='password'" -sql \
"select st_transform(st_geomfromewkb(decode(geometry_base64, 'base64')), 4326) as geom \
from my_table limit 1"

but get errors:

ERROR 1: No known way to write feature with geometry 'Multi Point'.
ERROR 1: Unable to write feature 0 from layer sql_statement.

ERROR 1: Terminating translation prematurely after failed
translation from sql statement.

1 Answer 1

3

DXF format does not really support multipoint geometry type and therefore GDAL DXF driver https://gdal.org/drivers/vector/dxf.html can't handle them. FME does support multipoints with a workaround by storing them as blocks https://docs.safe.com/fme/2018.1/html/FME_Desktop_Documentation/FME_ReadersWriters/acad/Geometry-Support-acad.htm

What you can do with ogr2ogr is to explode multipoints into simple points https://gdal.org/programs/ogr2ogr.html

-explodecollections

Produce one feature for each geometry in any kind of geometry collection in the source file

Proof of concept:

ogr2ogr -f dxf multi.dxf multipoint.jml 
ERROR 1: No known way to write feature with geometry 'Multi Point'.
ERROR 1: Unable to write feature 0 from layer multipoint.
ERROR 1: Terminating translation prematurely after failed translation of layer multipoint (use -skipfailures to skip errors)

ogr2ogr -f dxf multi.dxf multipoint.jml -explodecollections

Conversion succeeds, now check the result:

ogrinfo multi.dxf entities
INFO: Open of `multi.dxf'
      using driver `DXF' successful.

Layer name: entities
Geometry: Unknown (any)
Feature Count: 3
Extent: (500.000000, 360.000000) - (590.000000, 454.000000)
Layer SRS WKT:
(unknown)
Layer: String (0.0)
PaperSpace: Integer(Boolean) (0.0)
SubClasses: String (0.0)
Linetype: String (0.0)
EntityHandle: String (0.0)
Text: String (0.0)
OGRFeature(entities):0
  Layer (String) = 0
  SubClasses (String) = AcDbEntity:AcDbPoint
  EntityHandle (String) = 20000
  Style = PEN(c:#000000)
  POINT Z (590 454 1)

OGRFeature(entities):1
  Layer (String) = 0
  SubClasses (String) = AcDbEntity:AcDbPoint
  EntityHandle (String) = 20001
  Style = PEN(c:#000000)
  POINT Z (513 411 2)

OGRFeature(entities):2
  Layer (String) = 0
  SubClasses (String) = AcDbEntity:AcDbPoint
  EntityHandle (String) = 20002
  Style = PEN(c:#000000)
  POINT Z (500 360 3)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.