Skip to main content
minor addition
Source Link

I set up Mapnik to custom-render a GeoTiff file. python and xml files to do so were taken from a github mapnik example, and the successful image output is a rainbow-esque .png from the original .tif. Excellent.

All works fine, but now the question is: how can I configure Mapnik (either the python, xml or otherwise) to consider multiple .tif files when rendering images? These won't be overlapping tifs that contain different sets of information, but rather geographically-adjacent tifs that contain the same type of information. Together, they will cover a larger geographical area.

For larger context: my goal is to download all SRTM files (there are 1000s) and store them in a single directory. Using mod_tile, Mapnik, and whatever other bits of software I need, I want to be able to generate tile images of the SRTM data for consumption by a map in a browser (e.g. Leaflet, Google Map). mod_tile will be used for caching, but I will need to use Mapnik to generate images on the fly according to certain user preferences (e.g. user may be able to specify their own color bands for the elevation data).

How do I best make Mapnik consider multiple side-by-side GeoTiffs, when generating tiles? Is that even possible? do I have to create a single (massive) GeoTiff by stitching all of the SRTM files together? GDAL virtual format?

I may be looking at the problem the wrong way, as I am new to Mapnik and creating tiles - please let me know if I am.

Here is the python code:

import mapnik
mapxmlfile = 'raster_colorizer_small.xml'
outputfile = 'raster_colorizer_test.png'
m = mapnik.Map(800, 600)
mapnik.load_map(m, mapxmlfile)
m.zoom_all()
mapnik.render_to_file(m, outputfile)

And here is the raster_colorizer_small.xml file:

<Map background-color="white" srs="+init=epsg:32630">
  <Style name="DISCRETE RAINBOW">
    <Rule>
      <RasterSymbolizer>
        <RasterColorizer default-mode="discrete" default-color="white" >
            <stop color="red"    value = "0"  />
            <stop color="orange" value = "5"  />
            <stop color="yellow" value = "10" />
            <stop color="green"  value = "15" />
            <stop color="blue"   value = "20" />
            <stop color="indigo" value = "25" />
        </RasterColorizer>
      </RasterSymbolizer>
    </Rule>
  </Style>
  <Layer name="dataraster" srs="+init=epsg:32630">
      <StyleName>DISCRETE RAINBOW</StyleName>
      <Datasource>
          <Parameter name="file">../data/dataraster.tif</Parameter>
          <Parameter name="type">gdal</Parameter>
          <Parameter name="band">1</Parameter>
      </Datasource>
  </Layer>
</Map>

 

I set up Mapnik to custom-render a GeoTiff file. python and xml files to do so were taken from a github mapnik example, and the successful image output is a rainbow-esque .png from the original .tif. Excellent.

All works fine, but now the question is: how can I configure Mapnik (either the python, xml or otherwise) to consider multiple .tif files when rendering images? These won't be overlapping tifs that contain different sets of information, but rather geographically-adjacent tifs that contain the same type of information. Together, they will cover a larger geographical area.

For larger context: my goal is to download all SRTM files (there are 1000s) and store them in a single directory. Using mod_tile, Mapnik, and whatever other bits of software I need, I want to be able to generate tile images of the SRTM data for consumption by a map in a browser (e.g. Leaflet, Google Map). mod_tile will be used for caching, but I will need to use Mapnik to generate images on the fly according to certain user preferences (e.g. user may be able to specify their own color bands for the elevation data).

How do I make Mapnik consider multiple side-by-side GeoTiffs, when generating tiles? Is that even possible? do I have to create a single (massive) GeoTiff by stitching all of the SRTM files together?

I may be looking at the problem the wrong way, as I am new to Mapnik and creating tiles - please let me know if I am.

Here is the python code:

import mapnik
mapxmlfile = 'raster_colorizer_small.xml'
outputfile = 'raster_colorizer_test.png'
m = mapnik.Map(800, 600)
mapnik.load_map(m, mapxmlfile)
m.zoom_all()
mapnik.render_to_file(m, outputfile)

And here is the raster_colorizer_small.xml file:

<Map background-color="white" srs="+init=epsg:32630">
  <Style name="DISCRETE RAINBOW">
    <Rule>
      <RasterSymbolizer>
        <RasterColorizer default-mode="discrete" default-color="white" >
            <stop color="red"    value = "0"  />
            <stop color="orange" value = "5"  />
            <stop color="yellow" value = "10" />
            <stop color="green"  value = "15" />
            <stop color="blue"   value = "20" />
            <stop color="indigo" value = "25" />
        </RasterColorizer>
      </RasterSymbolizer>
    </Rule>
  </Style>
  <Layer name="dataraster" srs="+init=epsg:32630">
      <StyleName>DISCRETE RAINBOW</StyleName>
      <Datasource>
          <Parameter name="file">../data/dataraster.tif</Parameter>
          <Parameter name="type">gdal</Parameter>
          <Parameter name="band">1</Parameter>
      </Datasource>
  </Layer>
</Map>

 

I set up Mapnik to custom-render a GeoTiff file. python and xml files to do so were taken from a github mapnik example, and the successful image output is a rainbow-esque .png from the original .tif. Excellent.

All works fine, but now the question is: how can I configure Mapnik (either the python, xml or otherwise) to consider multiple .tif files when rendering images? These won't be overlapping tifs that contain different sets of information, but rather geographically-adjacent tifs that contain the same type of information. Together, they will cover a larger geographical area.

For larger context: my goal is to download all SRTM files (there are 1000s) and store them in a single directory. Using mod_tile, Mapnik, and whatever other bits of software I need, I want to be able to generate tile images of the SRTM data for consumption by a map in a browser (e.g. Leaflet, Google Map). mod_tile will be used for caching, but I will need to use Mapnik to generate images on the fly according to certain user preferences (e.g. user may be able to specify their own color bands for the elevation data).

How do I best make Mapnik consider multiple side-by-side GeoTiffs, when generating tiles? Is that even possible? do I have to create a single (massive) GeoTiff by stitching all of the SRTM files together? GDAL virtual format?

I may be looking at the problem the wrong way, as I am new to Mapnik and creating tiles - please let me know if I am.

Here is the python code:

import mapnik
mapxmlfile = 'raster_colorizer_small.xml'
outputfile = 'raster_colorizer_test.png'
m = mapnik.Map(800, 600)
mapnik.load_map(m, mapxmlfile)
m.zoom_all()
mapnik.render_to_file(m, outputfile)

And here is the raster_colorizer_small.xml file:

<Map background-color="white" srs="+init=epsg:32630">
  <Style name="DISCRETE RAINBOW">
    <Rule>
      <RasterSymbolizer>
        <RasterColorizer default-mode="discrete" default-color="white" >
            <stop color="red"    value = "0"  />
            <stop color="orange" value = "5"  />
            <stop color="yellow" value = "10" />
            <stop color="green"  value = "15" />
            <stop color="blue"   value = "20" />
            <stop color="indigo" value = "25" />
        </RasterColorizer>
      </RasterSymbolizer>
    </Rule>
  </Style>
  <Layer name="dataraster" srs="+init=epsg:32630">
      <StyleName>DISCRETE RAINBOW</StyleName>
      <Datasource>
          <Parameter name="file">../data/dataraster.tif</Parameter>
          <Parameter name="type">gdal</Parameter>
          <Parameter name="band">1</Parameter>
      </Datasource>
  </Layer>
</Map>

 
fixed grammar
Source Link

I have set up Mapnik to custom render-render a GeoTiff file. The python and xml files to do so arewere taken from somea github mapnik examplesexample, and I have them working successfully - the successful image that is output is is a rainbow-esque .png offrom the original .tif. Excellent.

This allAll works fine, but now the question is: how can I configure Mapnik (either the python or, xml or otherwise) to consider multiple .tif files when rendering images? These won't be overlapping tifs containingthat contain different sets of information, but rather adjacentgeographically-adjacent tifs that contain the same type of information but together. Together, they will cover a larger geographical area.

For larger context,: my goal is to download all SRTM files (there are 1000s) and store them in a single directory. UsingUsing mod_tile, Mapnik, and whatever other bits of software I need to, I want to be able to generate tile images of the SRTM data for consumption by a map in a browser (e.g. Leaflet, Google Map). mod_tile will be used for caching, but I will need to use Mapnik to generate images on the fly according to certain user preferences (e.g. user may be able to specify their own color bands for the elevation data).

How do I make Mapnik consider multiple side-by-side GeoTiffs, when generating tiles? Is that even possible? Must do I have to create a single (massive) GeoTiff by stitching together all of the SRTM files together?

Here is the python code:

I have set up Mapnik to custom render a GeoTiff file. The python and xml files to do so are taken from some github mapnik examples, and I have them working successfully - the image that is output is a rainbow-esque .png of the original .tif.

