Solved

How to write to .svg file format specifying attribute fill-opacity without fme prefix?

  • 10 January 2021
  • 5 replies
  • 7 views

Setting up writer by default adds attribute: 

fme: fill-opacity="0.1"

 to each feature. 

Is there a simple way to add  

fill-opacity="0.1"

to each feature instead ?

 

 

UPDATE: As per a comment by @chrisatsafe, I am interested in setting style per feature in this scenario to obtain this transparency effect you see below. The thing is, 'fill-opacity' has to be set to the same value 0.1 for all features within dataset.  

CaptureThank you,

Aleksei

icon

Best answer by chrisatsafe 11 January 2021, 22:15

View original

5 replies

Badge +2

Hi @__alex__​,

 

Are you looking to style per feature or per dataset? You have options with this. 

 

Option 1 (Per dataset), you can simply use the Style parameter in the writer feature type: 

fill-opacity:0.2

This uses css syntax

2021-01-11_13-07-03

Option 2 (per feature), write the svg with the FeatureWriter then read the .svg in with the FeatureReader to remove the fme: prefix. I believe the svg writer will prefix any attributes written to the .svg file with fme: so this would work for any user attributes that you are writing to the .svg.2021-01-11_13-11-46

 

Here are the outputs of both. I've also attached the example.

2021-01-11_13-12-35

 

Option 3 (didn't test):

Perhaps a different .svg template file in the writer parameters would do the trick. 

Thank you for helping with that @chrisatsafe. First option did a trick. Fill opacity had to be set to 0.2 for each feature in output dataset, which makes your question whether it is by feature or per dataset perfectly relevant. 

 

I've got another question: is that possible to set svg writer parameter 'Style' attribute  to many values to modify several properties?  For example I need to set stroke to none while keeping that fill-opacity equal 0.2. 

stroke="none"

 

 

 

 

Badge +2

Thank you for helping with that @chrisatsafe. First option did a trick. Fill opacity had to be set to 0.2 for each feature in output dataset, which makes your question whether it is by feature or per dataset perfectly relevant. 

 

I've got another question: is that possible to set svg writer parameter 'Style' attribute  to many values to modify several properties?  For example I need to set stroke to none while keeping that fill-opacity equal 0.2. 

stroke="none"

 

 

 

 

Absolutely, you can add as many style elements as you'd like as long as they are semi colon separated

fill-opacity:0.2;stroke:none

One thing to note... if your features already have a fill and stroke color, this likely will not work as the stroke can be set on the individual features as well. To change that, you can set the svg_color attribute to none in an attribute manager. 

 

The svg_color format attribute is the pen color and svg_fill_color is the fill. 

2021-01-12_8-34-44

Great! I got the effect I wanted to obtain using semi colon separated style elements. Thank you again!final2

Hi @__alex__​,

 

Are you looking to style per feature or per dataset? You have options with this. 

 

Option 1 (Per dataset), you can simply use the Style parameter in the writer feature type: 

fill-opacity:0.2

This uses css syntax

2021-01-11_13-07-03

Option 2 (per feature), write the svg with the FeatureWriter then read the .svg in with the FeatureReader to remove the fme: prefix. I believe the svg writer will prefix any attributes written to the .svg file with fme: so this would work for any user attributes that you are writing to the .svg.2021-01-11_13-11-46

 

Here are the outputs of both. I've also attached the example.

2021-01-11_13-12-35

 

Option 3 (didn't test):

Perhaps a different .svg template file in the writer parameters would do the trick. 

Hi I attempted option 2 that you have given as an example. FeatureReader does not read SVG datasets, so how did you use the FeatureWriter to write an SVG and then read it with FeatureReader? Its not in the list of formats? I would love help with this as its been a big-time sink!

Reply