Skip to main content

Related to my question about importing a prj file, I think one of these might be a solution. My inputs are DGN files and my outputs are shapefiles. The DGN files do not have a projection defined so I thought I can replace the prj file created by the shapefile writer. I came up with two different ways to do this but I don't know what will work in FME. Will one of these work for replacing my prj file?

  • create the shapefiles and save in a fanout by a given attribute (category)
    • read in the source prj file
    • rename the source prj file to match each new shapefile and overwrite the existing prj file, effectively overwriting the one created by feature writer. What transformer will I use for renaming the file and saving it?
    • I already have a process for creating the list of shapefile names, will fanout by the same attribute overwrite the existing file?
  • replace all of the text in the new shapefile prj file with the text from the source prj file
    • this seems the easiest but I don't know how to read in, replace text, and then resave
  • create the shapefiles in a feature writer
    • merge the source prj with the new shapefile and overwrite the shapefiles
      • this concept seems simple but the least likely to work

Any suggestion on what will work and the best transformer for the task?

If I understand correctly you have dgn files that do not have a projection defined, but you know what it is, and you would like the output shapefiles to have prj files with that projection, instead of unknown?

 

 

If that is the case, you don't need to mess with the prjs at all. You can define the projection on the dgn reader, in the workspace with the CoordinateSystemSetter, or on the shapefile wrtiter.


If I understand correctly you have dgn files that do not have a projection defined, but you know what it is, and you would like the output shapefiles to have prj files with that projection, instead of unknown?

 

 

If that is the case, you don't need to mess with the prjs at all. You can define the projection on the dgn reader, in the workspace with the CoordinateSystemSetter, or on the shapefile wrtiter.

No, they are custom projections.

 

 


Hi @tsurveyor, if you have a prj file containing your desired coordinate system definition, you can just copy it to the Shapefile destination folder with the File Copy writer, after writing the Shapefile files with a FeatureWriter.


Hi @tsurveyor, if you have a prj file containing your desired coordinate system definition, you can just copy it to the Shapefile destination folder with the File Copy writer, after writing the Shapefile files with a FeatureWriter.

That was kind of
what I thought. Right now I have set up writing shapefiles with a feature
writer. What I wasn't sure about was how to create a copy of my prj file with
the name of each shapefile and then put it in the correct folder. I am
struggling with how to make and save the numerous copies of the prj file,
each named for the shapefile it will update. I have attached a copy of my
workbench. I am processing over 200 DGN files and creating numerous shapefiles, and each shapefile needs their prj file replaced.

 

You were such a big help to me in getting me past the categorizing, this is the last hurdle (I think).

 

 

dgn2gis-step2-categorizedshapes.fmw

 

 

 

 

 


Hi @tsurveyor, if you have a prj file containing your desired coordinate system definition, you can just copy it to the Shapefile destination folder with the File Copy writer, after writing the Shapefile files with a FeatureWriter.

The feature output from the Summary port of the FeatureWriter have an attribute called "_dataset" that stores the destination dataset name and a list called "_feature_type{}.name" that contains the written feature type names. In the case of writing a Shapefile dataset, dataset name is the destination folder path, feature type names are the created Shapefile file names except extension. You can use them to copy a source prj file to the desired location with desired file name(s) quite easily.

 

See the attached demo: copy-prj-example.zip (FME 2018.1.0.3)

 


Hi @tsurveyor, if you have a prj file containing your desired coordinate system definition, you can just copy it to the Shapefile destination folder with the File Copy writer, after writing the Shapefile files with a FeatureWriter.

as always, you are tremendously helpful. I wasn't even aware of the filecopy writer but see it as extremely useful. I can do this when having to update metadata as well. Thank you!!!

 

 


Reply