e-n-f / datamaps

Indexes points and lines and generates map tiles to display them
BSD 2-Clause "Simplified" License
342 stars 53 forks source link

Add readme instructions for stitching tilesets #4

Closed umaar closed 10 years ago

umaar commented 10 years ago

After a tileset has been created with enumerate and render could you add instructions for some next steps? e.g. how could one stitch/combine all the individual tiles to form one large image?

e-n-f commented 10 years ago

Thanks for the suggestion @umaar. Sure, I'll add some better documentation.

If you really just want a single stitched image, the way to do it is to do a single render -A for the bounding box you are interested in instead of generating separate tiles and then attaching them together. For example

./render -A -- dots.dm 12 37.192596 -122.811526 38.070528 -121.702961 > sf.png

to get a single image for the San Francisco Bay Area.

e-n-f commented 10 years ago

Added this example in https://github.com/ericfischer/datamaps/commit/066b0028284b7fdaaa77f7bb94ac7475403c891c

umaar commented 10 years ago

Thanks for the example. Maybe I can better explain my use case, I can generate maps of particular areas which is great! However what I'd like to do is essentially get a world map

./render -A -- data 6 73.39706 -160.664062 11.070603 158.554688 > world.png

Which works, the catch is, you'll end up with that's 29440 by 9472 Image too big at a certain zoom level - I had assumed tilesets were for creating very large images but maybe they serve a different use case.

What are your thoughts? Is it practical to generate a large "world map" at a high zoom level (say 16)? Alternatively, I guess the tiles could be used with Google maps (custom tiles for example), at least that way you're not left with a ~100mb png file!.

e-n-f commented 10 years ago

Oh yes, the reason for datamaps making tiles at all is so you can use them for web maps like the Google Maps API or Leaflet. A single image for the world at zoom level 16 will be an impractical 524288 pixels wide (2^(16+8)).

If you've generated tiles into a directory named "tiles" with

./enumerate whatever.dm | xargs -L1 -P8 ./render -o tiles

then you can use Leaflet in a web browser to display them from a page like https://gist.github.com/ericfischer/8625818. You can change the

map.addLayer(L.tileLayer('tiles/{z}/{x}/{y}.png', { maxZoom: 22 }));

line to reflect where you put your tiles if they are somewhere else. Using custom tiles with the Google Maps API will be something very similar but I forget exactly how you specify the tile URL there.

umaar commented 10 years ago

Thanks very much for the example @ericfischer, I'm creating tiles now so I'll give it a try but that Leaflet example looks to be exactly what I was looking for.

An idea: progress information when creating a tileset. Tileset creation looks like it can be quite intensive, so having an idea of how many tiles are remaining could be useful. I noticed you did this for encode.

e-n-f commented 10 years ago

Good idea. Added progress indication to enumerate in https://github.com/ericfischer/datamaps/commit/d90932b5b1cf8fed3d931d8ce2a44c6f57628320