Question

Decrease size of file / Rounding coordinate in a list

  • 12 April 2022
  • 4 replies
  • 6 views

Hi everyone,

 

I'm currently trying to decrease the size of different file consisting of line and polygon geojson. After reducing the number of attribute and the name to a minimum, I'm looking to reduce the coordinate lenght of the those file.

 

I used the generalizer to decrease the number of coordinate being ouput by the line and polygon features. The other thing that would really help is to reduce the number precision or lenght of the number. I've tried to use the coordinaterounder transformer, but it those not remove the number itself.

 

From what I've read, only a python caller could round element in a list. If I choose this way, would I have to use a jsontemplater to format my geojson.

 

First, would it be possible to round the coordinate output directly in the geojson writer?

 

Second, what would be the script to add in python caller. I'm very new to python.

 

 


4 replies

Userlevel 3
Badge +16

You can edit a json file in notepad to view its contents, to try find more that can be trimmed out.

CoordinateRounder does work to reduce the precision of the coordinates which are output. Perhaps you need to reproject to Lat/Long before rounding, if you're not seeing any effect from it?

 

If the file has to be shared uncompressed, unfortunately geojson can get quite large, because each feature is stored separately as text, and the attributes are repeated for each feature. Depending on your use case, does each feature have to remain separate, could you aggregate features together if their attributes are identical? That will save space as well.

You can edit a json file in notepad to view its contents, to try find more that can be trimmed out.

CoordinateRounder does work to reduce the precision of the coordinates which are output. Perhaps you need to reproject to Lat/Long before rounding, if you're not seeing any effect from it?

 

If the file has to be shared uncompressed, unfortunately geojson can get quite large, because each feature is stored separately as text, and the attributes are repeated for each feature. Depending on your use case, does each feature have to remain separate, could you aggregate features together if their attributes are identical? That will save space as well.

As you can see in this post : https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/coordinaterounder.htm, Coordinate rounder does not actually trim the coordinate. So there is still quite a lot of character after that transformer. Also, I can not aggreate them. I have 5 feature that I need to separate in 12 group each to be downloaded by the users.

Userlevel 3
Badge +26

@Ian Gagnon-Renaud​ I wanted to point out that after your ZipExtractor transformer, there are 4 features being fed into the FeatureReader (atleast with the test data provided). This means there are 4 copies of the munic_s shapefile being read and processed. I'm not sure if this was by design, but it will contribute significantly to file size and processing time.

 

If it's not the intended action, I would use a Sampler between the ZipExtractor and FeatureReader to ensure the data is only read once.

@Ian Gagnon-Renaud​ I wanted to point out that after your ZipExtractor transformer, there are 4 features being fed into the FeatureReader (atleast with the test data provided). This means there are 4 copies of the munic_s shapefile being read and processed. I'm not sure if this was by design, but it will contribute significantly to file size and processing time.

 

If it's not the intended action, I would use a Sampler between the ZipExtractor and FeatureReader to ensure the data is only read once.

Sorry forgot to answer you. Yes, that really help. Like you said I was reading the file 4 time. Thx! In the end we decided to use a GDAL to round the coordinate with a system caller!

Reply