Question

Read SHP file, split and write into separate XML files


Badge

Hello,

I'm reading a SHP file, splitting it into tiles and I want to write each tile into a separate XML using my own XML template (XML Templater -> XML Formatter -> AttributeFileWriter). Is some kind of fanout possible on AttributeFileWriter?

Thanks for help, Moni


5 replies

Badge +22

Yes, you can set the Target Filename to an attribute. However, why not just use a Text File writer? Set the Attribute to contain XML output on the XML formatter to text_line_data, and setup a dataset fanout on the textfile writer.

Badge

Hi,

how do I set a dataset fanout on the textfile writer? I'm assigning tile number(s) (PLAN_NO) to every polygon from Area Polygons (some polygons can be within more than one tile). The XML Templater is using a custom schema - PLAN_NO attribute is not needed in the custom schema. In this example, the output is supposed to be 6 Area polygons files XML/GML files - one for each of the 6 tiles which intersect the input Site polygon.

I was able to split the Area polygons into tiles and output to SHP files, but I'm a little bit lost how I achieve the same with XML/GML output.

Any help much appreciated...

Userlevel 2
Badge +17

Hi @honkovam, If you need to create 6 XML documents for each PLAN_NO, you will have to send 6 features which have unique PLAN_NO to the ROOT port of the XMLTemplater, and also set PLAN_NO to the "Group Sub-Features By" parameter.

To create the 6 features for ROOT port, it might be easy to branch the data flow at the output port of the ListExploder and filter unique "PLAN_NO" features with the DuplicateFilter (Key Attributes: PLAN_NO).

Then, in the Navigator window, specify unique file name for each PLAN_NO to the Fanout Expression parameter of the Text File writer. e.g. "plan_@Value(PLAN_NO).xml"

See also this simplified example: fanout-dataset-example.fmw

Badge +22

Hi,

how do I set a dataset fanout on the textfile writer? I'm assigning tile number(s) (PLAN_NO) to every polygon from Area Polygons (some polygons can be within more than one tile). The XML Templater is using a custom schema - PLAN_NO attribute is not needed in the custom schema. In this example, the output is supposed to be 6 Area polygons files XML/GML files - one for each of the 6 tiles which intersect the input Site polygon.

I was able to split the Area polygons into tiles and output to SHP files, but I'm a little bit lost how I achieve the same with XML/GML output.

Any help much appreciated...

To have 6 features coming out of the XML Templater, you need to have 6 root features with an attribute you can use as a Group-By clause on the XML templater. If you you do not know the PLAN_NO in advance of runtime, instead of using a creator use a Sampler to get the first 1 feature from the list exploder with a group-By on the PLAN_No, Send the not sampled to the AREA port of the XML Templater, and send the sampled to both the Root and AREA ports.

Badge

Hi @takashi!

thank you very much for your help!

Moni

Reply