[postgis-users] help with Microstation DGN data to PostGIS

Frank Warmerdam warmerdam at pobox.com
Wed Jul 9 08:40:44 PDT 2003


ejansson at COLLEGES.ORG wrote:
> I've been been trying to load a number of files in Microstation DGN format into
> PostGIS, and was hoping someone here had some experience doing this.  I've been
> using the ogr2ogr utility to do this: 
> 
>     ogr2ogr -lco LAUNDER=YES -f "PostgreSQL" PG:dbname=testdb D4d10.97.1.dgn
> 
> ..but have found that the attribute data attached to my shapes is not being
> loaded into the database.  I have also tried using the ogr2ogr utility to create
> shapefiles, and then use shp2pgsql to get that data into PostGIS:
> 
>     ogr2ogr -skipfailures -nln D4d10.97.1_polygon -skipfailures -lco
> SHPT=POLYGON -f "ESRI Shapefile" D4d10.97.1/ D4d10.97.1.dgn
> 
> ..which works, excepth that, again, the attribute data does not appear: the SHP
> file has all the geometry data, but the DBF file is empty.  When I use ArcView
> and do a manual "Convert to Shapefile..." all the attribute data converts fine.
>  The problem is, I have several hundred of these files to convert.
> 
> Sorry if this is a peripheral topic to this list--I realize most users are
> probably most concerned with shapefiles and not DGNs.  Thanks in advance for any
> help.

Eric,

Ogr2ogr issues would be more properly addressed to the gdal-dev mailing list.

When converting a dgn file to other formats, such as shape or PostGIS you should
produce a new file that has features a bit like this:

OGRFeature(elements):2
   Type (Integer) = 6
   Level (Integer) = 0
   GraphicGro (Integer) = 0
   ColorIndex (Integer) = 0
   Weight (Integer) = 0
   Style (Integer) = 0
   EntityNum (Integer) = (null)
   MSLink (Integer) = (null)
   Text (String) = (null)
   POLYGON ((-97.22872389 49.00075000 0.000,-97.94962278 49.00055000 0.000,-98.99

If you are not getting Type, Level, GraphicGroup, ColorIndex, Weight, Style
EntityNum, MSLink and Text attributes in your .dbf file when converting to
shapefile then there is a bug somewhere, and I would encourage you to submit
it in the GDAL/OGR bugzilla with details of your software version, and a
sample input file and commandline to reproduce the problem.

If the issue is that Microstation external linked attributes (linked via
MSLink) are not being carried through ogr, well that is a different ball
of wax.  While the dgn file itself can hold some information about external
links, it isn't enough for ogr to automatically collect the external data.
Using the new OGR SQL join capabability we might be able to get the
external attributes joined, or you could load the external tables into
PostGIS seperately and use a join in Postgres.

Once we can get ogr2ogr from dgn to shapefile working smoothly, hopefully
you can use ogr2ogr to directly load PostGIS.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the postgis-users mailing list