Skip to main content

I have a request to convert some postgis geom data into TopoJSON. However they want the output to be single combined file similar to what is produced by https://mapshaper.org/

 

I can easily create individual TopoJSON files in FME. (Simple read postgis and connect to TopoJSON writer.) But I have not figured how I can produce a combined file with multiple objects in it like what is done with mapshaper.org site.

 

I uploaded sample TopoJson output files from FME and the sample combined file from mapshaper.

 

I figure this will likely need some type of python code, which is fine, but I'm hoping to not install any additional modules outside what FME provides.

 

Currently using FME 2020.2. That is what company uses. But I can use new FME version if it had options for doing this in some update.

Hello @ssmith_ftr​ 

It is currently not possible to write multiple feature types with the TopoJSON writer. The enhancement request related to this is tracked as FMEENGINE-75196.

However, it should be possible to route all features to a TopoJSON feature writer (without using a feature type fanout) and then modify the created TopoJSON to create one object per feature type using JSON transformers to create the 'combined' output you're expecting. I have attached an example workspace demonstrating this workflow created in FME 2022.1.

I tried recreating this workflow in FME 2020.2 but ran into several issues that have been fixed or improved in newer versions of FME. If you must use FME 2020.2, I would recommend modifying the TopoJSON file exploring using Python's json module. The json module is already shipped with FME.


Hello @ssmith_ftr​ 

It is currently not possible to write multiple feature types with the TopoJSON writer. The enhancement request related to this is tracked as FMEENGINE-75196.

However, it should be possible to route all features to a TopoJSON feature writer (without using a feature type fanout) and then modify the created TopoJSON to create one object per feature type using JSON transformers to create the 'combined' output you're expecting. I have attached an example workspace demonstrating this workflow created in FME 2022.1.

I tried recreating this workflow in FME 2020.2 but ran into several issues that have been fixed or improved in newer versions of FME. If you must use FME 2020.2, I would recommend modifying the TopoJSON file exploring using Python's json module. The json module is already shipped with FME.

I realized there was a setting misconfigured in the JSONUpdater. Try this updated version of the workspace instead.


Sorry to take while to respond I don't use JSON much today and had to fully digest what you did inside the workbench. You only used a few steps but the power of JSONTemplator and JSONUpdater together we not something I would've thought about.

 

The if-then-else kept throwing me off until I found Safe's article for JSONTemplator linking to the JSONiq docs. https://community.safe.com/s/article/json-writing-with-jsontemplater

 

I was able to take your workbench and integrate with my original workbench that had 4 distinct objects I needed to merge into single file with some additional properties. Everything works great now.

Thanks.


Hi @ssmith_ftr​,

We have added the capability to write multiple feature types to the TopoJSON writer. This available in the latest FME 2023 beta, which can be found at safe.com/beta.


I just want to say thanks for listening to users on requests. I thought this was a one time project and interesting how things come back again.

 

It just happens I was tasked with creating a MS Power BI report that needed custom polygons displayed on map. After searching Microsoft I found a custom visual for that would work. But this visual required I build a multi layer topoJSON file.

https://github.com/Microsoft/powerbi-visuals-drilldown-cartogram

 

I thought I would mention this in case you needed an example for FME 2023 release of why this feature is useful.

 

I look forward to testing 2023 Beta for this feature.


Reply