Thursday, April 21, 2011

Mapbox, TileMill and TileStream

Tilemill is pretty awesome.  Quickly you can prepare data as shapefiles, zip them up and then theme them using Tilemill(you need to install it on OSX or linux, I'm using Ubuntu 10.10).  Once you have it installed you can very quickly theme a map using CSS like style code, then export your map into an MBtiles format and start serving it up using Tilestream.  I built both from source after mirroring the projects from their git repositories.
This screen shot is of the first map I am working on.  It uses some of the data that Mapbox team has stored on their s3 amazon account and a shapefile of the latest TEA district boundaries.  I'm working on making it more data rich. There are ways to use your custom MBtiles data with Google Maps API and OpenStreetMap data. 
Simple "MSS" style code to generate most of the above map, there are two other stylesheets being used. One for labeling(with various definitions for different zoom levels) and one to color all the school districts contrasting colors. The colors can be defined by attribute data read from the shapefile DBF.
Map {
  background-color: #fff;
}
 #states {
  line-color: #002bff;
  line-width: 1;
}
#lakes {
  polygon-fill:@water;
  line-color:#002bff;
  line-width:0.4;
  line-opacity:0.4;
}
#world {
  ::outline {
    line-color: #000;
    line-width: 4;
  }
  line-color: #fff;
  line-width: 2;
}
#districts {
  line-color: #rgba(0,0,0,0.75);
  line-width: 1;

Development Seed has designed and released for free an iPad Mapbox App. Once you've got map style sheets down using carto in tilemill you generate the mbtiles file and copy it over to your iPad and viola instant custom map works very fast even with HUGE datasets, I tested it with a shapefile with over 300,000 polygon and it worked very well and was stable too.  This is due to the data being converted to images and sliced into tilesets, therefore it doesn't have to render the millions of points needed to make all those polygons.

Monday, April 11, 2011

Code!

I've used a few snippets of code from http://gis.utah.gov/code
The last one I used was the spatial join points and polygons without creating an extra(trash) dataset.