SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
INTRODUZIONE A MAPNIK




Luca Delucchi       OSMit 2009
Mapnik è un software libero per la
rappresentazione di dati geografici


              Permette la realizzazione di
            immagini singole oppure di tile
             per la pubblicazione sul web

             Multipiattaforma
        Linux - Mac OS X - Windows




Luca Delucchi                     OSMit 2009
Scritto in C++ con python
                 bindings che facilitano
                         l'utilizzo

 Utilizza standard OGC,
  librerie GDAL/OGR,
     proj, agg e cairo

                Utilizza l'algoritmo di Painter
                      per determinare l'ordine
                                degli elementi




Luca Delucchi                       OSMit 2009
Utilizzo



Script per il rendering:   Regole per gli stili:

- per le immagini          - file XML

- per le tile              - python

                           - c++




Luca Delucchi                           OSMit 2009
Stampa: png
#!/usr/bin/python

from mapnik import *
import cairo

mapfile = "progetto.xml"
map_output= 'prova_dim.png'
m = Map(1192, 840)
projection = '+proj=latlong +datum=WGS84'
load_map(m, mapfile)
bbox = Envelope(Coord(9.04311180114746,
45.7490234375), Coord(12.0447950363159,
47.1829261779785))
m.zoom_to_box(bbox)
render_to_file(m, map_output, 'png')



Luca Delucchi                               OSMit 2009
Stampa: png
#!/usr/bin/python

from mapnik import *
import cairo

mapfile = 'progetto.xml'
map_output = 'mapfile.pdf'
projection = '+proj=latlong +datum=WGS84'
m = Map(1192, 840)
load_map(m, mapfile)
bbox = Envelope(9.470383644104, 43.2393798828125,
12.4720678329468, 44.673282623291)
mapnik_map.zoom_to_box(bbox)
file = open(map_output, 'wb')
surface = cairo.PDFSurface(file.name, m.width, m.height)
render(m, surface)
surface.finish()

Luca Delucchi                                  OSMit 2009
File XML: map



<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map bgcolor="#b5d0d0" srs="+proj=merc +a=6378137
+b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0
+k=1.0 +units=m +nadgrids=@null +no_defs +over">

.................................................................................................
.................................................................................................
.................................................................................................

</Map>




 Luca Delucchi                                                                OSMit 2009
File XML: raster layer
<Layer name="dem" status="on">
   <StyleName>raster</StyleName>
   <Datasource>
     <Parameter name="type">gdal</Parameter>
     <Parameter name="file">/path/al/file/</Parameter>
     <Parameter name="format">tiff</Parameter>
   </Datasource>
</Layer>

  <Datasource>
    <Parameter    name="type">raster</Parameter>
    <Parameter    name="file">/path/file.tiff</Parameter>
    <Parameter    name="format">tiff</Parameter>
    <Parameter    name="lox">5.0</Parameter>
    <Parameter    name="loy">35.0</Parameter>
    <Parameter    name="hix">20.0</Parameter>
    <Parameter    name="hiy">50.0</Parameter>
  </Datasource>

 Luca Delucchi                                 OSMit 2009
File XML: postgis layer

<Layer name="misc_boundaries" status="on"
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0
+lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m
+nadgrids=@null +no_defs +over">
  <StyleName>boundary</StyleName>
  <Datasource>
    <Parameter name="type">postgis</Parameter>
    <Parameter name="user">utente</Parameter>
    <Parameter name="dbname">italy</Parameter>
    <Parameter name="password">****</Parameter>
    <Parameter name="table">(select * from italy_line) as
     road </Parameter>
    <Parameter name="estimate_extent">...</Parameter>
    <Parameter name="extent">833337,5432307,
   1119564,5572109</Parameter>
  </Datasource>
</Layer>
 Luca Delucchi                              OSMit 2009
File XML: shape layer




<Layer name="coast-poly" status="on" srs="+proj=merc
+a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0
+y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over">
  <StyleName>coast-poly</StyleName>
  <Datasource>
   <Parameter name="type">shape</Parameter>
   <Parameter name="file">/path/al/file/</Parameter>
  </Datasource>
</Layer>




 Luca Delucchi                              OSMit 2009
File XML: point style

<Style name="amenity">
   <Rule>
  <Filter>[tourism]='viewpoint'</Filter>
     <PointSymbolizer file="/path/file" type="png"
      width="16" height="16" allow_overlap="true"/>
   </Rule>
</Style>

<Style name="amenity">
   <Rule>
  <Filter>[tourism]='viewpoint'</Filter>
     <PointSymbolizer width="16" height="16"
      opacity=”0.5” allow_overlap="true"/>
   </Rule>
</Style>

Luca Delucchi                             OSMit 2009
File XML: line style
<Style>
  <Rule>
      <Filter>[highway] = 'motorway'</Filter>
      <LineSymbolizer>
         <CssParameter name="stroke">
         #666666</CssParameter>
         <CssParameter name="stroke-width">
         5</CssParameter>
         <CssParameter name="stroke-dasharray">
         8 - 3</CssParameter>
         <CssParameter name="stroke-linejoin">
         round</CssParameter>
         <CssParameter name="stroke-opacity">
         0.7</CssParameter>
      </LineSymbolizer>
  </Rule>
</Style>

Luca Delucchi                          OSMit 2009
File XML: line style



<Style name="aerialways">
   <Rule>
      <Filter>[aerialway] = 'cable_car'</Filter>
      <LinePatternSymbolizer width="16" height="16"
      type="png" file="/path/to/icon.png"/>
   </Rule>
</Style>




Luca Delucchi                              OSMit 2009
File XML: polygon style
<Style name="world">
   <Rule>
      <Filter>[na2] = 'IT'</Filter>
      <PolygonSymbolizer>
         <CssParameter name="fill">white</CssParameter>
         <CssParameter name="fill-opacity">
         0.8</CssParameter>
      </PolygonSymbolizer>
   </Rule>
</Style>

<Style name="world">
   <Rule>
      <Filter>[na2] = 'IT'</Filter>
      <PolygonPatternSymbolizer width="16" height="16"
      type="png" file="/path/to/icon.png"/>
   </Rule>
</Style>

Luca Delucchi                              OSMit 2009
File XML: building style



<Style name=”building”>
   <BuildingSymbolizer>
     <CssParameter name="fill">#000000</CssParameter>
     <CssParameter name="fill-opacity">1</CssParameter>
     <CssParameter name="height">8</CssParameter>
   </BuildingSymbolizer>
</Style>




Luca Delucchi                              OSMit 2009
File XML: text & shield style
<Style name="autostrade_name">
  <Rule>
      <Filter>[highway] = 'motorway'</Filter>
      <ShieldSymbolizer name="ref" face_name="DejaVu
      Sans Bold" size="7" fill="#000000" placement="line"
      file="/path/file" type="png" width="17" height="17"
      spacing="100" min_distance="150"/>
  </Rule>
</Style>
<Style>
  <Rule>
    <Filter>[popolazione] &gt;= 100000</Filter>
    <TextSymbolizer name="toponimo" face_name=
  "DejaVu Sans Book" size="15" fill="#000000"
  halo_radius="2" allow_overlap="true"/>
  </Rule>
</Style>
Luca Delucchi                               OSMit 2009
File XML: scaledenom style


<Style name="autostrade_name">
  <Rule>
      <Filter>[highway] = 'motorway'</Filter>
      <MaxScaleDenominator>10000000
      </MaxScaleDenominator>
      <MinScaleDenominator>2000000
      </MinScaleDenominator>
      <ShieldSymbolizer name="ref" face_name="DejaVu
      Sans Bold" size="7" fill="#000000" placement="line"
      file="/path/file" type="png" width="17" height="17"
      spacing="100" min_distance="150"/>
  </Rule>
</Style>



Luca Delucchi                                 OSMit 2009
File XML: filter style

<Filter>[highway] = 'primary'</Filter>

<Filter>[popolazione] &gt;= 30000 and [popolazione] &lt;
100000</Filter>

<Filter>([highway] = 'primary' or [highway] = 'primary_link'
or [highway] = 'trunk' or [highway] = 'trunk_link') and not
([tunnel] = 'yes' or [tunnel] = 'true' or [tunnel] = '1')</Filter>




Luca Delucchi                                      OSMit 2009
File XML: raster style




<Style name="raster">
  <Rule>
      <RasterSymbolizer>
      </RasterSymbolizer>
  </Rule>
</Style>




Luca Delucchi                         OSMit 2009
This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 2.5 Italy License.
 To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/2.5/it/ or send a letter to
        Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.

 Luca Delucchi                                                                        OSMit 2009

Contenu connexe

Similaire à Osmit2009 Mapnik

State of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceState of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceOSCON Byrum
 
Microsoft Accademic Cloud Tour Genova
Microsoft Accademic Cloud Tour GenovaMicrosoft Accademic Cloud Tour Genova
Microsoft Accademic Cloud Tour Genovaantimo musone
 
Automating Your Workflow with Gulp.js - php[world] 2016
Automating Your Workflow with Gulp.js - php[world] 2016Automating Your Workflow with Gulp.js - php[world] 2016
Automating Your Workflow with Gulp.js - php[world] 2016Colin O'Dell
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)Oswald Campesato
 
Cloud Computing in Mobile
Cloud Computing in MobileCloud Computing in Mobile
Cloud Computing in MobileSVWB
 
Repaso rápido a los nuevos estándares web
Repaso rápido a los nuevos estándares webRepaso rápido a los nuevos estándares web
Repaso rápido a los nuevos estándares webPablo Garaizar
 
Simulation of urban mobility (sumo) prest
Simulation of urban mobility (sumo) prestSimulation of urban mobility (sumo) prest
Simulation of urban mobility (sumo) prestJaskaranpreet Singh
 
Deck: A Go Package for Presentations
Deck: A Go Package for PresentationsDeck: A Go Package for Presentations
Deck: A Go Package for PresentationsAnthony Starks
 
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Sadaaki HIRAI
 
WFS Tutorial OGC Interoperability Day - Toluca mexico - May 30 2013
WFS Tutorial   OGC Interoperability Day - Toluca mexico - May 30 2013WFS Tutorial   OGC Interoperability Day - Toluca mexico - May 30 2013
WFS Tutorial OGC Interoperability Day - Toluca mexico - May 30 2013Luis Bermudez
 
QConSP 2015 - Dicas de Performance para Aplicações Web
QConSP 2015 - Dicas de Performance para Aplicações WebQConSP 2015 - Dicas de Performance para Aplicações Web
QConSP 2015 - Dicas de Performance para Aplicações WebFabio Akita
 
ACM Bay Area Data Mining Workshop: Pattern, PMML, Hadoop
ACM Bay Area Data Mining Workshop: Pattern, PMML, HadoopACM Bay Area Data Mining Workshop: Pattern, PMML, Hadoop
ACM Bay Area Data Mining Workshop: Pattern, PMML, HadoopPaco Nathan
 
Getting Started with PostGIS geographic database - Lasma Sietinsone, EDINA
Getting Started with PostGIS geographic database - Lasma Sietinsone, EDINAGetting Started with PostGIS geographic database - Lasma Sietinsone, EDINA
Getting Started with PostGIS geographic database - Lasma Sietinsone, EDINAJISC GECO
 
