Skip to main content

I have a line that I try to divide in smaller parts of 5 m each. The line is is from a shapefile. When I try to use the chopper it divides the line in random parts, varying in length from 7 to 113 meter, but in not a single case in 5 meter. Am I doing something wrong or is this a bug in the transformer?

Hope someone can help.

The Chopper only chops at existing vertices. So if you have a polyline with a great distance between vertices, your results might be very approximate.

Try the Snipper instead, with Snipping mode set to "Distance (value)"


Another option would be to use the IterativeSnipper from the FME Hub.


Another option would be to use the IterativeSnipper from the FME Hub.

Agreed. Just a pity that the parameter wording is a bit confusing and not in tune with the other transformers, OP should select "Shorten to length" for the Snipping mode there.

 

 


or build your own iterative snipper. Good practice and not to difficult.

Give it a bunch of parameters...like mine: length, percentage, segment_count, by attribute.

In fact I call mine a segmentor, for it can do it to polygons as well.


Agreed. Just a pity that the parameter wording is a bit confusing and not in tune with the other transformers, OP should select "Shorten to length" for the Snipping mode there.

 

 

How would it be possible to merge the end of the line with the penultimate one if it's smaller than the user value.

 

Example : My line's length is 11meters. My value is 3.

 

The result I want would be : 3m*2 lines and 5m*1 line

 

The result I get is : 3m*3 lines and 2m*1 line

 

 

Ideas anyone? Thanks!

 

 


The Chopper only chops at existing vertices. So if you have a polyline with a great distance between vertices, your results might be very approximate.

Try the Snipper instead, with Snipping mode set to "Distance (value)"

I am trying to do the same thing but with segments of 4000 m, on a line that is 8382 m long. There are two problems for me that I can't seem to find any documentation on. 1. Where do I say how long I want the segments to be (4000m), and 2. how do I specify the Starting location and Ending location?


I am trying to do the same thing but with segments of 4000 m, on a line that is 8382 m long. There are two problems for me that I can't seem to find any documentation on. 1. Where do I say how long I want the segments to be (4000m), and 2. how do I specify the Starting location and Ending location?

As per the documentation, the start and end location are specified in ground units (meaning that you'll probably want to make sure that your data isn't in e.g. LatLong), meaning that if your ground units are meters then you should supply distances in meters measured along the line. Length is implied by the distance between start and end location. The "problem" is that the Snipper only snips once, it will not repeat itself automatically if you want to divide long lines into several shorter lines.

But there's an IterativeSnipper transformer on the FME Hub that may be closer to what you're looking for. Don't be confused by the wording of the snipping mode (I would've changed "Shorten to length" to "Divide into max length"):

With an input line of 8382m the output will be two lines of 4000m each, plus one line with the remainder (382m).


As per the documentation, the start and end location are specified in ground units (meaning that you'll probably want to make sure that your data isn't in e.g. LatLong), meaning that if your ground units are meters then you should supply distances in meters measured along the line. Length is implied by the distance between start and end location. The "problem" is that the Snipper only snips once, it will not repeat itself automatically if you want to divide long lines into several shorter lines.

But there's an IterativeSnipper transformer on the FME Hub that may be closer to what you're looking for. Don't be confused by the wording of the snipping mode (I would've changed "Shorten to length" to "Divide into max length"):

With an input line of 8382m the output will be two lines of 4000m each, plus one line with the remainder (382m).

Thanks for quick answer David! But when I do that my translation fails.

I am first aggregating a line that is segmented in a way that doesnt work for me. I input the same mode and values as you've shown above. Do you know what this translation message means and what goes wrong? It seems to be saying that the aggregated feature has an invalid geometry type? I find that strange.

 

The below feature caused the translation to be terminated

Storing feature(s) to FME feature store file `.\\mapping_log.ffs'

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Feature Type: `FEATURE_TYPE'

Attribute(encoded: UTF-16LE): `Beskrivnin' has value ` '

Attribute(32 bit integer) : `Id' has value `5'

Attribute(64 bit real) : `Iterative_Snipper_length' has value `85266.30567646558'

Attribute(encoded: UTF-8) : `Iterative_Snipper_maxLength' has value `20'

Attribute(32 bit integer) : `Längd' has value `0'

Attribute(32 bit integer) : `OBJECTID' has value `2'

Attribute(encoded: UTF-16LE): `ObjNr' has value ` '

Attribute(encoded: UTF-16LE): `ObjektNamn' has value `Skåneleden HBG'

Attribute(64 bit real) : `Shape.STLength()' has value `8381.942131805463'

Attribute(string) : `fme_feature_type' has value `HBG.Skaneleden'

Attribute(string) : `fme_geometry' has value `fme_aggregate'

Attribute(string) : `fme_rejection_code' has value `INVALID_GEOMETRY_TYPE'

 


Thanks for quick answer David! But when I do that my translation fails.

I am first aggregating a line that is segmented in a way that doesnt work for me. I input the same mode and values as you've shown above. Do you know what this translation message means and what goes wrong? It seems to be saying that the aggregated feature has an invalid geometry type? I find that strange.

 

The below feature caused the translation to be terminated

Storing feature(s) to FME feature store file `.\\mapping_log.ffs'

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Feature Type: `FEATURE_TYPE'

Attribute(encoded: UTF-16LE): `Beskrivnin' has value ` '

