Solved

Convert DGN to Shape file

  • 16 November 2022
  • 4 replies
  • 96 views

Badge

Hi,

 

I have 25000 dgn files and I want to convert all of them into a single shape file and want to add the following attributes in the shape file

 

  1. File name of the dgn as attribute
  2. Level name of the dgn as attribute

I would like to convert only the line geometry from the dgn files.

 

Please help

icon

Best answer by david_r 16 November 2022, 15:08

View original

4 replies

Userlevel 6
Badge +33

Depending on the volume of the source data, I would prefer another format than shape, in which you can insert records instead of completely overwriting it. Geopackage, geodatabase, postgis, etc.

 

I think there are roughly 2 ways to do this:

  • One workspace to do it all.
    • Scan a directory for DGN files using a Directory and File Pathnames reader.
    • Read all DGN files with a second FeatureReader, merge attributes from first reader as these have the filename as attribute.
    • Filter the data you need.
    • Write the results to a shapefile.
    • Easy to build.
    • Probably takes a long time to run, might be memory challenging as well. Depends on source data.
    • When it fails, fix workspace and do it all again.
  • One workspace to create a table with all input files and status. A second one to read the table and use a workspacerunner to initiate a third workspace to proces one file each time and update the table with status = done.
    • Takes a bit more time to set up.
    • You can pause or stop and restart the process without having to do it all again.

 

You can always start with trying to do it using one workspace and convert to the workspacerunner alternative when it does not work.

 

Badge

Depending on the volume of the source data, I would prefer another format than shape, in which you can insert records instead of completely overwriting it. Geopackage, geodatabase, postgis, etc.

 

I think there are roughly 2 ways to do this:

  • One workspace to do it all.
    • Scan a directory for DGN files using a Directory and File Pathnames reader.
    • Read all DGN files with a second FeatureReader, merge attributes from first reader as these have the filename as attribute.
    • Filter the data you need.
    • Write the results to a shapefile.
    • Easy to build.
    • Probably takes a long time to run, might be memory challenging as well. Depends on source data.
    • When it fails, fix workspace and do it all again.
  • One workspace to create a table with all input files and status. A second one to read the table and use a workspacerunner to initiate a third workspace to proces one file each time and update the table with status = done.
    • Takes a bit more time to set up.
    • You can pause or stop and restart the process without having to do it all again.

 

You can always start with trying to do it using one workspace and convert to the workspacerunner alternative when it does not work.

 

Hi,

 

MAny thanks for the quick reply. I am new to FME. Can you please elaborate more or if there is any you tube or google link with instructions. Sorry if I am asking for too much.

 

Regards,

 

Krishna

Userlevel 4

Regardless of the output format, you need to expose the following two format attributes in the DGN reader: "fme_basename" = dgn filename (without the extension), and "igds_level_name" = the layer name. If you need the full filename with path, you need to expose "fme_dataset" as well. 

You can e.g. use the AttributeManager to rename them before output.

Use the GeometryFilter to only retain the line geometries.

You can select multiple folders or directories for your dgn files like this, that way you don't have to use any additional functionality:

imageFor example, this will read all the *.dgn files in any subdirectory under C:\Temp

C:\Temp\**\*.dgn

 

Badge

Hi,

 

MAny thanks for the quick reply. I am new to FME. Can you please elaborate more or if there is any you tube or google link with instructions. Sorry if I am asking for too much.

 

Regards,

 

Krishna

1. Take idgs as reader.

2. Expose required attributes (like dgn name & levels) - attributeexposer

3. Use transformer 'geometryfilter' to filter only 'lines'

4. Use writer gdb ( as you have lot of files)

Reply