Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have been looking at the UTFGrid specification and the usage of UTFGrid in Openlayers.

How do I create the required UTFGrid files for my data in PostGIS?

share|improve this question
add comment

2 Answers 2

This blog post is about exactly that. Looks like TileStache will handle it for you.

share|improve this answer
    
The only problem with this is that TileStache supports only EPSG 4326 & EPSG 3857 for the projection. I was looking for a more generic projection (UTM projection) –  Devdatta Tengshe Mar 12 '13 at 7:02
add comment

You can render UTF8 grids in mapnik directly - use the mapnik grid renderer, which nicely addresses the issue of being able to produce an image in any dimension.

For example in python:

import mapnik
import json

m = mapnik.load_map("map.xml")
layer_index = 0 #First layer on the map - index in m.layers
key = "__id__"  #Field used for the key in mapnik (should probably be unique)
resolution = 4  #Pixel resolution of output.
                #I'm pretty sure valid valuse are 1,2 and 4, but don't quote me
fields = []     #Attributes to output against the key

d = mapnik.render_grid(m, layer_index, key, resolution, fields) #returns a dictionary
json.dump(d, open("utf8.dump", "wb"), indent=2)

If you need help building your map.xml file for mapnik I'd go for TileMill - a really fantastic program for building mapnik xml from Carto CSS.

share|improve this answer
    
Bonus: in TileMill it's dead easy to bring in PostGIS data with a native connector as well. –  om_henners Mar 14 '13 at 22:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.