Skip to main content
Solved

Dynamic Writer to Write as KML not KMZ


I have a KML writer with dynamic attribute definition. The writer always writes a KMZ file but I want it to write a KML file. When you use a static writer you can specify the filename and extension in the writer as either ".kml" or ".kmz" but when it is dynamic you just give the path to the folder and "fme_feature_type" as the feature type name. Also there is no suffix on which to fan out.

How can I get the writer to write KML?

Thanks

Best answer by takashi

Hi @jimo, I think you can control the destination format (KML or KMZ) via file extension (.kml or .kmz) in the string expression for the Fanout Dataset option in the KML writer. e.g. assume that a feature attribute called "_basename" stores the destination filename without extension,

View original
Did this help you find an answer to your question?

6 replies

itay
Supporter
Forum|alt.badge.img+16
  • Supporter
  • May 2, 2017

Hi @jimo,

I have just created a dynamic translation to KML and I can still change the extension kml to kmz and it works just fine. Try it yourself and change the D: esult2.kmz to D: esult2.kml

acad2ogckml.fmwt


  • May 2, 2017
itay wrote:

Hi @jimo,

I have just created a dynamic translation to KML and I can still change the extension kml to kmz and it works just fine. Try it yourself and change the D: esult2.kmz to D: esult2.kml

acad2ogckml.fmwt

This works because you are writing the file name. However, in my case the file name will be set by a parameter. When I do it this way, I always get "doc.kml", not the filename that I passed in.

 

 

At any rate, I realized that I can use the zipfile module in the Python shutdown script to extract the doc.kml from the KMZ file, like this:

 

 

import zipfile

 

zip_ref = zipfile.ZipFile(pathToSourceKML, 'r')

 

# Where I want to write the KML

 

zip_ref.extractall(pathToUnzippedKML)

 

zip_ref.close()

 

 

Then I can use shutil.move(src,dst) to change the file name from doc.kml to the name that I want it to be.

 


itay
Supporter
Forum|alt.badge.img+16
  • Supporter
  • May 2, 2017

Also when fetching the parameter value and adding the .kml to it ?


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • May 3, 2017

Hi @jimo, I think you can control the destination format (KML or KMZ) via file extension (.kml or .kmz) in the string expression for the Fanout Dataset option in the KML writer. e.g. assume that a feature attribute called "_basename" stores the destination filename without extension,


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • May 3, 2017
takashi wrote:

Hi @jimo, I think you can control the destination format (KML or KMZ) via file extension (.kml or .kmz) in the string expression for the Fanout Dataset option in the KML writer. e.g. assume that a feature attribute called "_basename" stores the destination filename without extension,

0684Q00000ArKHUQA3.png

If the destination filename without extension will be specified through a user parameter (e.g. named "BASENAME"), this expression is available.

 

$(BASENAME).kml 

  • May 3, 2017
takashi wrote:

Hi @jimo, I think you can control the destination format (KML or KMZ) via file extension (.kml or .kmz) in the string expression for the Fanout Dataset option in the KML writer. e.g. assume that a feature attribute called "_basename" stores the destination filename without extension,

The $(BASENAME).kml is the syntax that works. Thanks @takashi@takashi.

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings