optimizes basemap rendering for tiles

Hi,

I'm using django and basemap to render tiles i can use to make an
overlay on google maps. I'm using this to generate a topology of an open
mesh network (freifunk) here in leipzig :slight_smile:
On my local developing machine this works very nice and due heavy
caching of database lookups it doesn't seem slow. My problem is, that
the production machine isn't that fast and has to little memory :frowning:

Now I'm thinking of a better algorithm to generate the tiles. Currently
they are generated on demand and then saved to disc for later usage. But
the topology is fetched every 10 minutes, so the disc files timeout
relative fast.

my current algorithm looks like this:

fetch all node positions and cache them through pickle.
These are rendered as small blue dots on the map (Yes, here I can
optimize to only call plot when the node is in boundries of the tile.

then all connections for the last topo are fetched and cached.
Now there is a problem, I have to plot all connections into the plot,
because it's not easy to say which lines are actually in the tile. I
haven't looked deep into matplotlib to know how optimized it already
ignores plots which are out of bound.

Now I'm asking my self: is it possible to make a basemap instance with
some lat/lng borders, plot all stuff in it, and then move the borders to
get a new tile which is next to the last one ? Would such a algorithm be
faster then the current one ?

If not, there is also the posibility to create one large image at
largest zoomlevel for the most used region and then cut and scale the
image until all tiles are generated.

You can find the sourcecode at:
http://ff-firmware.quamquam.org/trac/browser/ffsomething/trunk/apps/uptime/topoimg.py
mktopo() is acutally doing the work :slight_smile:

kindly regards
  Daniel

Daniel Poelzleithner wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I'm using django and basemap to render tiles i can use to make an
overlay on google maps. I'm using this to generate a topology of an open
mesh network (freifunk) here in leipzig :slight_smile:
On my local developing machine this works very nice and due heavy
caching of database lookups it doesn't seem slow. My problem is, that
the production machine isn't that fast and has to little memory :frowning:

Now I'm thinking of a better algorithm to generate the tiles. Currently
they are generated on demand and then saved to disc for later usage. But
the topology is fetched every 10 minutes, so the disc files timeout
relative fast.

my current algorithm looks like this:

fetch all node positions and cache them through pickle.
These are rendered as small blue dots on the map (Yes, here I can
optimize to only call plot when the node is in boundries of the tile.

then all connections for the last topo are fetched and cached.
Now there is a problem, I have to plot all connections into the plot,
because it's not easy to say which lines are actually in the tile. I
haven't looked deep into matplotlib to know how optimized it already
ignores plots which are out of bound.

Now I'm asking my self: is it possible to make a basemap instance with
some lat/lng borders, plot all stuff in it, and then move the borders to
get a new tile which is next to the last one ? Would such a algorithm be
faster then the current one ?

If not, there is also the posibility to create one large image at
largest zoomlevel for the most used region and then cut and scale the
image until all tiles are generated.

You can find the sourcecode at:
http://ff-firmware.quamquam.org/trac/browser/ffsomething/trunk/apps/uptime/topoimg.py
mktopo() is acutally doing the work :slight_smile:

kindly regards
  Daniel
  
Daniel: If you know what the lat/lon boundaries of all the tiles are beforehand, you can create Basemap instances for all those tiles once, then save them to pickles and have the app just load those pickles on demand. That way you will avoid the overhead of creating the Basemap instances, which can be significant, especially when higher resolution boundaries are used (since all of those boundaries have to be transformed from geographic to projection coordinates when the instance is created).

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : Jeffrey S. Whitaker: NOAA Physical Sciences Laboratory