python-mapnik icon indicating copy to clipboard operation
python-mapnik copied to clipboard

Mapnik Grid: Is there a way to include the layer name into the data attributes?

Open alculquicondor opened this issue 8 years ago • 4 comments

I'm rendering multiple layers (one on top of another), and I need a way to distinguish (on the utfgrid) to which layer the element corresponds to. Any other suggestion to accomplish this?

alculquicondor avatar Jan 25 '17 00:01 alculquicondor

There is features=true parameter of encode method which should encode additional info into the grid JSON, see. This might be helpful.

talaj avatar Jan 25 '17 13:01 talaj

I guess you are referring to something like this:

mapnik.render_layer(self.mapnik, grid, layer=index, fields=fields)
encoded_grid = grid.encode('utf', resolution=self.scale, features=True)

But that's a boolean. How do I set the data? In case you refer to the fields parameter on render_layer call, AFAIK that refers to columns on the datasource, but I need the layer index, name or something equivalent.

alculquicondor avatar Jan 30 '17 20:01 alculquicondor

But that's a boolean. How do I set the data?

The data should be already collected in the grid object. You will not get layer index or name directly, but you can distinguish it by the feature data. This is all I have, sorry.

talaj avatar Jan 30 '17 21:01 talaj

I see, we have solved it in TileStache by manually inserting the layer name when adding each mapnik layer. But I wanted to do if there was already another solution in mapnik directly. Thanks

alculquicondor avatar Jan 30 '17 21:01 alculquicondor