Skip to content

remove unused data from OSM files in repo #903

Closed

Description

@kodonnell

As discussed here (and following comments) there may be an interest in filtering OSM files to only include relevant data, before adding to the repo. (I'm assuming this is more relevant as an issue here than under map-matching, though I assume it applies to both.)

I definitely recommend it for new OSM files - but filtering existing files will (I think) make the repo bigger, and probably not gain us much?

Objectives for this issue:

  • figure out (and document) how to do the appropriate filtering
  • (optionally) apply it to existing OSM files

Cc @karussell @devemux86

Activity

  1. ratrun commented on Dec 8, 2016

    @ratrun
    Contributor

    Can you please describe a bit more what you mean by "repo"? Any why would somebody want to integrate such a functionality to graphhopper core? What is the goal (e.g. reduction of graph size,..)? From my perspective you are describing pre-processing steps one might to do and document for specific purposes. But shouldn't such steps be better kept out of scope for the graphhopper project?

  2. kodonnell commented on Dec 8, 2016

    @kodonnell
    ContributorAuthor

    Sorry @ratrun, I should've been clearer - we're not trying to add this functionality to the core (i.e. no code changes), it's just housekeeping. That is, why have full OSM files sitting in the (git) repo, when GH only needs road info, etc.? See the discussion linked above - it'd be nice to be able to add small OSM exports in as unit tests, but currently they're not small as they're full of extra junk. @karussell made the comment that it might be nice to apply this to existing OSM files in graphhoppper/map-matching.

  3. ratrun commented on Dec 10, 2016

    @ratrun
    Contributor

    Thanks @kodonnell, now I understand.
    I agree that e.g. buildings could be filtered away, but I would not filter out any ways which potentially could be used. I would not change already checked in files as their pre-decessors would still remain in the git repro. So this idea should be only applied to new files.

  4. kodonnell commented on Dec 10, 2016

    @kodonnell
    ContributorAuthor

    I agree that e.g. buildings could be filtered away, but I would not filter out any ways which potentially could be used.

    Agree. For context, the aforelinked OSM download was of only a few dozen roads, but was 6mb - in large part because of version/author information, but even things like tree species!

    I would not change already checked in files as their pre-decessors would still remain in the git repro. So this idea should be only applied to new files.

    There's probably a way to overwrite the history, but that scares me (and will probably cause problems) so yes, I agree.

  5. Nakaner commented on Apr 2, 2017

    @Nakaner
    Contributor

    I am adding this to this issue because it has the same reason.

    I just cloned this repository to my local machine. Because I used a slow DSL connection, I wondered why it took so painfully long. The result of my researches is: This repository is blown up by a handful of of questionable binary files.

    git clone git://github.com/graphhopper/graphhopper.git
    Klone nach 'graphhopper' ...
    remote: Counting objects: 57849, done.
    remote: Compressing objects: 100% (43/43), done.
    remote: Total 57849 (delta 11), reused 0 (delta 0), pack-reused 57797
    Empfange Objekte: 100% (57849/57849), 79.28 MiB | 352.00 KiB/s, Fertig.
    Löse Unterschiede auf: 100% (31743/31743), Fertig.
    

    I looked which files cause the increased the huge size and have not been deleted yet using git ls-tree -r -t -l --full-name HEAD | sort -n -k 4. Here are the last lines of the output which contain the largest files:

    100644 blob d4e1308cd8145b919dc5f9e078bde4b671accab7   94015	core/src/main/resources/com/graphhopper/reader/dem/Eurasia_names.txt
    100644 blob adf7ddd848b2ba74168ba2df9a72134e00769f94   98361	core/files/map-sidewalk-no.osm.gz
    100644 blob 5db2c6d4e9ba9bae1047b37acb13a87340206ec6  108415	web/src/main/webapp/js/lib/jquery-ui-custom-1.12.0.min.js
    100644 blob 25718abea1cb6bbcdb058a2dea6040fff973779e  169124	reader-shp/src/test/resources/data/gis.osm_roads_free_1.shx
    100644 blob d779934e48fafdcb7f9db465d3852540e2175a50  279487	core/files/moscow.osm.gz
    100644 blob ca7200f425f376013ddafdace5ca0d399c69c48d  333976	core/files/monaco.osm.gz
    100644 blob bceb49f6e4e7907a6fd11c17d251705ed354df38  449566	docs/core/images/17.jpg
    100644 blob a254b23e8d6c75fd2140d9026b2c3cf48b3e5855  450118	core/files/krems.osm.gz
    100644 blob 8842c67ff2817074a08c65729ceadbaa7d690abf  483425	core/files/Laufamholzstrasse.osm.xml
    100644 blob 4573cae8da2240fea8091a8200de72382917507d  515085	core/files/campo-grande.osm.gz
    100644 blob e9e8bc88630640e031264c543c9547c37896268f  543538	core/files/N43E007.hgt.zip
    100644 blob d56e591ad7993535e2792f0d20ac191e9fee446f  565390	core/files/andorra.osm.pbf
    100644 blob fb536a1de7e05bc37b1318aa742b77dfb111acd9  576904	core/files/S29W072.hgt.zip
    100644 blob f14b1b59f4f7d7c92cccd68ccf736d9b9bd42515  589869	web/graphhopper-web.png
    100644 blob 3d718b55708fd24c0e4793c096ff08459fb11319  594263	web/src/main/webapp/js/main.js
    100644 blob 3dd4381c9dce754903ea5ddbe070a4b80be1bcbd  761456	core/src/test/resources/com/graphhopper/reader/10000EWD.txt.gz
    100644 blob bbc3b2e502c930d99c0ef8b390f0624e9bccbb6f  872945	core/files/N52E008.hgt.zip
    100644 blob c03811c0028de5dc7cfdce77bf0dc0747b50e670 1048676	reader-osm/files/dem140191
    100644 blob c03811c0028de5dc7cfdce77bf0dc0747b50e670 1048676	reader-osm/files/dem142188
    100644 blob 265f900068a565164ba7a5226a0dcb390f146384 1269768	core/files/N55W003.hgt.zip
    100644 blob 5930eb29cbbd3413f7dfe33e5ea9f8621b9b7f6f 1332620	core/files/andorra.osm.gz
    100644 blob 0ffd88166777fb58bc69fee039ff1b30d5407734 1358226	core/files/N49E011.hgt.zip
    100644 blob 53404479bc31ba755626f039f6903ee771036467 1418473	core/files/north-bayreuth.osm.gz
    100644 blob 623adc98a9e2131857aef99088068a059f69eb13 1443718	core/files/N50E011.hgt.zip
    100644 blob 2c3edcd23bd2b99f2f09f576393fb3cb6fece951 2396663	web/src/main/resources/com/graphhopper/http/countries.geo.json
    100644 blob 815c82541fc0547c8f33b4b71c4ec59186ebf0e8 3013882	core/files/N48W125.hgt.zip
    100644 blob 491be81e73b2617753a7ee212f2f309b92cfec53 3244820	reader-shp/src/test/resources/data/gis.osm_roads_free_1.shp
    100644 blob 6b84456772ce9239911cc3255d67d737f377ca25 3301079	reader-shp/src/test/resources/data/malta-latest.osm.pbf
    100644 blob 116ff9c6482f0c5efe29348e1667b39033a5dc8e 3655497	reader-shp/src/test/resources/data/gis.osm_roads_free_1.dbf
    

    One reason is commit 1960b0f which added the free road shape files of Malta by Geofabrik to the repository.

    I think that these test data files should be downloaded from a third ressource (e.g. separate git repository as submodule for people really interested running unit tests of this part of the code) or should be replaced by a smaller shape file which also serves the needs or should be part of a Git submodule.

    The Perl script published here also reveals other commits larger than 1000000 bytes. The SRTM tiles, the shape file and the OSM extracts are in current master branch.

    bytes   SHA1
    2438830 b24950147b741375eae948abaabdc7716ec55cab -- move 2.3 MB large countries.geo.json 
    2439610 44e954b3163e79362905fa6a2507bcb35c5518da -- rename 2.3 MB large countries.geo.json 
    3270496 e085c0b3f3b1e8a3b5942d0938218bec40a357f3 -- many changes in source code files, ok
    2446334 0b5a60da2364abe742074c0b50f229180b060ae1 -- changes in countries.geo.json 
    3800201 2b888dad71178c8d767ea210a9a17e605b262205 -- new large JavaScript file
    3943020 2a621f4dee90b9d78bffb601bb182730b21828fc -- in gh-script branch (rename 3.6 MB OSM PBF and 3.6 MB zipped GTFS)
    3730551 7be9ec05ba3ab35ded6a7f925d3d85f380760d5c -- in fix_gh_script branch add 3.6 MB OSM PBF for the area of RNV
    3738709 048df0d2b35166d76c458dc74af4fdc76d9daee1 -- addition of the same file in branch "mz" a few minutes later (maybe a rebase?)
    10389816 1960b0f6239cb66fd6847fb865880a10e78eb025 -- commit discussed above introducing a shape file of Malta
    3938925 06971230dd314ae38edda0cb8d8e10a6743e60af -- addition of a large JavaScript file
    2151838 7d345ae02d17f2ab30b9c8cc178d00c90bf9d1bb -- addition of 3.6 MB zipped GTFS file
    2939935 712787ca00d45dfd0b5f4629277d2c98220418c5 -- addition of a large JavaScript file
    1578408 ea1a8e207d02cb52f2b062712b2c7e9689830c5c -- change formatting of the source code
    1392049 c6c18ce28ae1722bfb6338d517ca3093e205d1ac -- change copyright notices
    1408226 311969a8084a581a92cee2deb8d81899cf5dfdee -- uppercase to lowercase, camelCase to under_score
    3035434 2e60c80beb19f46c14d9d3b5cccc084b873e4944 -- add a 2.9 MB SRTM tile (core/files/N48W125.hgt.zip)
    2713486 0259d12b51ec924f397cdcbf4d6f2f49cec6e562 -- move three SRTM tiles, add one, delete one
    1070158 5ed7bd585e5ba8d6e397e89446c7a1e30fb1c3ee -- code formatting
    1548479 8c08b8c5eca24c972b5e38eccd14158fa3bc2b8f -- delete two OSM PBF files, add one (1.4 MB large)
    1495218 f0e21a63d2371bb3f949cdd4e6a4a6c8c619db10 -- add a SRTM tile (core/files/N50E011hgt.zip)
    3311500 0738d1ddfc8e293656e153ea676cc40a9ab199b2 -- add several SRTM tiles
    1363807 68575ca5c27bd5080c3413882186490d6937c2b7 -- add Andorra as OSM PBF and gzip compressed OSM XML
    1975663 5594f7f9d98d932f365557dc37b4b2d3b7abf698 -- moving many files
    1170075 4104b198a88296a5bef005e4fbad660494de4f9e -- renaming packages (and therefore renaming files)
    1259045 644e0d0d2dd2c9f4c3829f371ce96b1816ff664d -- moving gzip compressed OSM XML of Andorra and Monaco
    

    Deleting them using git rm is the wrong solution because that would not reduce the size of the Git history. Instead, you have to replace the bad commits which introduced this blobs by smaller ones and rebase all newer commits on them. git filter-branch does that. There is one disadvantage: All clones of this repository have to be rebase, too, if there latest commit is newer than the oldest modified commit.

  6. karussell commented on May 30, 2017

    @karussell
    Member

    There is one disadvantage: All clones of this repository have to be rebase, too, if there latest commit is newer than the oldest modified commit.

    We cannot do this :(

    For new files, which procedure do you suggest? E.g. at the moment I go to osm.org, select the area that I need, download and gzip. But when doing this at a border the file is >1MB even for a very tiny area. How could I remove the relations and everything associated in this case? With some osmosis or osmium magic?

  7. karussell commented on May 30, 2017

    @karussell
    Member

    I'm using now this

    osmfilter input.osm --drop="boundary=administrative" --drop-author --drop-version --drop-relations -o=output.osm
    

    update: we could remove everything building=yes or even building=*?
    keywords: strip, remove, compact, osmosis

  8. karussell commented on Sep 10, 2018

    @karussell
    Member

    This can be done for future files only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions