Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use Mapnik in an GeoDjango App with Spatialite 4.0 as backend. There is something weird with the tiles that I suspect might be related with a bad handling of mbr with spatialite.

If you look at those two images, the first is the tiles rendered in OpenLayers with a map.zoomToExtent on the features. If you look at the triangle in atlantic ocean you will see that the feature is not rendered entirely by Mapnik. The second image show the entire feature not tiled.

enter image description hereenter image description here

If I zoom in, the triangle continue to not be tiled correctly. If I zoom out a lot it finally appears.

I use this query in Mapnik:

query = '(select ' + geometryField + ', "id" from "shapefile_feature" where' + ' shapefile_id=' + str( + ') as geom'
datasource = mapnik.SQLite(file='C:\mygeosite\sqlite3\sql3.db',

featureLayer = mapnik.Layer("featureLayer")
featureLayer.datasource = datasource
share|improve this question
Where did the data come from? That is, what is the shapefile? – BradHards Apr 17 '13 at 20:57
Its a Multipolygon shapefile converted by FME from MapInfo format. I did the triangle inside the geodjango app with the geodjango.admin tool. I have verify the geometry of the triangle in spatialite, and it is conform with the other features geometry. – Below the Radar Apr 17 '13 at 22:39
I have seen the same problem with point shapefile created with QGIS. If a point is drawn far from other points, it doesnt appear in the tiles at certain zoom level. – Below the Radar Apr 17 '13 at 22:41
up vote 0 down vote accepted

I think I may have a part of the answer. I use only one table to store every features of every shapefiles uploaded in the geodjango app. Mapnik creates a spatial index on this table inside a distinct file named sql3.db.index. I think the problem is related to that spatial index, because when it is recreated after deletion, the features are displayed correctly. It seems this index is not updated when a feature geometry is modified.

Does anybody have more info about that? Which of Spatialite, GeoDjango or Mapnik is creating the sql3.db.index file. How I could manage to make it updated when a feature is modified?

share|improve this answer
Sounds like a bug. Perhaps try on mapnik web site? – BradHards Apr 18 '13 at 21:04
This paper describes a SpatiaLite scenario whereby the spatial index can become corrupted if the table doesn't have a primary key specified. seems odd to me that Mapnik would be to blame for the spatial index getting goofed---unless Mapnik is manipulating the db (I thought it was just a rendering engine?) I would expect maintaining the indices between Insert/Update calls to be the responsibility of the database. Am I wrong? – elrobis Apr 18 '13 at 23:43
I dont know if Mapnik is to blame, but I have notice that when tiles are rendered, the sql3.db.index is created if it was not already. This file is not generated by other process. And for Spatialite, the R-Tree Index is suppose to be stored in a virtual table inside the db not in a separate file. – Below the Radar Apr 19 '13 at 12:53
I see you asked your question over in the Mapnik group. :) – elrobis Apr 19 '13 at 14:08

Your Answer


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.