Skip to main content
Solved

Convert multiple ESRI shape files into SQL Server Geography

  • June 19, 2019
  • 2 replies
  • 97 views

I have a number of ESRI shape files that need Sqlising. Each shape file goes into a SQL Server Database table as a single row. How do I achieve this in one workflow? Doing these one by one is not practical as there are hundreds of shape files and I can easily make a mistake plus not repeatable.

Best answer by erik_jan

Two ways of doing this:

1) Point the Shape reader to <your folder>\\*.shp to read all Shape files in one go

2) Create a workspace to process 1 Shape file and a "runner" workspace using a "Directory and File Path" reader. This reader gets the file names (shp files) and not the contents. Follow the reader by a WorkspaceRunner transformer to call the workspace for processing a Shape file and pass the attribute containing the file name to the parameter in the WorkspaceRunner. This will create a loop to run the same workspace for each Shape file in the folder.

Option 1 is the easier, option 2 more flexible.

Hope this helps.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • Best Answer
  • June 19, 2019

Two ways of doing this:

1) Point the Shape reader to <your folder>\\*.shp to read all Shape files in one go

2) Create a workspace to process 1 Shape file and a "runner" workspace using a "Directory and File Path" reader. This reader gets the file names (shp files) and not the contents. Follow the reader by a WorkspaceRunner transformer to call the workspace for processing a Shape file and pass the attribute containing the file name to the parameter in the WorkspaceRunner. This will create a loop to run the same workspace for each Shape file in the folder.

Option 1 is the easier, option 2 more flexible.

Hope this helps.


rahulsharma
Safer
Forum|alt.badge.img+10
  • Safer
  • 359 replies
  • June 19, 2019

Hi @chapmans1982, As erik_jan mentioned both the above-mentioned steps would work, but just want to clarify the following

 

Incoming shapefiles have identical SCHEMA

 

Or else, the schema will be taken from the 1st incoming features and geometry and attributes will be written to same SQL table.

Under MSSQL Spatial Writer --> Parameters --> SpatialType > Set Value to Geography

Please find attached Template using FME tutorial data esrishape2mssql_spatial.fmwt