diff --git a/.gitignore b/.gitignore index 05d9664..cd1113a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # sphinx build folder -_build +build # Compiled source # ################### @@ -21,7 +21,7 @@ _build *.jar *.rar *.tar -*.zip +#*.zip # Logs and databases # ###################### @@ -39,3 +39,4 @@ Thumbs.db # Editor backup files # ####################### *~ + diff --git a/Makefile b/Makefile index a8a3d81..c7ea047 100644 --- a/Makefile +++ b/Makefile @@ -3,14 +3,16 @@ # You can set these variables from the command line. SPHINXOPTS = -SPHINXBUILD = sphinx-build +SPHINXBUILD = sphinx-build# -W PAPER = -BUILDDIR = _build +BUILDDIR = build +TRANSLATIONS = fr +LANGUAGES = en $(TRANSLATIONS) # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees/$$lang $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) -c . -A language=$$lang -D language=$$lang -A target=$(TARGET) -A languages='$(LANGUAGES)' .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest @@ -34,97 +36,151 @@ help: @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: - -rm -rf $(BUILDDIR)/* + -rm -rf build/* + +init: + @for lang in $(TRANSLATIONS) ;\ + do \ +# We change the Internal Field Separator (IFS) because to handle filename with special char like space. \ + OLDIFS="$$IFS"; \ + IFS=$$'\n'; \ + for file in `cd en; find . -type f -a -regex '.*\.txt$$' -a -not -regex '.*\.svn.*' -printf "%p\n" ; cd ..;`; \ + do \ + if [ ! -f $$lang/$$file ]; then \ + mkdir -p `dirname "$$lang/$$file"`; \ + (echo ".. meta::"; echo " :ROBOTS: NOINDEX") | cat - "en/$$file" > "$$lang/$$file"; \ + fi \ + done; \ + IFS=$$OLDIFS; \ +# Copy all no .txt files \ + yes n | cp -ipR en/* $$lang &> /dev/null; \ + done + @echo "Init finished. Other target can now be build.";\ html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @for lang in $(LANGUAGES);\ + do \ + mkdir -p $(BUILDDIR)/html/$$lang $(BUILDDIR)/doctrees/$$lang; \ + echo "$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $$lang $(BUILDDIR)/html/$$lang";\ + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $$lang $(BUILDDIR)/html/$$lang;\ + done @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html/.";\ singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @for lang in $(LANGUAGES);\ + do \ + mkdir -p $(BUILDDIR)/singlehtml/$$lang $(BUILDDIR)/doctrees/$$lang; \ + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $$lang $(BUILDDIR)/singlehtml/$$lang;\ + done @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + @echo "Build finished. The HTML pages are in $(BUILDDIR)/singlehtml/.";\ pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @for lang in $(LANGUAGES);\ + do \ + mkdir -p $(BUILDDIR)/pickle/$$lang $(BUILDDIR)/doctrees/$$lang; \ + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $$lang $(BUILDDIR)/pickle/$$lang;\ + done @echo @echo "Build finished; now you can process the pickle files." +web: pickle + json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @for lang in $(LANGUAGES);\ + do \ + mkdir -p $(BUILDDIR)/json/$$lang $(BUILDDIR)/doctrees/$$lang; \ + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $$lang $(BUILDDIR)/json/$$lang;\ + done @echo @echo "Build finished; now you can process the JSON files." htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @for lang in $(LANGUAGES);\ + do \ + mkdir -p $(BUILDDIR)/htmlhelp/$$lang $(BUILDDIR)/doctrees/$$lang; \ + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $$lang $(BUILDDIR)/htmlhelp/$$lang;\ + done @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Mapnik.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Mapnik.qhc" - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/Mapnik" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Mapnik" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + ".hhp project file in $(BUILDDIR)/htmlhelp/." latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @for lang in $(LANGUAGES);\ + do \ + mkdir -p $(BUILDDIR)/latex/$$lang $(BUILDDIR)/doctrees/$$lang; \ + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $$lang $(BUILDDIR)/latex/$$lang;\ + done @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - make -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex/."\ + @echo "Run \`make all-pdf' or \`make all-ps'" + +pdf: + @for lang in $(LANGUAGES);\ + do \ + mkdir -p $(BUILDDIR)/pdf/$$lang $(BUILDDIR)/doctrees/$$lang; \ + $(SPHINXBUILD) -b pdf $(ALLSPHINXOPTS) $$lang $(BUILDDIR)/pdf/$$lang;\ + done @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." + @echo "Build finished; the PDF files are in $(BUILDDIR)/pdf/."\ + @echo "Run \`make pdf' " -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man +epub: + @for lang in en;\ + do \ + mkdir -p $(BUILDDIR)/epub/$$lang $(BUILDDIR)/doctrees/$$lang; \ + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $$lang $(BUILDDIR)/epub/$$lang;\ + done @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + @echo "Build finished; the epub files are in $(BUILDDIR)/epub/."\ + @echo "Run \`make epub' " + +all-pdf: + @for lang in $(LANGUAGES);\ + do \ + /usr/bin/make -C $(BUILDDIR)/latex/$$lang all-pdf ; \ + if [ -d $(BUILDDIR)/html/$$lang ]; then \ + mv -f $(BUILDDIR)/latex/$$lang/Mapnik.pdf $(BUILDDIR)/html/$$lang ; \ + fi \ + done + +all-ps: + @for lang in $(LANGUAGES);\ + do \ + /usr/bin/make -C $(BUILDDIR)/latex/$$lang all-ps ; \ + if [ -d $(BUILDDIR)/html/$$lang ]; then \ + mv -f $(BUILDDIR)/latex/$$lang/Mapnik.pdf $(BUILDDIR)/html/$$lang ; \ + fi \ + done changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @for lang in $(LANGUAGES);\ + do \ + mkdir -p $(BUILDDIR)/changes/$$lang $(BUILDDIR)/doctrees/$$lang; \ + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $$lang $(BUILDDIR)/changes/$$lang;\ + done @echo - @echo "The overview file is in $(BUILDDIR)/changes." + @echo "The overview file is in $(BUILDDIR)/changes/." linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @for lang in $(LANGUAGES);\ + do \ + mkdir -p $(BUILDDIR)/linkcheck/$$lang $(BUILDDIR)/doctrees/$$lang; \ + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $$lang $(BUILDDIR)/linkcheck/$$lang;\ + done @echo @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." + "or in $(BUILDDIR)/linkcheck//output.txt." + +labels: + @for lang in $(LANGUAGES);\ + do \ + mkdir -p $(BUILDDIR)/labels/$$lang $(BUILDDIR)/doctrees/$$lang; \ + $(SPHINXBUILD) -b labels $(ALLSPHINXOPTS) $$lang $(BUILDDIR)/labels/$$lang;\ + cp $(BUILDDIR)/labels/$$lang/labels.txt $$lang/include/labels.inc;\ + done + @echo + @echo "Label generation complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/labels//labels.txt." -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." diff --git a/_files/110m-admin-0-countries.zip b/_files/110m-admin-0-countries.zip new file mode 100644 index 0000000..c8c08f5 Binary files /dev/null and b/_files/110m-admin-0-countries.zip differ diff --git a/_files/hello_world.zip b/_files/hello_world.zip new file mode 100644 index 0000000..411d958 --- /dev/null +++ b/_files/hello_world.zip @@ -0,0 +1,131 @@ + + + + + + + + + + + + + Attachment – + Mapnik Wiki & Documentation – Trac + + + + + + + +
+ +
+

XMLGettingStarted: hello_world.zip

+ + + + + + + + + +
+ File hello_world.zip, 9.6 kB + (added by springmeyer, 3 years ago) +
+

+Tutorial for Hello World Mapnik examples using pure python and XML config file +

+ +
+
+

+ HTML preview not available, + since no preview renderer could handle it. + Try downloading the file instead. +

+
+
+ +
+ + + + + + + + \ No newline at end of file diff --git a/_files/world_borders.zip b/_files/world_borders.zip new file mode 100644 index 0000000..b3baa9e --- /dev/null +++ b/_files/world_borders.zip @@ -0,0 +1,128 @@ + + + + + + + + + + + + + Attachment – + Mapnik Wiki & Documentation – Trac + + + + + + + +
+ +
+

XMLGettingStarted: world_borders.zip

+ + + + + + + + + +
+ File world_borders.zip, 294.9 kB + (added by springmeyer, 14 months ago) +
+ +
+
+

+ HTML preview not available, + since the file size exceeds 262144 bytes. + Try downloading the file instead. +

