Page:
Raster
Pages
A perfect testcase
API changes between v2.0 and v2.1
API changes between v3.0 and v3.1
AWS Lambda
About Mapnik
AlsoFilter
Api changes between v2.1 and v2.2
Api changes between v2.2 and v2.3
Api changes between v2.3 and v3.0
ArchInstallation
Aspect Fix Mode
Benchmark Notes
BoundsClipping
BrokenExceptions
BuildingSymbolizer
CSV Plugin
CairoVersions
CentOS_RHEL
ChangeLog
Code sprint
CodingStandards
Compiler Notes
Compositing
Contributing
DebianInstallation
DebugSymbolizer
DebuggingMapnik
DemoGallery
DeveloperTopics
DevelopingPlugins
Development
ElseFilter
ExampleCode
Expression
FasterCompiling
Fasterlabeling
Filter
FontSet
FreeBSDInstallation
GDAL
GEOS
GSOC Ideas
GSOC2010
GSOC2010_Application
GSOC2010_Ideas
GSOC2011
GSOC2011_Ideas
GeoJSON Plugin
GettingStarted
GettingStartedInPython
GettingStartedInXML
GlyphSymbolizer
GroupSymbolizer
Grouped rendering
Gsoc2012 application
Gsoc2012
HaitiStyles
Home
Ideas
Ideas_Compositing
Ideas_FutureMapnik
Image IO
InstallationTroubleshooting
InternationalText
IntroductionToGIS
Kismet
LabelingSupport
Layer
LearningMapnik
Legending
LinePatternSymbolizer
LineSymbolizer
LinuxInstallation
Logging
MacInstallation
MacInstallationSource
MacInstallation_Homebrew
MacPostGIS_Setup
MacPythonUpgradeIssues
ManagingLargeXmlFiles
MapDesign
Mapnik Development
Mapnik Installation
Mapnik with wxPython
Mapnik2
Mapnik2_Changes
MapnikCodeSprint
MapnikCodeSprint_MCS01
MapnikCodeSprint_MCS01_Location
MapnikCodeSprint_MCS01_Results
MapnikCodeSprint_MCS01_Schedule
MapnikCodeSprint_MCS02
MapnikCoreConcepts
MapnikDependencies
MapnikInstallationSvn
MapnikReferences
MapnikReleaseSteps
MapnikReleases
MapnikRenderers
MapnikTutorials
MapnikUtilities
MapnikViewer
Mapnikinstallation
MarkersSymbolizer
MaxScaleDenominator
MemoryDatasource
MetaWriter
MinScaleDenominator
ModServer
Nik2Img
Notes and caveats
OCCI
OGR
OpenSolarisInstallation
OpenSolarisInstallation_32bit
OpenSolarisInstallation_64bit
OpenSolarisInstallation_TroubleShooting
OpenSuse
OpenSuseInstallation
OptimizeRenderingWithPostGIS
OsmPlugin
OutputFormats
PackageBuilding
Paleoserver
Path Expression
PgRaster
PluginArchitecture
PointSymbolizer
PolygonPatternSymbolizer
PolygonSymbolizer
PostGIS
Postgis async
Python Plugin
Python3k
RFC: Raster color interpretation
Raster
RasterColorizer
RasterSymbolizer
Rasterlite
Related projects and utilities
Release0.6.0
Release0.6.1
Release0.7.0
Release0.7.1
Release0.7.2
Release2.0.0
Release2.0.1
Release2.0.2
Release2.1.0
Release2.2.0
Runtime Logging
SQLite
SVG support
Scale factor
ScaleAndPpi
ShapeFile
ShieldSymbolizer
ShieldSymbolizerTests
Style
StyleShare
Svg rendering gochas
SymbologySupport
Text Rendering Overview
TextSymbolizer
Trac to Github wiki migration notes
Troubleshooting
UbuntuInstallation
UbuntuInstallationOld
UsingCustomFonts
UsingScons
WindowsInstallation
World population tutorial
XMLConfigReference
XmlFormatDiscussion
iOS
mapnik.Datasource
mapnik.Layer
mapnik.Map
my choice
No results
10
Raster
Matthieu Bonnefoy edited this page 2016-04-20 14:19:59 +12:00
Table of Contents
This plugin supports reading tiff and geotiff files.
Tiled or Stripped tiff files are required and when rasters are small < 200-300 MB this driver is faster that the GDAL plugin.
If files are larger it is recommended to build GDAL overviews (with gdaladdo command) and instead read with the GDAL plugin.
Note: overviews support is available only in Mapnik >= 0.7.0
A drawback(or advantage!) of this plugin is that it requires manually setting the file bounds.
- hint: create a GDAL datasource from your tiff in python, call the envelope() method to get the bounds, and use those.
For other plugins see: PluginArchitecture
Installation
To check if the raster plugin built and was installed correctly you can do:
>>> from mapnik import DatasourceCache as c
>>> 'raster' in c.plugin_names()
True
Parameters
parameter | value | description | default |
file | string | geotiff file path | |
base | string | optional base path where to search for the tiff raster file | |
lox | double | lower x corner of the image in map coordinates | |
loy | double | lower y corner of the image in map coordinates | |
hix | double | upper x corner of the image in map coordinates | |
hiy | double | upper y corner of the image in map coordinates | |
extent | string | extent of the image in map coordinates, comma or space separated (at least or should be passed) | |
format | string | image format to use, currently only tiff is supported | tiff |
Styling
To style a layer use the RasterSymbolizer
Usage
Python
<!-- NOTE: must be in the same SRS as your map-->
<Layer name="Raster">
<StyleName>raster</StyleName>
<Datasource>
<Parameter name="type">raster</Parameter>
<Parameter name="file">/path/to/my/raster/file.tiff</Parameter>
<Parameter name="lox">min_x</Parameter>
<Parameter name="loy">min_y</Parameter>
<Parameter name="hix">max_x</Parameter>
<Parameter name="hiy">max_y</Parameter>
</Datasource>
</Layer>
from mapnik import Raster, Layer
raster = Raster(base='/home/mapnik/data',file='/path/to/my/raster/file.tiff',lox=minx,loy=min_y,hix=max_x,hiy=max_y)
lyr = Layer('Tiff Layer')
lyr.datasource = raster
C++
Plugin datasource initialization example code can be found on PluginArchitecture.
A Raster datasource may be created as follows:
{
parameters p;
p["type"]="raster";
p["file"]="/path/to/my/raster/file.tiff";
p["lox"]=min_x;
p["loy"]=min_y;
p["hix"]=max_x;
p["hiy"]=max_y;
set_datasource(datasource_cache::instance()->create(p));
layer lyr("Raster");
lyr.add_style("raster");
m.add_layer(lyr);
}