[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
Large Scale Log Analytics with Solr: Presented by Rafał Kuć & Radu Gheorghe, ...
Large Scale Log Analytics with Solr: Presented by Rafał Kuć & Radu Gheorghe, ...Large Scale Log Analytics with Solr: Presented by Rafał Kuć & Radu Gheorghe, ...
Large Scale Log Analytics with Solr: Presented by Rafał Kuć & Radu Gheorghe, ...Lucidworks
 
Basic html5 and javascript
Basic html5 and javascriptBasic html5 and javascript
Basic html5 and javascriptwendy017
 

Similaire à Osmit2009 Mapnik (20)

02 create first-map
02 create first-map02 create first-map
02 create first-map
 
State of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceState of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open Source
 
Microsoft Accademic Cloud Tour Genova
Microsoft Accademic Cloud Tour GenovaMicrosoft Accademic Cloud Tour Genova
Microsoft Accademic Cloud Tour Genova
 
Automating Your Workflow with Gulp.js - php[world] 2016
Automating Your Workflow with Gulp.js - php[world] 2016Automating Your Workflow with Gulp.js - php[world] 2016
Automating Your Workflow with Gulp.js - php[world] 2016
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
 
Cloud Computing in Mobile
Cloud Computing in MobileCloud Computing in Mobile
Cloud Computing in Mobile
 
The Devil and HTML5
The Devil and HTML5The Devil and HTML5
The Devil and HTML5
 
Repaso rápido a los nuevos estándares web
Repaso rápido a los nuevos estándares webRepaso rápido a los nuevos estándares web
Repaso rápido a los nuevos estándares web
 
Simulation of urban mobility (sumo) prest
Simulation of urban mobility (sumo) prestSimulation of urban mobility (sumo) prest
Simulation of urban mobility (sumo) prest
 
Deck: A Go Package for Presentations
Deck: A Go Package for PresentationsDeck: A Go Package for Presentations
Deck: A Go Package for Presentations
 
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
 
WFS Tutorial OGC Interoperability Day - Toluca mexico - May 30 2013
WFS Tutorial   OGC Interoperability Day - Toluca mexico - May 30 2013WFS Tutorial   OGC Interoperability Day - Toluca mexico - May 30 2013
WFS Tutorial OGC Interoperability Day - Toluca mexico - May 30 2013
 
QConSP 2015 - Dicas de Performance para Aplicações Web
QConSP 2015 - Dicas de Performance para Aplicações WebQConSP 2015 - Dicas de Performance para Aplicações Web
QConSP 2015 - Dicas de Performance para Aplicações Web
 
ACM Bay Area Data Mining Workshop: Pattern, PMML, Hadoop
ACM Bay Area Data Mining Workshop: Pattern, PMML, HadoopACM Bay Area Data Mining Workshop: Pattern, PMML, Hadoop
ACM Bay Area Data Mining Workshop: Pattern, PMML, Hadoop
 
Getting Started with PostGIS geographic database - Lasma Sietinsone, EDINA
Getting Started with PostGIS geographic database - Lasma Sietinsone, EDINAGetting Started with PostGIS geographic database - Lasma Sietinsone, EDINA
Getting Started with PostGIS geographic database - Lasma Sietinsone, EDINA
 
Getting started with PostGIS geographic database
Getting started with PostGIS geographic databaseGetting started with PostGIS geographic database
Getting started with PostGIS geographic database
 
[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design
 
Large Scale Log Analytics with Solr: Presented by Rafał Kuć & Radu Gheorghe, ...
Large Scale Log Analytics with Solr: Presented by Rafał Kuć & Radu Gheorghe, ...Large Scale Log Analytics with Solr: Presented by Rafał Kuć & Radu Gheorghe, ...
Large Scale Log Analytics with Solr: Presented by Rafał Kuć & Radu Gheorghe, ...
 
Basic html5 and javascript
Basic html5 and javascriptBasic html5 and javascript
Basic html5 and javascript
 

Plus de luca delucchi

OpenStreetMap @ ITIS Pininfarina
OpenStreetMap @ ITIS PininfarinaOpenStreetMap @ ITIS Pininfarina
OpenStreetMap @ ITIS Pininfarinaluca delucchi
 
Sviluppo dei software GIS verso le tecnologie cloud e l’integrazione con disp...
Sviluppo dei software GIS verso le tecnologie cloud e l’integrazione con disp...Sviluppo dei software GIS verso le tecnologie cloud e l’integrazione con disp...
Sviluppo dei software GIS verso le tecnologie cloud e l’integrazione con disp...luca delucchi
 
Strumenti e azioni utili a raccogliere dati
Strumenti e azioni utili a raccogliere dati Strumenti e azioni utili a raccogliere dati
Strumenti e azioni utili a raccogliere dati luca delucchi
 
OpenStreetMap database e api
OpenStreetMap database e apiOpenStreetMap database e api
OpenStreetMap database e apiluca delucchi
 
OpenStreetMap android
OpenStreetMap androidOpenStreetMap android
OpenStreetMap androidluca delucchi
 
Humanitaria OpenStreetMap Team (HOT)
Humanitaria OpenStreetMap Team (HOT)Humanitaria OpenStreetMap Team (HOT)
Humanitaria OpenStreetMap Team (HOT)luca delucchi
 
ZOO WPS the integration with GRASS GIS
ZOO WPS the integration with GRASS GISZOO WPS the integration with GRASS GIS
ZOO WPS the integration with GRASS GISluca delucchi
 
Introduzione a OpenStreetMap
Introduzione a OpenStreetMapIntroduzione a OpenStreetMap
Introduzione a OpenStreetMapluca delucchi
 
Introduzione a OpenStreetMap (book version)
Introduzione a OpenStreetMap (book version)Introduzione a OpenStreetMap (book version)
Introduzione a OpenStreetMap (book version)luca delucchi
 

Plus de luca delucchi (19)

OpenStreetMap @ ITIS Pininfarina
OpenStreetMap @ ITIS PininfarinaOpenStreetMap @ ITIS Pininfarina
OpenStreetMap @ ITIS Pininfarina
 
Sviluppo dei software GIS verso le tecnologie cloud e l’integrazione con disp...
Sviluppo dei software GIS verso le tecnologie cloud e l’integrazione con disp...Sviluppo dei software GIS verso le tecnologie cloud e l’integrazione con disp...
Sviluppo dei software GIS verso le tecnologie cloud e l’integrazione con disp...
 
Strumenti e azioni utili a raccogliere dati
Strumenti e azioni utili a raccogliere dati Strumenti e azioni utili a raccogliere dati
Strumenti e azioni utili a raccogliere dati
 
OpenStreetMap database e api
OpenStreetMap database e apiOpenStreetMap database e api
OpenStreetMap database e api
 
OpenStreetMap android
OpenStreetMap androidOpenStreetMap android
OpenStreetMap android
 
Mappare genova
Mappare genovaMappare genova
Mappare genova
 
Humanitaria OpenStreetMap Team (HOT)
Humanitaria OpenStreetMap Team (HOT)Humanitaria OpenStreetMap Team (HOT)
Humanitaria OpenStreetMap Team (HOT)
 
Osm research
Osm researchOsm research
Osm research
 
Grass workshop2011
Grass workshop2011Grass workshop2011
Grass workshop2011
 
Grass cloud
Grass cloudGrass cloud
Grass cloud
 
ZOO WPS the integration with GRASS GIS
ZOO WPS the integration with GRASS GISZOO WPS the integration with GRASS GIS
ZOO WPS the integration with GRASS GIS
 
Introduzione a OpenStreetMap
Introduzione a OpenStreetMapIntroduzione a OpenStreetMap
Introduzione a OpenStreetMap
 
Introduzione a OpenStreetMap (book version)
Introduzione a OpenStreetMap (book version)Introduzione a OpenStreetMap (book version)
Introduzione a OpenStreetMap (book version)
 
Ld2010
Ld2010Ld2010
Ld2010
 
Linuxday2008 Osm
Linuxday2008 OsmLinuxday2008 Osm
Linuxday2008 Osm
 
Linuxday2008 Gis
Linuxday2008 GisLinuxday2008 Gis
Linuxday2008 Gis
 
Linuxday2009 OSM
Linuxday2009 OSMLinuxday2009 OSM
Linuxday2009 OSM
 
Bicitalia 2008
Bicitalia 2008Bicitalia 2008
Bicitalia 2008
 
OSMit2009 GFOSS.it
OSMit2009 GFOSS.itOSMit2009 GFOSS.it
OSMit2009 GFOSS.it
 

Dernier

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 

Dernier (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Osmit2009 Mapnik

  • 1. INTRODUZIONE A MAPNIK Luca Delucchi OSMit 2009
  • 2. Mapnik è un software libero per la rappresentazione di dati geografici Permette la realizzazione di immagini singole oppure di tile per la pubblicazione sul web Multipiattaforma Linux - Mac OS X - Windows Luca Delucchi OSMit 2009
  • 3. Scritto in C++ con python bindings che facilitano l'utilizzo Utilizza standard OGC, librerie GDAL/OGR, proj, agg e cairo Utilizza l'algoritmo di Painter per determinare l'ordine degli elementi Luca Delucchi OSMit 2009
  • 4. Utilizzo Script per il rendering: Regole per gli stili: - per le immagini - file XML - per le tile - python - c++ Luca Delucchi OSMit 2009
  • 5. Stampa: png #!/usr/bin/python from mapnik import * import cairo mapfile = "progetto.xml" map_output= 'prova_dim.png' m = Map(1192, 840) projection = '+proj=latlong +datum=WGS84' load_map(m, mapfile) bbox = Envelope(Coord(9.04311180114746, 45.7490234375), Coord(12.0447950363159, 47.1829261779785)) m.zoom_to_box(bbox) render_to_file(m, map_output, 'png') Luca Delucchi OSMit 2009
  • 6. Stampa: png #!/usr/bin/python from mapnik import * import cairo mapfile = 'progetto.xml' map_output = 'mapfile.pdf' projection = '+proj=latlong +datum=WGS84' m = Map(1192, 840) load_map(m, mapfile) bbox = Envelope(9.470383644104, 43.2393798828125, 12.4720678329468, 44.673282623291) mapnik_map.zoom_to_box(bbox) file = open(map_output, 'wb') surface = cairo.PDFSurface(file.name, m.width, m.height) render(m, surface) surface.finish() Luca Delucchi OSMit 2009
  • 7. File XML: map <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE Map> <Map bgcolor="#b5d0d0" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over"> ................................................................................................. ................................................................................................. ................................................................................................. </Map> Luca Delucchi OSMit 2009
  • 8. File XML: raster layer <Layer name="dem" status="on"> <StyleName>raster</StyleName> <Datasource> <Parameter name="type">gdal</Parameter> <Parameter name="file">/path/al/file/</Parameter> <Parameter name="format">tiff</Parameter> </Datasource> </Layer> <Datasource> <Parameter name="type">raster</Parameter> <Parameter name="file">/path/file.tiff</Parameter> <Parameter name="format">tiff</Parameter> <Parameter name="lox">5.0</Parameter> <Parameter name="loy">35.0</Parameter> <Parameter name="hix">20.0</Parameter> <Parameter name="hiy">50.0</Parameter> </Datasource> Luca Delucchi OSMit 2009
  • 9. File XML: postgis layer <Layer name="misc_boundaries" status="on" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over"> <StyleName>boundary</StyleName> <Datasource> <Parameter name="type">postgis</Parameter> <Parameter name="user">utente</Parameter> <Parameter name="dbname">italy</Parameter> <Parameter name="password">****</Parameter> <Parameter name="table">(select * from italy_line) as road </Parameter> <Parameter name="estimate_extent">...</Parameter> <Parameter name="extent">833337,5432307, 1119564,5572109</Parameter> </Datasource> </Layer> Luca Delucchi OSMit 2009
  • 10. File XML: shape layer <Layer name="coast-poly" status="on" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over"> <StyleName>coast-poly</StyleName> <Datasource> <Parameter name="type">shape</Parameter> <Parameter name="file">/path/al/file/</Parameter> </Datasource> </Layer> Luca Delucchi OSMit 2009
  • 11. File XML: point style <Style name="amenity"> <Rule> <Filter>[tourism]='viewpoint'</Filter> <PointSymbolizer file="/path/file" type="png" width="16" height="16" allow_overlap="true"/> </Rule> </Style> <Style name="amenity"> <Rule> <Filter>[tourism]='viewpoint'</Filter> <PointSymbolizer width="16" height="16" opacity=”0.5” allow_overlap="true"/> </Rule> </Style> Luca Delucchi OSMit 2009
  • 12. File XML: line style <Style> <Rule> <Filter>[highway] = 'motorway'</Filter> <LineSymbolizer> <CssParameter name="stroke"> #666666</CssParameter> <CssParameter name="stroke-width"> 5</CssParameter> <CssParameter name="stroke-dasharray"> 8 - 3</CssParameter> <CssParameter name="stroke-linejoin"> round</CssParameter> <CssParameter name="stroke-opacity"> 0.7</CssParameter> </LineSymbolizer> </Rule> </Style> Luca Delucchi OSMit 2009
  • 13. File XML: line style <Style name="aerialways"> <Rule> <Filter>[aerialway] = 'cable_car'</Filter> <LinePatternSymbolizer width="16" height="16" type="png" file="/path/to/icon.png"/> </Rule> </Style> Luca Delucchi OSMit 2009
  • 14. File XML: polygon style <Style name="world"> <Rule> <Filter>[na2] = 'IT'</Filter> <PolygonSymbolizer> <CssParameter name="fill">white</CssParameter> <CssParameter name="fill-opacity"> 0.8</CssParameter> </PolygonSymbolizer> </Rule> </Style> <Style name="world"> <Rule> <Filter>[na2] = 'IT'</Filter> <PolygonPatternSymbolizer width="16" height="16" type="png" file="/path/to/icon.png"/> </Rule> </Style> Luca Delucchi OSMit 2009
  • 15. File XML: building style <Style name=”building”> <BuildingSymbolizer> <CssParameter name="fill">#000000</CssParameter> <CssParameter name="fill-opacity">1</CssParameter> <CssParameter name="height">8</CssParameter> </BuildingSymbolizer> </Style> Luca Delucchi OSMit 2009
  • 16. File XML: text & shield style <Style name="autostrade_name"> <Rule> <Filter>[highway] = 'motorway'</Filter> <ShieldSymbolizer name="ref" face_name="DejaVu Sans Bold" size="7" fill="#000000" placement="line" file="/path/file" type="png" width="17" height="17" spacing="100" min_distance="150"/> </Rule> </Style> <Style> <Rule> <Filter>[popolazione] &gt;= 100000</Filter> <TextSymbolizer name="toponimo" face_name= "DejaVu Sans Book" size="15" fill="#000000" halo_radius="2" allow_overlap="true"/> </Rule> </Style> Luca Delucchi OSMit 2009
  • 17. File XML: scaledenom style <Style name="autostrade_name"> <Rule> <Filter>[highway] = 'motorway'</Filter> <MaxScaleDenominator>10000000 </MaxScaleDenominator> <MinScaleDenominator>2000000 </MinScaleDenominator> <ShieldSymbolizer name="ref" face_name="DejaVu Sans Bold" size="7" fill="#000000" placement="line" file="/path/file" type="png" width="17" height="17" spacing="100" min_distance="150"/> </Rule> </Style> Luca Delucchi OSMit 2009
  • 18. File XML: filter style <Filter>[highway] = 'primary'</Filter> <Filter>[popolazione] &gt;= 30000 and [popolazione] &lt; 100000</Filter> <Filter>([highway] = 'primary' or [highway] = 'primary_link' or [highway] = 'trunk' or [highway] = 'trunk_link') and not ([tunnel] = 'yes' or [tunnel] = 'true' or [tunnel] = '1')</Filter> Luca Delucchi OSMit 2009
  • 19. File XML: raster style <Style name="raster"> <Rule> <RasterSymbolizer> </RasterSymbolizer> </Rule> </Style> Luca Delucchi OSMit 2009
  • 20. This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 2.5 Italy License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/2.5/it/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. Luca Delucchi OSMit 2009