Question

How to extract attributes from nested GeoJSON

  • 25 February 2021
  • 8 replies
  • 6 views

Picking any country from https://osm-boundaries.com/Map >download tick all_tags gives this in FME

FME01However in attribute manger I can only see the 7 input attributes

The all_tags looks like thisAll_tagsWhat I'd like to do is extract the non "name" tags as unique attributes

E.G. is_in, ISO3166-2, wikkidata etc.

Some of the tags are like is_in:country : VALUE

and keep the rest as a JSON string (keeping the values as is maintaining diacritics)

Some features have more unique tags than others so my output PostGIS table will have all possible columns and any feature with out a particular tag should be a NULL string

 

I can then write to a PostGIS database

 

Can someone tell me how to extract the all_tags JSON string as described?


8 replies

Userlevel 4
Badge +30

Hi @geo_geek

Could you share the Workspace template ( .fmwt )?

 

Thanks in Advance,

Danilo

 

@danilo_fme​ 

I attach Workspace template ( .fmwt ) as requested

 

Userlevel 4
Badge +30

 

@danilo_fme​ 

I attach Workspace template ( .fmwt ) as requested

 

Thanks @geo_geek​ . Could you sned me ( please ) the reader too?

Hi

Not totally sure what reader your asking for

On the reader => properties => help it points to

GeoJSON (Geographic JavaScript Object Notation) Reader/Writer

 

https://docs.safe.com/fme/2020.2/html/FME_Desktop_Documentation/FME_ReadersWriters/geojson/geojson.htm

 

This has the option of flattening all_tags to columns but as each data set has different tags this isn't of use I need a more dynamic method

 

Badge +20

Hi

Not totally sure what reader your asking for

On the reader => properties => help it points to

GeoJSON (Geographic JavaScript Object Notation) Reader/Writer

 

https://docs.safe.com/fme/2020.2/html/FME_Desktop_Documentation/FME_ReadersWriters/geojson/geojson.htm

 

This has the option of flattening all_tags to columns but as each data set has different tags this isn't of use I need a more dynamic method

 

@danilo_fme​ is refering to the .json file you downloaded from osm-boundaries.com.

We don't know if we need to be logged in to download or there is a trick to it but the download button isn't active.

OK

to enable DL you have to have a free Open Street map account and authenticate with that

 

I attach Thailand.geojson.gz as this has enough variety in the all_tags string other countries have more properties

Please note in order to upload I had to create a zip file this might need unziping

 

Sorry zip file attached hopefully other format wouldn't upload

Userlevel 4
Badge +30

Sorry zip file attached hopefully other format wouldn't upload

Thanks @geo_geek​ your data.

Reply