Question

how to duplicate shapefiles X times and join data from table(s) to the shapefiles

  • 5 November 2018
  • 7 replies
  • 6 views

Hi everyone,

Here a newbie queston. I want to duplicate a shapefile 18 times (instead of manually duplicating the shapefile) and then attach information from 18 tables to those shapefiles based on the key value: NamePark. I tried the Cloner, however then instead I got a shapefile with so many features, so I was wondering what to do instead

So basically I have two questions:

1) Is there a transformer available to copy/duplicate a shapefile X times

2) How can I join the tables to the shapefiles based on a key value. I looked at featurmerger, but I cant find the key values.

 

I have attached an image of my current workflow


7 replies

Badge +3

You miss the ParkName attribute on one dataset?

Cloner is ok for duplicating, but looks like you don't need t do so maybe.

 

Post some sample dataset?

Badge +7

In the Cloner, enter an attribute name for the copy number. After the Cloner, use an AttributeFilter on the copy number attribute to split the data flow into 18 streams. Then in each stream try using the FeatureJoiner to add the data from the table. The streams can all come together for one ShapeFile Writer where you can set the ShapeFile name based on the copy number (e.g. ) or the park name (e.g. Or you can use AttributeValueMapper to create and/or set a ShapeFile name attribute value based on the copy number and use that in the Writer.

If your tables are in an appropriate format such as SQL Server, you may be able to use something like one or more DatabaseJoiners or SQLExecutors to join the tabular data.

In the Cloner, enter an attribute name for the copy number. After the Cloner, use an AttributeFilter on the copy number attribute to split the data flow into 18 streams. Then in each stream try using the FeatureJoiner to add the data from the table. The streams can all come together for one ShapeFile Writer where you can set the ShapeFile name based on the copy number (e.g. ) or the park name (e.g. Or you can use AttributeValueMapper to create and/or set a ShapeFile name attribute value based on the copy number and use that in the Writer.

If your tables are in an appropriate format such as SQL Server, you may be able to use something like one or more DatabaseJoiners or SQLExecutors to join the tabular data.

@tim_wood wow, thanks for the explanation, unfortunately I am already stuck at the attributefilter, I use Attribute to Filter by Copynr (name for the column which holds the information on the copy number), however when I run the attributefilter, I don't get seperate streams, everything is put into unfiltered as you can see in the image :(

Badge +7

@tim_wood wow, thanks for the explanation, unfortunately I am already stuck at the attributefilter, I use Attribute to Filter by Copynr (name for the column which holds the information on the copy number), however when I run the attributefilter, I don't get seperate streams, everything is put into unfiltered as you can see in the image :(

You need to enter the copy number values manually in the AttributeFilter as shown below (after setting the Attribute to Filter by to Copynr).

In the Cloner, enter an attribute name for the copy number. After the Cloner, use an AttributeFilter on the copy number attribute to split the data flow into 18 streams. Then in each stream try using the FeatureJoiner to add the data from the table. The streams can all come together for one ShapeFile Writer where you can set the ShapeFile name based on the copy number (e.g. ) or the park name (e.g. Or you can use AttributeValueMapper to create and/or set a ShapeFile name attribute value based on the copy number and use that in the Writer.

If your tables are in an appropriate format such as SQL Server, you may be able to use something like one or more DatabaseJoiners or SQLExecutors to join the tabular data.

@tim_wood Hi, now it worked, thanks. I assumed that defining the Attribute to Filter by was enough, however I didn't know that I had to manually type the possibilities as well. :)

Badge +7

@tim_wood Hi, now it worked, thanks. I assumed that defining the Attribute to Filter by was enough, however I didn't know that I had to manually type the possibilities as well. :)

Yes, sometimes it would be nice if it auto-populated the output ports for you. However, your data could have thousands or millions of features, so you don't necessarily want to sit there for ages while FME scans all the data to work out what the values are. Also, you might not want to use all the possible values, only filter on certain ones.

If the values you want for your output ports exist in an existing dataset, you can add them via the Import button. So if you had a CSV file which had a column containing values 1 to 18, you could import them that way. But in this case I think it's easier to just type them in.

The other thing about importing the values is that if you needed to set up 50 output ports and had a file with 75 values in, you could import that, then remove the 25 values you didn't want. Easier than typing in 50 values with no typos.

Badge +3

@carlyxjack

rather then creating a filter, you could of course enumerate the tabelfilters. Using sorter and sampler or using listbuilder and counter.

The max. number can then be passé (FeatureMerger or Variable Setter/Retriever) to the parks. And then clone the parks based on that.

Then you could merge grouped by the counter (counter and copynumber should of course be named the same.)

No filtering needed.

 

In your example you have 3 filters, so you clone the parks 3 times. So you can groupBy on those in your FeatureMerger.

 

Reply