{"id":19933525,"url":"https://github.com/tnocs/minify-geojson","last_synced_at":"2025-05-03T11:33:38.572Z","repository":{"id":9790850,"uuid":"63320420","full_name":"TNOCS/minify-geojson","owner":"TNOCS","description":"Minifies (compresses) a GeoJSON file, i.e. by removing properties or using fewer decimals for coordinates.","archived":false,"fork":false,"pushed_at":"2023-08-03T06:36:20.000Z","size":207,"stargazers_count":26,"open_issues_count":7,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-07T09:53:23.379Z","etag":null,"topics":["compresses","geojson","geojson-parser","minifies","minify","minify-geojson"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TNOCS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-07-14T09:04:56.000Z","updated_at":"2023-10-27T12:53:37.000Z","dependencies_parsed_at":"2023-11-22T08:52:06.387Z","dependency_job_id":null,"html_url":"https://github.com/TNOCS/minify-geojson","commit_stats":{"total_commits":93,"total_committers":3,"mean_commits":31.0,"dds":"0.032258064516129004","last_synced_commit":"26c009386afaf8e5720c959ffb2d6c3ac03e1696"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TNOCS%2Fminify-geojson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TNOCS%2Fminify-geojson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TNOCS%2Fminify-geojson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TNOCS%2Fminify-geojson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TNOCS","download_url":"https://codeload.github.com/TNOCS/minify-geojson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224360118,"owners_count":17298319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compresses","geojson","geojson-parser","minifies","minify","minify-geojson"],"created_at":"2024-11-12T23:14:04.372Z","updated_at":"2024-11-12T23:14:05.067Z","avatar_url":"https://github.com/TNOCS.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# minify-geojson\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/786f95aba4434d0bb464d820f096d63d)](https://www.codacy.com/app/erikvullings/minify-geojson?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=TNOCS/minify-geojson\u0026utm_campaign=badger)\n\nA small tool to minify (compress) a GeoJSON file by:\n\n- Removing non-significant whitespace\n- Reducing the number of decimals used for coordinates: option `-c 5` to keep 5 decimals\n- Minify the length of the keys by mapping each key name to a single or double letter combination: option `-k` converts long property keys such as `my_long_property_name` to `a` or `ab`. **Warning:** If you already have property keys like `a` or `b`, it may map them to the wrong name.\n- Blacklist keys, i.e. remove these keys from the output\n- Whitelist keys, i.e. only keep these keys in the output\n- Filter features, i.e. only keep those features whose properties satisfy certain conditions.\n\nThe tool works in two modes: for files that require reprojection or topojson output, it will read in all data at once. In case your GeoJSON file is too large for node.js to handle, this may fail. That's why it normally uses a streaming mode, so also large files can be processed easily (after which you can try reprojecting it again).\n\n## Installation\n\nTo run it standalone:\n\n```shell\nnpm i -g minify-geojson\n```\n\nAfter which the `minify-geojson` command should be available.\n\nAlternatively, you can fork/download/clone the repository, and execute:\n\n```shell\nnpm install\nnpm link\nnpm run watch\n```\n\nAny changes in the Typescript code will be compiled, and since you've linked the project, you can use the `minify-geojson` command from the command line too.\n\n## Manual\n\n```shell\nMinify GeoJSON\n\n  Minify (compress) each input GeoJSON or ESRI shapefile by replacing the\n  attribute keys with a shorter representation (typically, its first letter).\n  You can also reduce the number of decimals for coordinates and properties,\n  whitelist and blacklist or filter certain properties. Output can be GeoJSON\n  or TopoJSON. If you wish to reproject to WGS84, you can supply the EPSG code\n  (which will be resolved via\n  http://www.spatialreference.org/ref/epsg/YOURCODE/proj4/).\n\nOptions\n\n  -k, --keys Boolean                  Minify property keys, e.g. id remains id, telephone\n                                      becomes t, address a etc.\n  -i, --includeKeyMap Boolean         Add the key map to the GeoJSON file. Requires the -k\n                                      flag too.\n  -t, --topo Boolean                  Output format is TopoJSON instead of GeoJSON.\n  -r, --reproject String              Reproject to WGS84 by supplying the input EPSG\n                                      coordinate system, e.g. -r EPSG:28992.\n  -f, --filter String                 Comma separted list of property filters, which will\n                                      KEEP those features when the property filter returns\n                                      true, e.g. filter \"WATER = NO\" will filter out\n                                      feature\\'s where { \"WATER\": \"NO\" }.\n  -b, --blacklist String              Comma separated list of properties that should be\n                                      removed (others will be kept). Note that keys will not\n                                      be minified unless the -k flag is used too.\n  -w, --whitelist String              Comma separated list of properties that should be kept\n                                      (others will be removed). Note that keys will not be\n                                      minified unless the -k flag is used too.\n  -c, --coordinates Positive number   Only keep the first n digits of each coordinate.\n  -d, --decimals Positive number      Only keep the first n digits of each decimal property.\n  -s, --src File names                Source files to process: default option, you do not need to\n                                      supply the -s flag.\n  -v, --verbose Boolean               Output is verbose.\n\nExamples\n\n  01. Shrink property keys and output to        $ minify-geojson -k original.geojson\n  original.min.geojson\n  02. A verbose version                         $ minify-geojson -kv original.geojson\n  03. Prune the blacklisted properties          $ minify-geojson -b \"property1, property2\"\n                                                original.geojson\n  04. Keep the whitelisted properties           $ minify-geojson -w \"property1, property2\"\n                                                original.geojson\n  05. Removes superfluous decimals (keep        $ minify-geojson -c 5 original.geojson\n  first 5)\n  06. Add the key mapping to the output         $ minify-geojson -ki original.geojson\n  07. Convert output to topojson (-i and -c     $ minify-geojson -kt original.geojson\n  are not used)\n  08. Reproject shape file in RD (EPSG:28992)   $ minify-geojson -ktv -r 28992 original.shp\n  to TopoJSON\n  09. Filter based on properties                $ minify-geojson -ktv -r 28992 -f \"WATER =\n                                                NO, CITY=Amsterdam\" -b \"WATER, CITY\"\n                                                original.shp\n  10. Full example                              $ minify-geojson -ktiv -w \"property1,\n                                                property2\" -c 5 original.geojson\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftnocs%2Fminify-geojson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftnocs%2Fminify-geojson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftnocs%2Fminify-geojson/lists"}