Attribute(32 bit integer) : `Id' has value `5'

Attribute(64 bit real) : `Iterative_Snipper_length' has value `85266.30567646558'

Attribute(encoded: UTF-8) : `Iterative_Snipper_maxLength' has value `20'

Attribute(32 bit integer) : `Längd' has value `0'

Attribute(32 bit integer) : `OBJECTID' has value `2'

Attribute(encoded: UTF-16LE): `ObjNr' has value ` '

Attribute(encoded: UTF-16LE): `ObjektNamn' has value `Skåneleden HBG'

Attribute(64 bit real) : `Shape.STLength()' has value `8381.942131805463'

Attribute(string) : `fme_feature_type' has value `HBG.Skaneleden'

Attribute(string) : `fme_geometry' has value `fme_aggregate'

Attribute(string) : `fme_rejection_code' has value `INVALID_GEOMETRY_TYPE'

 

I think the iterative snipper expects a single line, if you are sending it output from the aggregator you are possibly sending it a line with path segments. You could consider using a linecombiner instead of the aggregator to get a single line geometry.

Thanks for quick answer David! But when I do that my translation fails.

I am first aggregating a line that is segmented in a way that doesnt work for me. I input the same mode and values as you've shown above. Do you know what this translation message means and what goes wrong? It seems to be saying that the aggregated feature has an invalid geometry type? I find that strange.

 

The below feature caused the translation to be terminated

Storing feature(s) to FME feature store file `.\\mapping_log.ffs'

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Feature Type: `FEATURE_TYPE'

Attribute(encoded: UTF-16LE): `Beskrivnin' has value ` '

Attribute(32 bit integer) : `Id' has value `5'

Attribute(64 bit real) : `Iterative_Snipper_length' has value `85266.30567646558'

Attribute(encoded: UTF-8) : `Iterative_Snipper_maxLength' has value `20'

Attribute(32 bit integer) : `Längd' has value `0'

Attribute(32 bit integer) : `OBJECTID' has value `2'

Attribute(encoded: UTF-16LE): `ObjNr' has value ` '

Attribute(encoded: UTF-16LE): `ObjektNamn' has value `Skåneleden HBG'

Attribute(64 bit real) : `Shape.STLength()' has value `8381.942131805463'

Attribute(string) : `fme_feature_type' has value `HBG.Skaneleden'

Attribute(string) : `fme_geometry' has value `fme_aggregate'

Attribute(string) : `fme_rejection_code' has value `INVALID_GEOMETRY_TYPE'

 

The error message is INVALID_GEOMETRY_TYPE, so I'm guessing that aggregates aren't supported (which does make some sense to me). Try again without the Aggregator.


The error message is INVALID_GEOMETRY_TYPE, so I'm guessing that aggregates aren't supported (which does make some sense to me). Try again without the Aggregator.

Yeah, so without the aggregator it works, and it seems to be going through the whole line. But I get 8 lines of 27 total that are of strange lengths. Which makes it impossible for me to use the results. I need all segments to be as close to 4000 m as possible, with the exeption of one end segment, that can be whatever is left. (Correction from above, I missed a number on the total length of the line it is around 80 000 m)

 

I imagine that this has to do with the status of the line I want to "segment", it is as I described not just one feature. It is 10 seperate features. Any idea of how I can get the segments more equal in length?

 


I think the iterative snipper expects a single line, if you are sending it output from the aggregator you are possibly sending it a line with path segments. You could consider using a linecombiner instead of the aggregator to get a single line geometry.

Hi egomm! Thanks for the advice. I tried your suggestion of the linecombiner instead, once with the default setting/parameters and once by grouping them on a field I know they have the same value in. But I get the same result, 5 features come out, how can I make them into one?


Alternatively one could use a Densifier before the Chopper to generate the vertices in between. For Arcs however, the Densifier seems to have no effect, so use an ArcStroker first.

In fact, the Chopper generates for one arc more than one output line feature, however the length of the output does not even closely match the approximate length parameter (there should not be any vertex on the arc, @david_r so why is it chopping arcs anyway?).

chopperdoesnotuselength.fmwt


Alternatively one could use a Densifier before the Chopper to generate the vertices in between. For Arcs however, the Densifier seems to have no effect, so use an ArcStroker first.

In fact, the Chopper generates for one arc more than one output line feature, however the length of the output does not even closely match the approximate length parameter (there should not be any vertex on the arc, @david_r so why is it chopping arcs anyway?).

chopperdoesnotuselength.fmwt

I suspect this phrase from the documentation explains it:

Input arcs are stroked prior to chopping. If the chopping operation does not modify a stroked arc, the arc is unstroked and will be output untouched.

The arc seems to be stroked with an automatic stroking distance and the Chopper then splits at the vertices on the stroked arc. In this case the automatic stroking distance seems to correspond to about 1744 meters (at least on my machine), which is also the length of the chopped segments since there are no intermediate vertices.

Perhaps try using the DistanceChopper on the FME Hub, it seems to give a much more sensible result.


I am trying to do the same thing but with segments of 4000 m, on a line that is 8382 m long. There are two problems for me that I can't seem to find any documentation on. 1. Where do I say how long I want the segments to be (4000m), and 2. how do I specify the Starting location and Ending location?

TOP tnkx Dav!


Reply