[postgis-users] Help on using Ogr2ogr to load dxf data to postgis

Paolo Corti pcorti at gmail.com
Fri Oct 12 05:48:48 PDT 2012


Hi
you'd better do asking to gdal-dev list, as it is a GDAL question. Anyway:

On Fri, Oct 12, 2012 at 2:21 PM, Pieri70 <pierigis at gmail.com> wrote:
> Hello
> I'm trying to load a thousand dxf files to postgis using ogr2ogr (windows xp
> postgres9/postgis2).
> the syntax I use is:
> ogr2ogr --config DXF_INLINE_BLOCKS FALSE --config DXF_MERGE_BLOCK_GEOMETRIES
> FALSE -f "PostgreSQL" PG:"host=localhost user=postgres dbname=mydbname
> password=mypassword" mydxf.DXF -overwrite entities
>
> This creates a table called entities that collect point and lines and a
> geometry column wkb_geometry with a coord dimension integer 2 and a srid 0
>
> My questions are:
> Is there the possibility to filter unwanted layer from dxf before insert
> them into the entities table via ogr?

I have not big experience with DXF driver, but the way you are going
you are just copying all of the layers from the .dxf file.
You can copy layer by layer (running the script for each layer)
specifying its name after input file, something like this:

 ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres
dbname=mydbname password=mypassword" mydxf.dxf layername -overwrite
entities

> and
> is there the possibility to convert closed polylines to polygons?

You could use the -nlt type option. I am sure it works for promoting
geometries to multi geometries and the other way, but I have never
tried for building polygons to polylines.
Otherwise use ST_Polygonize PostGIS function after the import.

> and
> how can I set the correct coord space (3D) and srid?

please refer to ogr2ogr [1] doc page
regards
p

[1] http://www.gdal.org/ogr2ogr.html

-- 
Paolo Corti
Geospatial software developer
web: http://www.paolocorti.net
twitter: @capooti
skype: capooti



More information about the postgis-users mailing list