+
+
+ +
+ + + + + + + + \ No newline at end of file diff --git a/_images/world.png b/_images/world.png new file mode 100644 index 0000000..c4d9291 Binary files /dev/null and b/_images/world.png differ diff --git a/_images/world_population.png b/_images/world_population.png new file mode 100644 index 0000000..5dd1681 Binary files /dev/null and b/_images/world_population.png differ diff --git a/_images/world_population_minimized.png b/_images/world_population_minimized.png new file mode 100644 index 0000000..9393017 Binary files /dev/null and b/_images/world_population_minimized.png differ diff --git a/_static/default.css b/_static/default.css index 3ed8d31..edec059 100644 --- a/_static/default.css +++ b/_static/default.css @@ -543,3 +543,8 @@ ul.keywordmatches li.goodmatch a { font-weight: bold; } +/* Overloading css property from pygments.css */ +.highlight { + background: none repeat scroll 0 0 #FBF8F5 !important; +} + diff --git a/_static/mapnik.ico b/_static/mapnik.ico new file mode 100644 index 0000000..bafb93a Binary files /dev/null and b/_static/mapnik.ico differ diff --git a/about_mapnik.rst b/about_mapnik.rst deleted file mode 100644 index e06a994..0000000 --- a/about_mapnik.rst +++ /dev/null @@ -1,101 +0,0 @@ - -****** -Mapnik -****** - -Mapnik is about making beautiful maps. It uses the `AGG library -`_ or `Cairo library -`_ and offers world class anti-aliasing -rendering with subpixel accuracy for geographic data. It is written -from scratch in modern C++ and doesn't suffer from design decisions -made a decade ago. When it comes to handling common software tasks -such as memory management, filesystem access, regular expressions, -parsing and so on, Mapnik doesn't re-invent the wheel, but utilizes -best of breed industry standard libraries from http://boost.org. - - - -History -======= - -Mapnik was started in a warm June afternoon in 2005 by Artem -Pavlenko. First version was released in ... - -Current version is 0.7.1 available for download at -http://mapnik.org/download/. - - -Community -========= - -Mapnik community is organized around main site http://mapnik.org and -development site http://trac.mapnik.org on which you can find latest -news about Mapnik and its development. Development site is organized -like a wiki which contains a lot of useful information, and you can -freely contribute if you `sign up `_. - -Also you can ask questions on mailing lists `mapnik-users -`_ and if you -want to help developing Mapnik check out `mapnik-devel -`_. On this -links you will also find mailing list archive, which you should check -before asking your question. You can follow mailing lists on `Nabble -`_. - -If you like more direct communication you can find us on **#mapnik** at -irc.freenode.net, feel free to drop in with your question anytime. - -Platforms -========= - -Mapnik is a cross platform toolkit that runs on Windows, Mac, and -Linux (since release 0.4). Users commonly run Mapnik on Mac >=10.4.x -(both intel and PPC), as well as Debian/Ubuntu, Fedora, Centos, -OpenSuse, and FreeBSD. - -Supported data formats -====================== - -Mapnik uses a plugin architecture to read different -datasources. Current plugins which are considered stable, and built by -default, are: - -* *shape* - support for accessing `ESRI Shape - `_ files -* *postgis* - support for accessing geospatial data through `PostGIS - `_, the spatial database - extension for `PostgreSQL - `_ -* *raster* - stripped or tiled raster TIFF image dataset support - -Other plugins are not unstable but as they were added later in -development and there could still be some issues: - -* *gdal* - support for `GDAL `_ - datasets -* *ogr* - support for `OGR - `_ datasets -* *osm* - support reading `OpenStreetMap - `_ XML dataset -* *sqlite* - support for `SQLite - `_ / `Spatialite - `_ sql vector format -* *occi* - support for `oracle spatial - `_ 10g (versions - 10.2.0.x) sql vector format -* *kismet* - support for `kismet `_ - GPS support shows little WLAN nodes on the map -* *rasterlite* - support for `Rasterlite - `_ sqlite raster with wavelet - compression - -More data access plug-ins will be available in the future. If you -cannot wait and/or like coding in C++, why not write your own data -access plug-in? - -Future -====== - -Large number of developers and contributors are actively developing -*mapnik2* which will become **0.8.0**. Also, version **0.7.2** is -scheduled to be released shortly. diff --git a/conf.py b/conf.py index f93fde7..aa9297d 100644 --- a/conf.py +++ b/conf.py @@ -25,7 +25,7 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', 'sphinx.ext.ifconfig'] +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', 'sphinx.ext.ifconfig', 'sphinx.ext.extlinks'] # 'sphinx.ext.coverage' # fancy extensions we don't need now... @@ -260,3 +260,9 @@ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = {'http://docs.python.org/': None} + +# -- Options for sphinx.ext.extlinks – Markup to shorten external links --------------------------------------------------- + +extlinks = {'source': ('http://trac.mapnik.org/browser/%s', + 'Source ')} + diff --git a/en/GettingStarted-1.rst b/en/GettingStarted-1.rst new file mode 100644 index 0000000..8a84a91 --- /dev/null +++ b/en/GettingStarted-1.rst @@ -0,0 +1,308 @@ +******************************************************************************* +Tutorial 1 -- 'Hello,world!' in Python +******************************************************************************* + +Overview +-------- + +This tutorial will ensure that Mapnik and its python bindings are +properly installed and introduce you to some of the basic +programming concepts for Mapnik. + +Step 1: check installation +-------------------------- + +Make sure you have mapnik installed. You should be able to open a +terminal and type: + +.. sourcecode:: bash + + mapnik-config -v # should return a version number. + +This tutorial expects Mapnik 2.x or greater. Older versions do not +provide the ``mapnik-config`` program, so we recommend upgrading. + +Next test the python bindings. You should be able to open a +terminal and type: + +.. sourcecode:: bash + + python -c "import mapnik;print mapnik.__file__" # should return the path to the python bindings and no errors + +If the above does not work (e.g. throws an ``ImportError``) then +please go back and ensure Mapnik is properly +`installed `_. If you need help, sign up for +the `mailing list `_ to ask questions +or join the +`#mapnik room on freenode IRC `_ + +Step 2 +------ + +Now, we need some data to render. Let's use a shapefile of world +border polygons from http://naturalearthdata.com. Download the data +from this wiki's local cache +:download:`here <../_files/110m-admin-0-countries.zip>` or directly from the +`Natural Earth Data site `_. +Unzip the archive in an easily accessible location of your +choosing. In *Step 3* we will be referencing the path to this +shapefile in python code, so make sure you know where you put it. + +Once unzipped, you should see four files like: + +.. sourcecode:: bash + + ne_110m_admin_0_countries.shp + ne_110m_admin_0_countries.shx + ne_110m_admin_0_countries.dbf + ne_110m_admin_0_countries.prj + +To download and unzip on the command line with the do: + +.. sourcecode:: bash + + wget https://github.com/mapnik/mapnik/wiki/data/110m-admin-0-countries.zip + unzip 110m-admin-0-countries.zip # creates ne_110m_admin_0_countries.shp + +Step 3 +------ + +Now we're going to program in Python and Mapnik, using sample code +and the python interpreter. + +The idea here is not that you have to interact with Mapnik via +Python, but that this is a good way to build foundational skills +for how Mapnik works. + +So, let's begin! Open a python interpreter simply by typing in your +terminal: + +.. sourcecode:: python + + python + +The code below can be pasted into your interpreter. Ideally paste +line by line so you can confirm each step is working. The commented +lines (#) should be able to be pasted without trouble, but +depending on your interpreter setting may cause errors. + +Import Mapnik +~~~~~~~~~~~~~ + +Import the Mapnik python bindings: + +.. sourcecode:: python + + import mapnik + +Create a Map +~~~~~~~~~~~~ + +``python m = mapnik.Map(600,300) # create a map with a given width and height in pixels # note: m.srs will default to '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' # the 'map.srs' is the target projection of the map and can be whatever you wish m.background = mapnik.Color('steelblue') # set background colour to 'steelblue'.`` + +Create a Style +~~~~~~~~~~~~~~ + +Create the Styles which determines how the data is rendered: + +.. sourcecode:: python + + s = mapnik.Style() # style object to hold rules + r = mapnik.Rule() # rule object to hold symbolizers + # to fill a polygon we create a PolygonSymbolizer + polygon_symbolizer = mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9')) + r.symbols.append(polygon_symbolizer) # add the symbolizer to the rule object + # to add outlines to a polygon we create a LineSymbolizer + line_symbolizer = mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'),0.1) + r.symbols.append(line_symbolizer) # add the symbolizer to the rule object + s.rules.append(r) # now add the rule to the style and we're done + +And add the Style to the Map: + +.. sourcecode:: python + + m.append_style('My Style',s) # Styles are given names only as they are applied to the map + +Create a Datasource +~~~~~~~~~~~~~~~~~~~ + +In *Step 2* above you should have downloaded a sample shapefile of +polygons of world countries. We are now going to load that into a +``mapnik.Datasource`` object in python. + +If your python interpreter was launched from the same directory as +you downloaded the natural earth shapefile to you should be able to +use a relative path to create the datasource like: + +:: + + ds = mapnik.Shapefile(file='ne_110m_admin_0_countries.shp') + +Otherwise use an absolute path (exchanging +``/Users/dane/Downloads/`` for the correct path on your machine): + +.. sourcecode:: python + + ds = mapnik.Shapefile(file='/Users/dane/Downloads/ne_110m_admin_0_countries.shp') + +Note: optionally (to learn about your data) you can call the +``envelope()`` function off the datasource object to see the full +coordinate bounds of the data: + +.. sourcecode:: python + + >>> ds.envelope() + Box2d(-180.0,-90.0,180.0,83.64513) + +That shows the minx, miny, maxx, and maxy of the data. Because the +above coordinates are between -180 and 180 for the x or longitude +values and -90 and 90 for the y or latitude values we know this +data is in *geographic* coordinates and uses degrees for units - a +pretty good indication this is ``WGS84 (aka EPSG:4326)``. This +specific shapefile also stores this projection information as a +``WKT`` string in the ``ne_110m_admin_0_countries.prj`` file. But +Mapnik need to know this specific, common spatial references system +by its `Proj.4 `_ string of +``+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs``. See the +``layer.srs`` value below for why this matters. + +Create a Layer +~~~~~~~~~~~~~~ + +Mapnik Layers are basically containers around datasources, that +store useful properties. + +So, lets now create a Layer object and add the datasource to it. + +.. sourcecode:: python + + layer = mapnik.Layer('world') # new layer called 'world' (we could name it anything) + # note: layer.srs will default to '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' + +Note: the 'layer.srs' is the source projection of the Datasource +and *must* match the projection of the coordinates of that data or +else your map will likely be blank. In this case, the default +``srs`` Mapnik assumes happens to also match the projection of the +data. When this is not the case you need to set the layer.srs to +the correct value (which is beyond the scope of this tutorial). + +Now attach the datasource to the layer, and reference: + +.. sourcecode:: python + + layer.datasource = ds + +Lastly, we need to make sure the style we created above (and +attached to the map) is also applied to the layer, by its string +reference: + +.. sourcecode:: python + + layer.styles.append('My Style') + +Prepare the Map for rendering +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This step is critical. Finally add the layer to the map and zoom to +the full extent of the data layer (using ``zoom_all`` which will +calculate the cumulative extent of all layers attached to the map). +If you do not zoom the Map to the extent of the layer(s), then the +rendered output will be blank. + +.. sourcecode:: python + + m.layers.append(layer) + m.zoom_all() + +Render your map +~~~~~~~~~~~~~~~ + +Finish up by rendering your map image: + +.. sourcecode:: python + + # Write the data to a png image called world.png the current directory + mapnik.render_to_file(m,'world.png', 'png') + + # Exit the python interpreter + exit() # or ctrl-d + +Then back in your normal shell type: + +.. sourcecode:: bash + + # On a mac + open world.png + # On windows + start world.png + +Or navigate to your base directory and open ``world.png`` and the +result should look like this: ![world.png] + +Step 4 +~~~~~~ + +The next logical step is to run that same code all at once as a +python script from your shell/terminal (rather than pasted into the +python interpreter line-by-line). This way you will be able to +modify and experiment with the settings, then simply re-run the +script. + +So, create a blank text file called ``world.py``. + +Make it executable: + +.. sourcecode:: bash + + chmod +x world.py + +Then add a line at the top of the script like: + +.. sourcecode:: bash + + #!/usr/bin/env python + +Finally, append the entire text below and save the file. + +.. sourcecode:: python + + import mapnik + m = mapnik.Map(600,300) + m.background = mapnik.Color('steelblue') + s = mapnik.Style() + r = mapnik.Rule() + polygon_symbolizer = mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9')) + r.symbols.append(polygon_symbolizer) + line_symbolizer = mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'),0.1) + r.symbols.append(line_symbolizer) + s.rules.append(r) + m.append_style('My Style',s) + ds = mapnik.Shapefile(file='ne_110m_admin_0_countries.shp') + layer = mapnik.Layer('world') + layer.datasource = ds + layer.styles.append('My Style') + m.layers.append(layer) + m.zoom_all() + mapnik.render_to_file(m,'world.png', 'png') + print "rendered image to 'world.png'" + + +- Don't forget to ensure the correct path to your + ``ne_110m_admin_0_countries.shp`` shapefile. +- Mapnik accepts both the absolute path to your data as well as + the relative path (Same goes for the path to where you want to save + your file) + +Finally run the script with the command: + +.. sourcecode:: bash + + ./world.py # You must be in the same directory as you saved the script + + +- Note: if you re-run this script it will will re-write over the + world.png map. +- Now you can easily open the script in a separate text editor and + try changing the dimensions, colors, or datasource (remember to use + the correct ``srs`` if you change the datasource). + diff --git a/en/XMLGettingStarted.rst b/en/XMLGettingStarted.rst new file mode 100644 index 0000000..d15cff9 --- /dev/null +++ b/en/XMLGettingStarted.rst @@ -0,0 +1,284 @@ +***************************************************** +Tutorial 2 -- 'Hello,world!' using XML configuration +***************************************************** + +Overview +-------- + +Make sure you have mapnik installed and you've successfully run through +:doc:`GettingStarted Tutorial 1 `. + +* This page will guide you through using the Mapnik python bindings along with + a separate XML file for your map styles. + +* This is a useful approach to manage your map styles/rules separately from + your python code, and can be advantageous for very complex formatting. + Therefore, an XML configuration is used by the Open Street Map project to do + intense filtering of PostGIS data by attribute. + + +Two examples will be shown: + +1) An XML configuration that exactly matches the map output from the pure python +example in :doc:`The Getting Started Tutorial 1 `. + + +* This is intended to help new users see the common usage of Mapnik style and + rule parameters. + +* Note: These samples are intentionally sparse and do not take full advantage + of Mapnik capabilities. + + * See the :source:`rundemo.py ` script in the + downloads for more advanced usage of python bindings. + + * See the :source:`OSM XML example ` + in the tests folder for more advanced usage of XML. + + +2) An XML configuration that uses a world borders dataset with population +attributes to create a chloropleth map by population size. This is intended to +introduce the uses of rule filters and labeling in XML + +Note: the code for example 1, along with the code from :doc:`GettingStarted +Tutorial 1 ` can be downloaded in a zip bundle from a link +below. These downloads contain relative paths to a data folder where you +should place the world_borders.shp. + +Etape 1 +------- + +**Hello World XML** + +First you will still need a python script that sets the basic map parameters +and points to the XML config file: + +.. sourcecode:: python + + #!/usr/bin/env python + import mapnik mapfile = 'world_styles.xml' + map_output = 'hello_world_using_xml_config.png' + m = mapnik.Map(600, 300) + mapnik.load_map(m, mapfile) + bbox = mapnik.Envelope(mapnik.Coord(-180.0, -90.0), mapnik.Coord(180.0, 90.0)) + m.zoom_to_box(bbox) + mapnik.render_to_file(m, map_output) + +* Copy this code and save to a file called **world_map.py** + +Next you will need to create the **world_styles.xml** file referenced in the +**world_map.py** + +Note: you will need to specify the path to the same Mapping Hacks +`world borders shapefile `_ +using in Tutorial 1 + +.. sourcecode:: xml + + + + + + + My + Style + + shape + /path/to/your/world_borders + + + + + +* Copy this XML and save to a file called **world_styles.xml** beside the + **world_map.py** script + +Now run that script with this command: + +.. sourcecode:: bash + + python world_map.py + +* It should output a png graphic in the same folder that matches the Getting + Started Tutorial. + + + +Etape 2 +------- + +**World Population XML** + +Attached below and included as code samples, here is a sample python script that +accesses a **population.xml map configuration.** + +Note: you will need to download the `modified world borders shapefile +`_. + +* Note: This file is originally from `Thematic Mapping Blog + `_. The version + attached here is the simpler shapefile provided there with some modification + made to avoid problems that occur when displaying the map in projections such + as 900913/3785 (this tutorial does not use this projection so you can use the + original shapefiles as well). See `ticket 308 + `_ for details. + +This script should result in a graphic like this: + + +.. _worldpop: +.. figure:: ../_images/world_population_minimized.png + + +.. sourcecode:: python + + #!/usr/bin/env python + + import mapnik mapfile = "population.xml" + m = mapnik.Map(1400, 600) + mapnik.load_map(m, mapfile) + bbox = mapnik.Envelope(mapnik.Coord(-180.0, -75.0), mapnik.Coord(180.0, 90.0)) + m.zoom_to_box(bbox) + mapnik.render_to_file(m, 'world_population.png', 'png') + +And here is the xml file: + +.. sourcecode:: xml + + + + + + + + + + + population + countries_label + + shape + + + /PATH/TO/THE/TM_WORLD_BORDERS_SIMPL-0.3 + + + + +Attached files + +:download:`hello_world.zip <../_files/hello_world.zip>` - Tutorial for Hello World Mapnik examples using pure python and XML config file. + +:download:`world_population.png <../_images/world_population.png>` Map graphic output of Step 2 using XML configuration to display chloropleth map of world population. + +:download:`world_population_minimized.png <../_images/world_population_minimized.png>` - Minimized version of the output of Step 2 for trac display. + +:download:`world_borders.zip <../_files/world_borders.zip>`. + diff --git a/en/about_mapnik.rst b/en/about_mapnik.rst new file mode 100644 index 0000000..7bfac67 --- /dev/null +++ b/en/about_mapnik.rst @@ -0,0 +1,77 @@ + +****** +Mapnik +****** + +Mapnik is a Free Toolkit for developing mapping applications. +It’s written in C++ and there are Python bindings to facilitate +fast-paced agile development. It can comfortably be used for both +desktop and web development, which was something I wanted from the +beginning. + +Mapnik is about making beautiful maps. It uses the AGG library and +offers world class anti-aliasing rendering with subpixel accuracy for +geographic data. It is written from scratch in modern C++ and doesn’t +suffer from design decisions made a decade ago. When it comes to +handling common software tasks such as memory management, filesystem +access, regular expressions, parsing and so on, Mapnik doesn’t +re-invent the wheel, but utilizes best of breed industry standard +libraries from boost.org + + +History +======= + +Mapnik was started in a warm June afternoon in 2005 by Artem +Pavlenko. An overview of global project advancement can be visualize +reading Mapnik project `closed milestones `_ + +Previous main version was 0.7.1. You can generate the outdated docs +with Sphinx retrieving `the package `_. +Current version is Mapnik 2.0.2. available for download at http://mapnik.org/download/. + + +Community +========= + +Mapnik community is organized around main site http://mapnik.org and +development site https://github.com/mapnik/mapnik/ on which you can find latest +news about Mapnik and its development. Development site is organized +like a wiki which contains a lot of useful information, and you can +freely contribute if you `sign in `_ to Github. + +Both users and developers can ask questions on Google group `mapnik `_ +Users and developers mailing list were hosted at `Berlios `_ from Feb. 2006 to Nov. 2011 +Before asking questions, you can search old archives using `Nabble `_ +or directly into the Google group for recents topics. + +If you like more direct communication you can find us on **#mapnik** at +irc.freenode.net, feel free to drop in with your question anytime. + +Platforms +========= + +Mapnik is a cross platform toolkit that runs on Windows, Mac, and +Linux (since release 0.4). Users commonly run Mapnik on Mac >=10.4.x +(both intel and PPC), as well as Debian/Ubuntu, Fedora, Centos, +OpenSuse, and FreeBSD. + +Supported data formats +====================== + +Mapnik uses a plugin architecture to read different +datasources. Current plugins can read ESRI shapefiles, PostGIS, TIFF +raster, OSM xml, Kismet, as well as all OGR/GDAL formats. More data +access plug-ins will be available in the future. If you cannot wait +and/or like coding in C++, why not write your own data access plug-in? + +Future +====== + +As always, there are lots of things in the pipeline. +Large number of developers and contributors are actively developing +*mapnik 2.1.x* series. +Look on the page `Future features of Mapnik `_ +and sign up for the `mapnik list `_ +to join the community discussion. You can also follow `Mapnik news +`_ to get latest hot features in the pipe. diff --git a/documentation_guidelines.rst b/en/documentation_guidelines.rst similarity index 100% rename from documentation_guidelines.rst rename to en/documentation_guidelines.rst diff --git a/en/getting_started.rst b/en/getting_started.rst new file mode 100644 index 0000000..410b2cd --- /dev/null +++ b/en/getting_started.rst @@ -0,0 +1,168 @@ +*************** +Getting Started +*************** + +After reading this document you should be able to create a simple +rendered map using Python or C++. + +TODO: add final rendered image + + +What do I need to get started? +============================== + +First of all you need to install Mapnik library to your system. There +are to two basic ways to do it, you can either download binaries or +build library yourself from source. Installation from source if far more +complex and it documented in ..link to document... + +Installation depends on your operating system and following sections +describe this process. + +Windows installation +-------------------- + +Installing Mapnik on windows consists of following steps: + +1. Install system prerequisites + +Because Mapnik binary was built using with Visual C++ 2008 Express, +it requires vc90 runtime. To solve this, go to download +the C++ runtimes from `microsoft website `_ +and install it. + +2. Install Python 2.7 + +Always because of the build, provided python bindings support for now +just Python version 2.7 32 bit (not 64 bit) which can be downloaded from +`official Python website `_ +Install it. +Now you have to install python to your path (it means you will have +access to python throught DOS command line) +For this, steps to follow are: + +* right-click "My Computer" and click "Properties". +* in "System Properties" window, click on the "Advanced" tab. +* from "Advanced section", click on "Environment Variables". +* in "Environment Variables" window, click on the "Path" variable in the "Systems Variable" section. +* after, click on "Edit". +* at the end of "Path", add ``;c:\Python27;C:\Python27\Scripts``, click "Ok" +* open a new command line and type "python" to confirm it works and go out typing "exit()" + +3. Download, unzip and configure Mapnik binary + +Go to retrieve `the binary `_ +and simply unzip the archive into ``c:/mapnik-2.0.1rc0`` + +Set your system and/or users environment variables for Mapnik: + +* set system "Path" adding at the end ``;c:\mapnik-2.0.1rc0\lib`` like you've done for Python + +* launch a new DOS command line and then you should be able to run the demo program: :: + + cd c:\mapnik-2.0.1rc0\demo\c++ + rundemo ..\..\lib\mapnik + +* You'll get something like this :: + + running demo ... + looking for 'shape.input' plugin in... ..\..\lib\mapnik/input/ + looking for DejaVuSans font in... ..\..\lib\mapnik/fonts/DejaVuSans.ttf + Three maps have been rendered using AGG in the current directory: + - demo.jpg + - demo.png + - demo256.png + - demo.tif + Have a look! + Three maps have been rendered using Cairo in the current directory: + - cairo-demo.png + - cairo-demo256.png + - cairo-demo.pdf + - cairo-demo.svg + Have a look! + +* set mapnik python environment + +You also have to use the python bindings to enable them adding a new +system environment variable called PYTHONPATH and affect it ``c:\mapnik-2.0.1rc0\python\2.7\site-packages;`` + +Then you should be able to run the python demo after you open a new DOS shell: +:: + cd c:\mapnik-2.0.1rc0\demo\python + python rundemo.py + + +Linux installation +------------------ + +Most modern Linux distributions include Mapnik binaries in their +repositories. Installation method depends your distribution: + +* Ubuntu :: + + # sudo add-apt-repository ppa:mapnik/nightly-trunk + # aptitude install libmapnik2 + +* Debian + + *Wheezy*: + + Directly bundled in distribution :: + + # apt-get install libmapnik2-2.0 mapnik-utils libmapnik2-2.0 + + *Squeeze*: + + A backport was done from Wheezy version + + Follow instructions from http://osm.fsffrance.org/debian-backports/README to install + +* Fedora + + For version 2, you will have to compile from source at the moment + +* Archlinux + + See `mapnik wiki on Arch linux installation `_ + + +MacOSX installation +------------------- + +Dane Springmeyer kindly hosts and builds MacOSX Mapnik binaries, you +can find more information on his download page +http://dbsgeo.com/downloads/. + +Testing Mapnik installation +=========================== + +Easiest way to test if you have successfully installed and configured +Mapnik is to start up your Python interpreter and try to import mapnik +library: :: + + $ python + Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) + [GCC 4.4.3] on linux2 + Type "help", "copyright", "credits" or "license" for more information. + >>> import mapnik + >>> + +If there are no errors or complaints, you're on the right track. You +can also try to find out which Mapnik version you are currently +running by executing following code: :: + + >>> import mapnik + >>> mapnik.mapnik_version_string() + '2.0.0' + >>> + +If you don't get 2.x.x version, you will maybe need to make:: + + >>> import mapnik2 + +This case, was to avoid namespace collision in python when mapnik 2.0 +version wasn't the current version and users already get a 0.7.x version. + +Now, that's it you are ready to create your first map using Python +scripting language. + diff --git a/index.rst b/en/index.rst similarity index 91% rename from index.rst rename to en/index.rst index 0b7dc88..c826d17 100644 --- a/index.rst +++ b/en/index.rst @@ -29,6 +29,8 @@ Contents Load PostGIS Database with Initial Geographic Data Install Mapnik Library Prerequisites Install Mapnik Library + Start to use Mapnik with simple example + Start to use Mapnik with XML example ================== Indices and tables @@ -44,6 +46,6 @@ Documentation writing guidelines .. toctree:: :maxdepth: 1 - + documentation_guidelines.rst diff --git a/install_mapnik_library.rst b/en/install_mapnik_library.rst similarity index 100% rename from install_mapnik_library.rst rename to en/install_mapnik_library.rst diff --git a/install_mapnik_library_prereq.rst b/en/install_mapnik_library_prereq.rst similarity index 100% rename from install_mapnik_library_prereq.rst rename to en/install_mapnik_library_prereq.rst diff --git a/install_postgis_database.rst b/en/install_postgis_database.rst similarity index 82% rename from install_postgis_database.rst rename to en/install_postgis_database.rst index 423c3b6..93b4b5a 100644 --- a/install_postgis_database.rst +++ b/en/install_postgis_database.rst @@ -5,7 +5,7 @@ Install PostGIS Database Install Postgresql and PostGIS ============================== -Is everything up to date on your system? +Is everything up to date on your system? :: @@ -18,19 +18,19 @@ queries. :: sudo aptitude install postgresql-8.4-postgis postgresql-contrib-8.4 - sudo aptitude install postgresql-server-dev-8.4 - sudo aptitude install build-essential libxml2-dev + sudo aptitude install postgresql-server-dev-8.4 + sudo aptitude install build-essential libxml2-dev sudo aptitude install libgeos-dev libpq-dev libbz2-dev proj - + Configure the Postgresql Server =============================== Edit the configuration file at -/etc/postgresql/8.4/main/postgresql.conf to set some resonable +/etc/postgresql/8.4/main/postgresql.conf to set some reasonable defaults. These changes help when dealing with large quantities of data that are found in geographic some databases. -These edits are found in four places in the configuration file. +These edits are found in four places in the configuration file. :: @@ -42,11 +42,11 @@ These edits are found in four places in the configuration file. Configure runtime kernel parameters =================================== -Edit /etc/sysctl.conf to set kernel parameters after a restart. +Edit /etc/sysctl.conf to set kernel parameters after a restart. :: - kernel.shmmax=268435456 + kernel.shmmax=268435456 Then apply the same kernel parameter now, without restarting. @@ -62,7 +62,7 @@ changes. :: - sudo /etc/init.d/postgresql-8.4 restart + sudo /etc/init.d/postgresql-8.4 restart The database server should restart without errors or warnings @@ -77,7 +77,7 @@ you will use this database name. Substitute your username for "username" in two places below. This should be the username that will render maps with mapnik. -:: +:: sudo -u postgres -i createuser username # answer yes for superuser @@ -100,6 +100,10 @@ This should respond with many lines ending with | CREATE FUNCTION | COMMIT +:: + + psql -f /usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql -d gis + Substitute your username for "username" in two places in the next line. This should be the username that will render maps with mapnik. @@ -134,6 +138,9 @@ Replies with many lines ending with Set SRID for PostGIS Database ============================= +This step is now not needed anymore, spatial_ref_sys.sql already contains +reference to the projection. Only here as a reminder. + Set the Spatial Reference Identifier (SRID) on the new database. :: @@ -144,12 +151,3 @@ Should reply with | INSERT 0 1 - - - - - - - - - diff --git a/load_postgis_database.rst b/en/load_postgis_database.rst similarity index 100% rename from load_postgis_database.rst rename to en/load_postgis_database.rst diff --git a/fr/GettingStarted-1.rst b/fr/GettingStarted-1.rst new file mode 100644 index 0000000..5ac564f --- /dev/null +++ b/fr/GettingStarted-1.rst @@ -0,0 +1,234 @@ +******************************************************************************* +Tutoriel 1 -- 'Hello,world!' en Python +******************************************************************************* + +Etape 1 +------- + +Assurez- vous d'avoir mapnik installé. En fonction de votre chemin +d'installation, vous aurez peut-être besoin de modifier le chemin python +PYTHONPATH, /etc/ld.so.conf, d'exporter LD_LIBRARY_PATH ou de faire n'importe +quelle modification nécessaire au fonctionnement du système. + +La manière la plus simple de faire cette vérification est de démarrer +l'interpréteur python à partir de la ligne de commande en tapant python +et ensuite de taper simplement: + +.. sourcecode:: python + + >>> import mapnik + + +et si vous n'avez pas de messages d'erreur, vous êtes sur le bon chemin. Dans +le cas contraire, vous allez devoir encore vérifier votre installation. + +.. note:: Si vous avez compilé mapnik en mode debug, vous devriez voir + apparaître le listing des sources de données utilisables, incluant: + +.. sourcecode:: python + + >>> import mapnik + registered datasource : gdal + registered datasource : postgis + registered datasource : raster + registered datasource : shape + +Pour obtenir ce listing, vous avez aussi la possibilité de faire + +.. sourcecode:: python + + python -c "from mapnik import DatasourceCache as c;print ','.join(c.plugin_names())" + + +Etape 2 +------- + +Le code ci-dessous peut être coller dans votre interpréteur python. Idéalement, +copier ligne par ligne le code pour confirmer que chaque étape fonctionne. Les +lignes commentées (#) devrait pouvoir être collées sans problème mais la +configuration de votre interpréteur pourra dans certains cas causer des erreurs. + + * Voir le bout de code (snippet) à l'étape 3 pour un code sans commentaires. + +Importer la librairie mapnik et définir des paramètres basiques pour la carte + +.. sourcecode:: python + + import mapnik + + # Instantiate a map object with given width, height and spatial reference + # system + m = mapnik.Map(600,300,"+proj=latlong +datum=WGS84") + # Set background colour to 'steelblue'. + # You can use 'named' colours, #rrggbb, #rgb or rgb(r%,g%,b%) format + m.background = mapnik.Color('steelblue') + + + +.. note:: Mapnik accepte toutes les projections que supporte PROJ4. Allez sur + http://spatialreference.org pour obtenir les chaînes de caractères PROJ4 + pour les différentes projections. Par exemple, + http://spatialreference.org/ref/epsg/4326/mapnikpython/ vous donnera les + paramètres exacts pour la projection EPSG 4326 (utilisée dans les GPS par + exemple). + +Créer les styles et les règles pour la symbologie de la carte + +.. sourcecode:: python + + # Now lets create a style and add it to the Map. + s = mapnik.Style() + # A Style can have one or more rules. A rule consists of a filter, min/max + # scale demoninators and 1..N Symbolizers. If you don't specify filter and + # scale denominators you get default values : + # Filter = 'ALL' filter (meaning symbolizer(s) will be applied to all + # features) + # MinScaleDenominator = 0 + # MaxScaleDenominator = INF + # Lets keep things simple and use default value, but to create a map we + # we still must provide at least one Symbolizer. Here we want to fill + # countries polygons with greyish colour and draw outlines with a bit + # darker stroke. + + r=mapnik.Rule() + r.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9'))) + r.symbols.append(mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'),0.1)) + s.rules.append(r) + + +Faire le lien entre les informations de style et celles de votre carte et de +votre donnée + +.. sourcecode:: python + + # Here we have to add our style to the Map, giving it a name. + m.append_style('My Style',s) + + # Here we instantiate our data layer, first by giving it a name and srs + # (proj4 projections string), and then by giving it a datasource. + lyr = mapnik.Layer('world',"+proj=latlong +datum=WGS84") + # Then provide the full filesystem path to a shapefile in WGS84 or + # EPSG 4326 projection without the .shp extension + # A sample shapefile can be downloaded from + # http://mapnik-utils.googlecode.com/svn/data/world_borders.zip + lyr.datasource = mapnik.Shapefile(file='/Users/path/to/your/data/world_borders') + lyr.styles.append('My Style') + + +Enfin, ajouter les couches à la carte et zoomer sur l'étendue maximale de la couche. + +.. sourcecode:: python + + m.layers.append(lyr) + m.zoom_to_box(lyr.envelope()) + +Finir en générant l'image de la carte du monde + +.. sourcecode:: python + + #!python + # Write the data to a png image called world.png in the base directory of your user + mapnik.render_to_file(m,'world.png', 'png') + + # Exit the python interpreter + exit() + + +Ensuite revenir dans votre terminal: + +.. sourcecode:: bash + + # On a mac + open world.png + # On windows + start world.png + + +Ou naviguer dans votre répertoire et ouvrir world.png avec un résultat qui +devrait ressembler à celui-ci-dessous: + +.. _world: +.. figure:: ../_images/world.png + + +Etape 3 +------- + +L'étape suivante la plus logique est le lancement de ce même code depuis un +script python lancé via votre terminal. De cette manière, vous serez capable +de modifier et d'expérimenter des changements de paramètres. + +Cette étape peut être réalisée en ajoutant la ligne suivante au début du script: + +.. sourcecode:: python + + #!/usr/bin/env python + +Copier tout le texte ci-dessous et l'enregistrer dans un fichier portant le +nom world.py. + +.. sourcecode:: python + + #!/usr/bin/env python + + import mapnik + m = mapnik.Map(600,300,"+proj=latlong +datum=WGS84") + m.background = mapnik.Color('steelblue') + s = mapnik.Style() + r=mapnik.Rule() + r.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9'))) + r.symbols.append(mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'),0.1)) + s.rules.append(r) + m.append_style('My Style',s) + lyr = mapnik.Layer('world',"+proj=latlong +datum=WGS84") + lyr.datasource = mapnik.Shapefile(file='/Users/path/to/your/data/world_borders') + lyr.styles.append('My Style') + m.layers.append(lyr) + m.zoom_to_box(lyr.envelope()) + mapnik.render_to_file(m,'world.png', 'png') + +.. note:: N'oubliez pas de changer le chemin pour qu'il pointe vers votre + fichier shp world_borders. + + * Mapnik supporte aussi bien les chemins absolus que relatifs vers vos + données. + * Il en est de même pour le chemin de votre fichier. + +Ensuite rendre le script exécutable. Sur Mac ou Linux, vous ferez cela avec la +commande: + +.. sourcecode:: bash + + chmod +x world.py + + +Lancer le script avec la commande: + +.. sourcecode:: bash + + # You must be in the same directory as you saved the script + ./world.py + # Add a second optional command to open the resulting file with one + # keystroke + # On a mac + ./world.py; open world.png + # On windows + start world.py && start world.png + + +* Lancer de cette manière le script permettra d'écraser le fichier et d'ouvrir + la carte world.png. +* Maintenant, vous pouvez facilement ouvrir le script dans un éditeur de texte + et essayer de changer les dimensions, les couleurs ou la source de donnée + (en n'oubliant pas de choisir la bonne projection). + +Pour générer la même carte avec XML, lisez le +:doc:`Commencez avec mapnik et le XML (tutoriel 2) ` qui +montre l'usage du XML pour la configuration de la carte. + +Pour télécharger, ce script ainsi avec d'autres scripts de tutoriels, +voir http://code.google.com/p/mapnik-utils/ + + +Pièce jointe :download:`world.png <../_images/world.png>`. + diff --git a/fr/XMLGettingStarted.rst b/fr/XMLGettingStarted.rst new file mode 100644 index 0000000..927b779 --- /dev/null +++ b/fr/XMLGettingStarted.rst @@ -0,0 +1,299 @@ +*************************************************************** +Tutoriel 2 -- 'Hello,world!' en utilisant la configuration XML +*************************************************************** + +Vue d'ensemble +-------------- + +Assurez-vous d'avoir Mapnik installé et d'avoir passé avec succès +:doc:`Commencer à utiliser Mapnik avec un exemple simple `. + +* Cette page va vous guider dans l'usage de Mapnik avec Python pour gérer les + les styles de carte avec un fichier XML séparé. + +* C'est une approche pratique pour gérer vos styles/règles pour la carte + séparément de votre code python, et celà peut être avantageux pour gérer des + formatages très complexes. + Par conséquent, c'est un fichier de configuration XML qui est utilisé par le + projet OpenStreetMap pour faire des filtrages par attributs très importants + sur des données PostGIS. + + +Deux exemples vont être montrés: + +1) un fichier de configuration XML qui fournit exactement le même résultat que +pour la carte générée dans l'exemple en python pur dans :doc:`Commencer à +utiliser Mapnik avec un exemple simple `. + + +* C'est dans le but d'aider les nouveaux utilisateurs à comprendre l'usage + courant des styles Mapnik et les paramètres des règles. + +* Note: Ces exemples sont volontairement limités et ne tirent pas entièrement + profit des capacités de Mapnik. + + * Voir le script :source:`rundemo.py ` dans les + téléchargements pour des usages plus avancés de Mapnik avec Python. + + * Voir :source:`l'exemple du XML OSM + ` dans le répertoire de tests pour + des usages plus avancés avec le XML. + + +2) Un XML de configuration qui utilise un jeu de données des contours mondiaux +avec les attributs de population pour créer une carte choroplèthe par taille +de la population. C'est dans le but d'introduire l'utilisation des règles de +filtrage et de gestion des étiquettes avec un XML. + +Note: Le code pour l'exemple 1, ainsi que le code de :doc:`Commencer à +utiliser Mapnik avec un exemple simple ` peut être +télécharger depuis un fichier zip à partir du lien ci-dessous. Ces +fichiers contiennent des chemins relatifs à un répertoire de données où vous +devrez placer world_borders.shp (et ses fichiers associés). + +Etape 1 +------- + +**Hello World XML** + +En premier, vous aurez toujours besoin d'un script python qui définit les +paramètres basiques de la carte et qui pointe vers le fichier XML de +configuration: + +.. sourcecode:: python + + #!/usr/bin/env python + import mapnik mapfile = 'world_styles.xml' + map_output = 'hello_world_using_xml_config.png' + m = mapnik.Map(600, 300) + mapnik.load_map(m, mapfile) + bbox = mapnik.Envelope(mapnik.Coord(-180.0, -90.0), mapnik.Coord(180.0, 90.0)) + m.zoom_to_box(bbox) + mapnik.render_to_file(m, map_output) + +* Copier ce code et sauver le fichier sous le nom **world_map.py** + +Ensuite, vous allez devoir créer le fichier **world_styles.xml** référencé dans +**world_map.py** + +Note: vous devrez spécifier le chemin vers le même `fichier shape des contours +mondiaux `_ de Mapping Hacks +utilisé dans le tutoriel 1 + +.. sourcecode:: xml + + + + + + + My + Style + + shape + /path/to/your/world_borders + + + + + +* Copier ce fichier XML et sauver le fichier **world_styles.xml** au même niveau + que le script **world_map.py** + +Maintenant, lancer ce script avec la commande: + +.. sourcecode:: bash + + python world_map.py + +* Il devrait générer une image png dans le même répertoire un fichier + équivalent à celui produit dans + Started Tutorial. + + + +Etape 2 +------- + +**World Population XML** + +Vous trouverez joint ci-dessous et inclus comme code, un exemple de script +python qui accède à un fichier **population.xml pour la configuration de +la carte.** + +Note: Vous devrez télécharger :download:`le fichier shp des contours mondiaux +des pays <../_files/world_borders.zip>`. + +* Note: Ce fichier est originalement issu de `Thematic Mapping Blog + `_. La version + jointe est le fichier shape fourni le plus simple comportant quelques + modifications pour éviter des problèmes quand la carte est générée dans des + projections telles que le 900913/3785 (ce tutoriel n'utilise pas cette + projection, donc vous pouvez utiliser les fichiers shape originaux + également). Voir le `ticket 308 `_ pour + des détails. + +Ce script devrait générer un résultat graphique comme celui ci-dessous: + +.. _worldpop: +.. figure:: ../_images/world_population_minimized.png + + +.. sourcecode:: python + + #!/usr/bin/env python + + import mapnik mapfile = "population.xml" + m = mapnik.Map(1400, 600) + mapnik.load_map(m, mapfile) + bbox = mapnik.Envelope(mapnik.Coord(-180.0, -75.0), mapnik.Coord(180.0, 90.0)) + m.zoom_to_box(bbox) + mapnik.render_to_file(m, 'world_population.png', 'png') + +Et voici le fichier xml: + +.. sourcecode:: xml + + + + + + + + + + + population + countries_label + + shape + + + /PATH/TO/THE/TM_WORLD_BORDERS_SIMPL-0.3 + + + + +Fichiers joints + +:download:`hello_world.zip <../_files/hello_world.zip>` - Tutoriel pour les +exemples Mapnik Hello World utilisant le python pur et le système de fichier +de configuration XML. + +:download:`world_population.png <../_images/world_population.png>` Carte +résultante de l'étape 2 en utilisant le fichier XML de configuration pour +afficher une carte chloroplèthe de la population mondiale. + +:download:`world_population_minimized.png +<../_images/world_population_minimized.png>` - Version réduite du résultat de +l'étape 2 pour le rendu sous Trac. + +:download:`world_borders.zip <../_files/world_borders.zip>`. + diff --git a/fr/about_mapnik.rst b/fr/about_mapnik.rst new file mode 100644 index 0000000..44354b7 --- /dev/null +++ b/fr/about_mapnik.rst @@ -0,0 +1,105 @@ + +****** +Mapnik +****** + +Mapnik consiste à faire de belles cartes. Il utilise la `bibliothèque AGG +`_ ou `la bibliothèque Cairo +`_ et offre un rendu avec anticrénelage +de première qualité avec une précision inférieure au pixel pour les données +géographiques. Il a été développé à partir de zéro en utilisant du C++ moderne +et ne souffre donc pas de choix de conception hérités d'années d'existence. +Quand il s'agit de gérer les tâches communes à la plupart des logiciels comme +la gestion de la mémoire, les accès aux systèmes de fichiers, la gestion des +expressions régulières ou bien d'autres fonctionnalités, Mapnik ne réinvente +pas la roue, mais utilise les meilleures bibliothèques standards de l'industrie +logicielle issues de http://boost.org. + + +Historique +========== + +Le projet Mapnik a été commencé en 2005 par un chaud après-midi de juin, par Artem Pavlenko. +La première version a été mise à disposition ... + +La version courante est la 0.7.1 qui est disponible au téléchargement sur +http://mapnik.org/download/. + + +Communauté +========== + +La communauté Mapnik est organisée autour du site principal http://mapnik.org +et du site de développement http://trac.mapnik.org sur lequel vous trouverez +les dernières nouveautés sur Mapnik et son développement. Le site de +développement est organisé comme un wiki qui contient beaucoup d'informations +utiles, et où vous pouvez contribuer librement en vous +`enregistrant `_. + +Vous pouvez aussi poser des questions sur les listes de diffusion `mapnik-users +`_ (mapnik-utilisateurs) +et si vous souhaitez contribuer au développement de Mapnik allez sur +`mapnik-devel +`_ +(mapnik-développeurs). En suivant ces liens vous trouverez aussi les archives +de ces listes, que vous pourrez consulter avant de poser une question. Vous +pouvez suivre ces listes sur `Nabble +`_. + +Si vous préférez une communication plus directe, vous pouvez nous trouvez dans +la salle **#mapnik** sur irc.freenode.net, n'hésitez pas à venir pour nous +poser vos questions quand vous voulez. + +Plates-formes +============= + +Mapnik est une boîte à outils multi-plates-formes qui fonctionne sur Windows, +Mac, et Linux (depuis la version 0.4). Les utilisateurs font fonctionner +généralement Mapnik sur Mac >=10.4.x (avec un processeur Intel comme PPC), +comme sur Debian/Ubuntu, Fedora, Centos, OpenSuse, et FreeBSD. + +Formats de données supportés +============================ + +Mapnik utilise une architecture basée sur les plugins pour lire les différentes +sources de données. Les plugins courants, considérés comme stables et compilés +par défaut, sont : + +* *shape* - permet l'accès aux fichiers `Shape ESRI + `_ +* *postgis* - permet l'accès aux données géospatiales issues de `PostGIS + `_, l'extension spatiale pour + `PostgreSQL `_ +* *raster* - permet l'usage d'images raster TIFF simples ou tuilées + +Les autres plugins ne sont pas instables mais comme ils ont été rajoutés plus +récemment, ils peuvent encore comporter quelques erreurs: + +* *gdal* - permet l'accès aux sources de données `GDAL + `_ +* *ogr* - permet l'accès aux sources de données `OGR + `_ +* *osm* - permet la lecture des fichiers de données XML `OpenStreetMap + `_ +* *sqlite* - permet l'accès aux données géospatiales vecteurs '`SQLite + `_ / `Spatialite + `_ +* *occi* - permet l'accès aux données géospatiales vecteurs de `oracle + spatial `_ 10g (versions + 10.2.0.x) +* *kismet* - permet le support de `kismet `_ + Ce support GPS montre les noeuds WLAN sur la carte +* *rasterlite* - permet l'accès au format raster sqlite avec compression par + "vaguelettes" `Rasterlite `_ + +Plus de plugins d'accès aux données seront disponibles dans le futur. Si vous +ne voulez pas attendre et /ou voulez coder en C++, pourquoi ne pas écrire +votre propre plugin d'accès aux données? + +Futur +===== + +Un grand nombre de développeurs et de contributeurs développent activement +*mapnik2* qui deviendra la version **0.8.0**. De plus, il est +planifié que la version **0.7.2** sorte prochainement. + diff --git a/fr/documentation_guidelines.rst b/fr/documentation_guidelines.rst new file mode 100644 index 0000000..2690ed2 --- /dev/null +++ b/fr/documentation_guidelines.rst @@ -0,0 +1,28 @@ +*********************************** +Guide pour rédiger la documentation +*********************************** + +* La largeur du texte ne devrait pas dépasser plus de **80** caractères par + ligne. +* La structure suivante qui devrait être utilisée : :: + + =================== + Parties principales + =================== + + ********* + Chapitres + ********* + + Sections + ======== + + Sous-sections + ------------- + + Sous-sous-sections + ^^^^^^^^^^^^^^^^^^ + + paragraphes + """"""""""" + diff --git a/fr/getting_started.rst b/fr/getting_started.rst new file mode 100644 index 0000000..7ea1131 --- /dev/null +++ b/fr/getting_started.rst @@ -0,0 +1,80 @@ +******* +Débuter +******* + +Après avoir lu ce document, vous devriez être capable de créer un rendu de +carte simple avec Python ou C++. + +TODO: Ajouter l'image finale obtenue + + +De quoi a-t-on besoin pour débuter? +=================================== + +Premièrement, vous devez installer la bibliothèque Mapnik sur votre système. +Il y a deux manières basiques de le faire, vous pouvez télécharger des binaires +(des exécutables) ou compiler votre librairie vous même depuis les sources. +L'installation depuis les sources est nettement plus comlexe et est documentée +dans Lien vers le document + +L'installation dépend de votre système d'exploitation et les sections suivantes +décrivent le processus. + +Installation sous Windows +------------------------- + +Installer Mapnik sous Windows suit les étapes suivantes: + +1. Installer les logiciels prérequis +2. Télécharger et décompresser la bibliothèque Mapnik +3. Configurez votre système et / ou les variables utilisateurs de votre + environnement + +Chacun de ces étapes est définie .. ici ..! + +Installation sous Linux +----------------------- + +La plupart des distributions modernes de Linux inclut des binaires Mapnik dans +leurs dépôts. La méthode d'installation dépend de votre distribution: + +* Debian ou Ubuntu :: + + # aptitude install python-mapnik + +* Fedora :: + + # yum install mapnik-python + +* Archlinux :: + + # pacman -S mapnik + +Installation sous MacOSX +------------------------ + +Dane Springmeyer héberge et compile généreusement les binaires Mapnik pour +MacOSX, vous pouvez retrouver plus d'informations sur la page de téléchargement +http://dbsgeo.com/downloads/. + +Tester l'installation de Mapnik +=============================== + +La manière la plus simple de faire un test pour vérifier que vous avez installé +et configuré avec succès Mapnik est de démarrer l'interpréteur Python et +d'essayer d'importer la bibliothèque mapnik: :: + + $ python Python 2.6.5 (r265:79063, Apr 1 2010, 05:28:39) [GCC 4.4.3 20100316 + (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for + more information. >>> import mapnik >>> + +S'il n'y a pas d'erreurs ou de complaintes, vous êtes sur la bonne voie. Vous +pouvez aussi essayer de trouver la version de Mapnik que vous utilisez +actuellement en exécutant le code suivant: :: + + >>> import mapnik >>> mapnik.mapnik_version() 701 # Human readable version + >>> mapnik.mapnik_version_string() '0.7.1' + +C'est bon, vous êtes prêt à créer votre première carte en utilisant le langage +Python. + diff --git a/fr/index.rst b/fr/index.rst new file mode 100644 index 0000000..da5592e --- /dev/null +++ b/fr/index.rst @@ -0,0 +1,52 @@ +.. Mapnik documentation master file, created by + sphinx-quickstart on Fri Jul 16 14:41:35 2010. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +==================== +Documentation Mapnik +==================== + +Mapnik est une boîte à outils multi-plateformes en C++/Python pour +développer des applications cartographiques. Mapnik est un `logiciel libre +`_ et il est disponible +sous licence `LGPL `_ (Lesser +General Public Licence). Le coeur est constitué d'une bibliothèque partagée +en C++ qui fournit des algorithmes / modèles pour l'accès à des données +spatiales et pour la visualisation. Il peut être utilisé aisément à la fois +pour du développement web comme bureautique permettant un développement rapide +basé sur les méthodes agiles. + +======= +Contenu +======= + +.. toctree:: + :maxdepth: 1 + + A propos de Mapnik + Débuter + Installer la base PostGIS + Charger une base de données PostGIS avec des données géographiques + Installer les librairies prérequises pour Mapnik + Installer la librairie Mapnik + Commencer à utiliser Mapnik avec un exemple simple + Commencer à utiliser Mapnik avec un exemple XML + +=============== +Index et tables +=============== + +* :ref:`genindex` +* :ref:`search` + + +============================================ +Guide d'aide à la rédaction de documentation +============================================ + +.. toctree:: + :maxdepth: 1 + + documentation_guidelines.rst + diff --git a/fr/install_mapnik_library.rst b/fr/install_mapnik_library.rst new file mode 100644 index 0000000..0e689f0 --- /dev/null +++ b/fr/install_mapnik_library.rst @@ -0,0 +1,70 @@ +******************************** +Installer la librairie Mapnik +******************************** + +La librairie Mapnik peut être installée de plusieurs manières, choisissez l'une +d'elles: + + +- Installer depuis votre gestionnaire de paquets +- Installer depuis les binaires (sources déjà compilées pour une plate-forme) +- Installer la version stable de Mapnik depuis les sources +- Installer la dernière version de Mapnik depuis les sources +- tba ? + +Est-ce que tout est à jour sur votre système? + +:: + + sudo aptitude update + sudo aptitude safe-upgrade + + +Installer la bibliothèque Mapnik depuis votre gestionnaire de paquets +===================================================================== + +Cela ne sera peut-être pas la version la plus récente de Mapnik, selon votre +distribution. + +:: + + sudo aptitude install mapnik + + +Installer la bibliothèque Mapnik depuis les binaires +==================================================== + +Les binaires Windows et MacOSX sont disponibles. Voir les instructions +d'installation pour Windows et MacOSX. + + TODO: Avoir une server de compilation pour créer les binaires .deb et .rpm + + TODO: Ajouter les instructions d'installation pour MacOSX + + TODO: Ajouter les instructions d'installation pour Windows + + + +Installer la dernière version stable de la bibliothèque Mapnik depuis les sources +================================================================================= + +:: + + + cd ~/src + svn co http://svn.mapnik.org/tags/release-0.7.1/ mapnik + cd mapnik + python scons/scons.py configure INPUT_PLUGINS=all OPTIMIZATION=3 SYSTEM_FONTS=/usr/share/fonts/truetype/ + python scons/scons.py + sudo python scons/scons.py install + sudo ldconfig + +Si Mapnik est compilé sans erreurs, confirmer que python trouve bien Mapnik. + +:: + + python + >>> import mapnik + # if python returns the 3-chevron prompt below without errors mapnik was properly detected + >>> + diff --git a/fr/install_mapnik_library_prereq.rst b/fr/install_mapnik_library_prereq.rst new file mode 100644 index 0000000..cbfe681 --- /dev/null +++ b/fr/install_mapnik_library_prereq.rst @@ -0,0 +1,37 @@ +************************************ +Install Mapnik Library Prerequisites +************************************ + +Installer les librairies Boost depuis les paquets +================================================= + +Est-ce que tout est à jour sur votre système? + +:: + + sudo aptitude update + sudo aptitude safe-upgrade + + +Installer les outils prérequis +------------------------------ + +:: + + sudo aptitude install libltdl3-dev libpng12-dev libtiff4-dev libicu-dev + sudo aptitude install python-cairo-dev python-nose + sudo aptitude install libfreetype6-dev libcairo2-dev libcairomm-1.0-dev + sudo aptitude install libgeotiff-dev libtiff4 libtiff4-dev libtiffxx0c2 + sudo aptitude install libsigc++-dev libsigc++0c2 libsigc-2.0-2 libsigx-2.0-dev + sudo aptitude install libgdal1-dev python-gdal imagemagick + + +Installer les librairies Boost de développement +----------------------------------------------- + +:: + + sudo aptitude install libboost-python1.40-dev libboost1.40-dev libboost-filesystem1.40-dev + sudo aptitude install libboost-iostreams1.40-dev libboost-regex1.40-dev libboost-thread1.40-dev + sudo aptitude install libboost-program-options1.40-dev + diff --git a/fr/install_postgis_database.rst b/fr/install_postgis_database.rst new file mode 100644 index 0000000..f0e71dd --- /dev/null +++ b/fr/install_postgis_database.rst @@ -0,0 +1,161 @@ +******************************* +Installation de la base PostGIS +******************************* + +Installer Postgresql and PostGIS +================================ + +Est-ce que tout est à jour sur notre système? + +:: + + sudo aptitude update + sudo aptitude safe-upgrade + +Installer PostgreSQL et l'extension PostGIS pour permettre d'utiliser des +requêtes géographiques. + +:: + + sudo aptitude install postgresql-8.4-postgis postgresql-contrib-8.4 + sudo aptitude install postgresql-server-dev-8.4 + sudo aptitude install build-essential libxml2-dev + sudo aptitude install libgeos-dev libpq-dev libbz2-dev proj + +Configurer le serveur PostgreSQL +================================ + +Editer le fichier de configuration situé dans +/etc/postgresql/8.4/main/postgresql.conf pour définir certains des +paramètres par défaut. Ces changements aident lorsque l'on doit gérer des grandes +quantités de données telles qu'on peut les trouver dans certaines bases de +données géographiques. + +Ces changements sont à effectuer à quatre endroits dans le fichier de +configuration. + +:: + + shared_buffers = 128MB # 16384 for 8.1 and earlier + checkpoint_segments = 20 + maintenance_work_mem = 256MB # 256000 for 8.1 and earlier + autovacuum = off + +Configurer les paramètres du noyau d'exécution +============================================== + +Editer /etc/sysctl.conf pour définir les paramètres du noyau après un +redémarrage. + +:: + + kernel.shmmax=268435456 + +Ensuite, appliquer ce même paramètre du noyau maintenant mais sans redémarrer. + +:: + + sudo sysctl kernel.shmmax=268435456 + +Redémarrer le serveur PostgreSQL +================================ + +Redémarrer le serveur PostgreSQL pour prendre en compte les modifications de configuration. + +:: + + sudo /etc/init.d/postgresql-8.4 restart + +Le serveur de base de données devrait redémarrer sans messages d'erreurs ou +d'avertissements + + | * Restarting PostgreSQL 8.4 database server + | ...done. + +Créer la base de données PostgreSQL +==================================== + +Créer la base de données nommée "gis". Certains des futurs outils supposerons +que vous utilisez ce nom de base de données. Substituer votre nom d'utilisateur +à la place de "username" dans les deux cas suivants. Ce nom va être celui de +l'utilisateur qui va générer les cartes avec mapnik. + +:: + + sudo -u postgres -i + createuser username # answer yes for superuser + createdb -E UTF8 -O username gis + createlang plpgsql gis + exit + +Appliquer les extensions PostGIS à la base de données +===================================================== + +Appliquer les extensions PostGIS à la base de données. + +:: + + psql -f /usr/share/postgresql/8.4/contrib/postgis.sql -d gis + +La réponse devrait finir avec beaucoup de lignes du type + + | ... + | CREATE FUNCTION + | COMMIT + +puis lancer + +:: + + psql -f /usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql -d gis + + +Substituer votre nom d'utilisateur "username" dans les deux emplacements de la +ligne suivante. C'est cet utilisateur qui doit être utilisé pour générer les +cartes avec mapnik. + +:: + + echo "ALTER TABLE geometry_columns OWNER TO username; ALTER TABLE + spatial_ref_sys OWNER TO username;" | psql -d gis + +La réponse devrait être du type + + | ALTER TABLE + | ALTER TABLE + +Permettre la mise à jour des données OpenStreetMap +==================================================== + +Cette étape optionnelle est seulement requise si vous prévoyez de faire des +mises à jour régulières de votre donnée OpenStreetMap. Activer pour cela le +module intarray pour pouvoir faire la mise à niveau de la base de manière +journalière, horaire ou par minute en utilisant les fichiers .osc de +OpenStreetMap. + +:: + + psql -f /usr/share/postgresql/8.4/contrib/_int.sql -d gis + +Cela renvoie de multiples lignes du type + + | ... + | CREATE FUNCTION + | CREATE OPERATOR CLASS + +Définir le SRID pour la base de données PostGIS +=============================================== + +Cette étape est maintenant inutile normalement, spatial_ref_sys.sql contenant +déjà la référence de la projection. Elle est gardée pour mémoire. + +Définir le SRID (Spatial Reference IDentifier) sur la nouvelle base de données. + +:: + + psql -f ~/bin/osm2pgsql/900913.sql -d gis + +Le retour devrait être du type + + | INSERT 0 1 + diff --git a/fr/load_postgis_database.rst b/fr/load_postgis_database.rst new file mode 100644 index 0000000..514b337 --- /dev/null +++ b/fr/load_postgis_database.rst @@ -0,0 +1,67 @@ +******************************************************************* +Alimenter la base de données PostGIS avec des données géographiques +******************************************************************* + +Il y a plusieurs manières d'alimenter la base de données. Choisir +une des façons suivantes: + +- Fichier OpenStreetMap "Planet" + + Le fichier OpenStreetMap "Planet" est une copie de la base de données mondiale. + Ce fichier est volumineux et peut par conséquent engendrer quelques problèmes informatiques (également pour les nouveaux utilisateurs). + +- Fichier OpenStreetMap "Extract" + + Les fichiers OpenStreetMap "Extract" contiennent les données OpenStreetMap + pour une région donnée, souvent un pays, un état ou une région. Ils sont + plsu simple d'utilisation que le fichier "Planet". + +- OpenStreetMap API Bounding Box + + De plus petites zones géographiques, à l'échelle d'une ville par exemple, peuvent + être obtenues l'API OpenStreetMap. + +- Postgresql dump file + + +Fichier OpenStreetMap "Planet" +============================== + +Récupérer la base de données complète OpenStreetMap, appelée également +"fichier planet" et charger-la dans la base de données PostGIS. + +Récupérer le fichier planet +--------------------------- + +Un nouveau "planet" est publié environ toutes les semaines. Le miroir +et les archives sont disponibles à l'adresse http://planet.openstreetmap.org/ . +En juillet 2010 le fichier planet pesait environ 10 GB. Si vous n'êtes pas +intéressé par la base de données complète, vous pouvez choisir de télécharger +une extraction. + +Install the Planet File +----------------------- + +Using osm2pgsql or another tool. + + +OpenStreetMap Extract File +========================== + +OpenStreetMap Extract files typically include a single country, state +or province. They are published periodically by various sites +including + +- http://download.geofabrik.de/osm/ +- http://download.cloudmade.com/ +- others + +Aquire the Extract File +----------------------- + + + + + + + diff --git a/getting_started.rst b/getting_started.rst deleted file mode 100644 index e2c0cc8..0000000 --- a/getting_started.rst +++ /dev/null @@ -1,82 +0,0 @@ -*************** -Getting Started -*************** - -After reading this document you should be able to create a simple -rendered map using Python or C++. - -TODO: add final rendered image - - -What do I need to get started? -============================== - -First of all you need to install Mapnik library to your system. There -are to two basic ways to do it, you can either download binaries or -build library yourself from source. Installation from soruce if far more -complex and it documented in ..link to document... - -Installation depends on your operating system and following sections -describe this process. - -Windows installation --------------------- - -Installing Mapnik on windows consists of following steps: - -1. Install prerequisites -2. Download and unzip Mapnik binary -3. Set your system and/or users environment variables - -Each of this steps is explained in detail ..here..! - -Linux installation ------------------- - -Most modern Linux distributions include Mapnik binaries in their -repositories. Installation method depends your distribution: - -* Debian or Ubuntu :: - - # aptitude install python-mapnik - -* Fedora :: - - # yum install mapnik-python - -* Archlinux :: - - # pacman -S mapnik - -MacOSX installation -------------------- - -Dane Springmeyer kindly hosts and builds MacOSX Mapnik binaries, you -can find more information on his download page -http://dbsgeo.com/downloads/. - -Testing Mapnik installation -=========================== - -Easiest way to test if you have successfully installed and configured -Mapnik is to start up your Python interpreter and try to import mapnik -library: :: - - $ python - Python 2.6.5 (r265:79063, Apr 1 2010, 05:28:39) - [GCC 4.4.3 20100316 (prerelease)] on linux2 - Type "help", "copyright", "credits" or "license" for more information. - >>> import mapnik - >>> - -If there are no errors or complaints, you're on the right track. You -can also try to find out which Mapnik version are you currently -running by executing following code: :: - - >>> import mapnik - >>> mapnik.mapnik_version() - 701 - >>> - -That's it you are ready to create your first map using Python -scripting language.