This all works fine, but how can I configure Mapnik (either the python or xml or otherwise) to consider multiple .tif files when rendering images? These won't be overlapping tifs containing different information but rather adjacent tifs that contain the same information but together cover a larger geographical area.

For larger context, my goal is to download all SRTM files (there are 1000s) and store them in a single directory. Using mod_tile, Mapnik, and whatever other bits of software I need to, I want to be able to generate tile images of the SRTM data for consumption by a map in a browser (e.g. Leaflet, Google Map). mod_tile will be used for caching, but I will need to use Mapnik to generate images on the fly according to certain user preferences (e.g. user may be able to specify their own color bands for the elevation data).

How do I make Mapnik consider multiple side-by-side GeoTiffs when generating tiles? Is that even possible? Must I create a single (massive) GeoTiff by stitching together all of the SRTM files?

Here is the python

I set up Mapnik to custom-render a GeoTiff file. python and xml files to do so were taken from a github mapnik example, and the successful image output is a rainbow-esque .png from the original .tif. Excellent.

All works fine, but now the question is: how can I configure Mapnik (either the python, xml or otherwise) to consider multiple .tif files when rendering images? These won't be overlapping tifs that contain different sets of information, but rather geographically-adjacent tifs that contain the same type of information. Together, they will cover a larger geographical area.

For larger context: my goal is to download all SRTM files (there are 1000s) and store them in a single directory. Using mod_tile, Mapnik, and whatever other bits of software I need, I want to be able to generate tile images of the SRTM data for consumption by a map in a browser (e.g. Leaflet, Google Map). mod_tile will be used for caching, but I will need to use Mapnik to generate images on the fly according to certain user preferences (e.g. user may be able to specify their own color bands for the elevation data).

How do I make Mapnik consider multiple side-by-side GeoTiffs, when generating tiles? Is that even possible? do I have to create a single (massive) GeoTiff by stitching all of the SRTM files together?

Here is the python code:

Source Link

use mapnik to read from multiple geotiffs

I have set up Mapnik to custom render a GeoTiff file. The python and xml files to do so are taken from some github mapnik examples, and I have them working successfully - the image that is output is a rainbow-esque .png of the original .tif.

This all works fine, but how can I configure Mapnik (either the python or xml or otherwise) to consider multiple .tif files when rendering images? These won't be overlapping tifs containing different information but rather adjacent tifs that contain the same information but together cover a larger geographical area.

For larger context, my goal is to download all SRTM files (there are 1000s) and store them in a single directory. Using mod_tile, Mapnik, and whatever other bits of software I need to, I want to be able to generate tile images of the SRTM data for consumption by a map in a browser (e.g. Leaflet, Google Map). mod_tile will be used for caching, but I will need to use Mapnik to generate images on the fly according to certain user preferences (e.g. user may be able to specify their own color bands for the elevation data).

How do I make Mapnik consider multiple side-by-side GeoTiffs when generating tiles? Is that even possible? Must I create a single (massive) GeoTiff by stitching together all of the SRTM files?

I may be looking at the problem the wrong way, as I am new to Mapnik and creating tiles - please let me know if I am.

Here is the python

import mapnik
mapxmlfile = 'raster_colorizer_small.xml'
outputfile = 'raster_colorizer_test.png'
m = mapnik.Map(800, 600)
mapnik.load_map(m, mapxmlfile)
m.zoom_all()
mapnik.render_to_file(m, outputfile)

And here is the raster_colorizer_small.xml file:

<Map background-color="white" srs="+init=epsg:32630">
  <Style name="DISCRETE RAINBOW">
    <Rule>
      <RasterSymbolizer>
        <RasterColorizer default-mode="discrete" default-color="white" >
            <stop color="red"    value = "0"  />
            <stop color="orange" value = "5"  />
            <stop color="yellow" value = "10" />
            <stop color="green"  value = "15" />
            <stop color="blue"   value = "20" />
            <stop color="indigo" value = "25" />
        </RasterColorizer>
      </RasterSymbolizer>
    </Rule>
  </Style>
  <Layer name="dataraster" srs="+init=epsg:32630">
      <StyleName>DISCRETE RAINBOW</StyleName>
      <Datasource>
          <Parameter name="file">../data/dataraster.tif</Parameter>
          <Parameter name="type">gdal</Parameter>
          <Parameter name="band">1</Parameter>
      </Datasource>
  </Layer>
</Map>