# How to crop a given .osm file?

**URL:** <https://discourse.julialang.org/t/how-to-crop-a-given-osm-file/31305>\
**Category:** General Usage\
**Created:** [November 20, 2019, 8:55am UTC](https://discourse.julialang.org/t/how-to-crop-a-given-osm-file/31305 "2019-11-20T08:55:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [November 20, 2019, 8:55am UTC](https://discourse.julialang.org/t/how-to-crop-a-given-osm-file/31305/1 "2019-11-20T08:55:54Z")

</div>

I have been bothered with this for a while. I downloaded .osm.pbf file from the internet, it’s like 477MB. Then, I cropped it using the following command,

> osmium extract -b 10,10,25,40 map.osm.pbf -o map\_b.osm.pbf

and then

> osmium cat map.osm.pbf -o map\_b.osm

Now, map\_b.osm is like 456 MB.

Then, I started to load the .osm file and to parse it using a julia package. The thing is, the mapdata I got have all the bounds parameters 0 (min\_lat, max\_lat, min\_lon, max\_lon). This is rather strange.

I have used the other way to preprocess the download .osm.pbf from the internet, and it’s a little bit better than the above `osmium extract -b` , in the sense that at least the mapdata obtained has a non-zero bound.  
For example, I use the following to obtain all the highways.

`osmosis --read-xml map.osm --tf accept-ways highway=* --used-node --write-xml map_all_highways.osm`

The thing is, this map\_all\_highways.osm has like 2GB. It’s a bit big.

Then, I use `osmosis --read-xml map.osm --tf accept-ways highway=motorway highway=motorway_link highway=trunk highway=trunk_link highway=primary highway=primary_link highway=secondary highway=secondary_link highway=tertiary highway=tertiary_link highway=unclassified highway=residential --used-node --write-xml map_highways.osm`  
to obtain all the important highways. The file obtained is like 339MB. The thing is, many routing results got 0 in the end, which I need to double check more to make sure. Any suggestions? Any comments are greatly appreciated.
