Skip to content

Instantly share code, notes, and snippets.

@danicarrion
Created November 17, 2020 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danicarrion/89c0db2802c3dcf7841f38d357337e85 to your computer and use it in GitHub Desktop.
Save danicarrion/89c0db2802c3dcf7841f38d357337e85 to your computer and use it in GitHub Desktop.
Ejemplo python-mapnik
FROM ubuntu:20.04
RUN apt-get update -y && apt-get install -y apt-utils
RUN apt-get install -y python3-mapnik
WORKDIR /app
COPY . .
<Map background-color="blue" srs="+init=epsg:4326">
<Style name="My Style">
<Rule>
<PolygonSymbolizer fill="#f2eff9" />
<LineSymbolizer stroke="rgb(50%,50%,50%)" stroke-width="0.1" />
</Rule>
</Style>
<Layer name="world" srs="+init=epsg:4326">
<StyleName>My Style</StyleName>
<Datasource>
<Parameter name="type">postgis</Parameter>
<Parameter name="host">172.17.0.1</Parameter>
<Parameter name="dbname">curso</Parameter>
<Parameter name="user">curso</Parameter>
<Parameter name="password">curso</Parameter>
<Parameter name="table">(select geom from countries) as "table"</Parameter>
</Datasource>
</Layer>
</Map>
import mapnik
m = mapnik.Map(1024, 1024)
mapnik.load_map(m, "map.xml")
m.zoom_all()
mapnik.render_to_file(m, "map.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment