1

I am trying to create a google earth like wep application. My problem is that I can't get to render a full view of the earth.

The zoom_all() function generates the following error :

RuntimeError: could not zoom to combined layer extents using zoom_all because proj4 could not back project any layer extents into the map srs (set map 'maximum-extent' to override layer extents)

And if I define an envelope, I can only manage to have a cropped view of the earth with

mapnik.Envelope(-4500000, -4500000, 4500000, 4500000)

or a blank image with

mapnik.Envelope(-4600000, -4600000, 4600000, 4600000)

EDIT : I also tried specifying maximum-extent in the xml file but the result was the same as specifying the envelope in the python script.

What am I doing wrong ? Any hint will be appreciated :)

My configuration is :

This is the python script that renders the image :

#!/usr/bin/python2

import mapnik

image = 'world-xml.png'
map_config = 'world.xml'
m = mapnik.Map(1000, 1000)
mapnik.load_map(m, map_config)
bbox = mapnik.Envelope(-4500000, -4500000, 4500000, 4500000)
m.zoom_to_box(bbox)
mapnik.render_to_file(m, image)

And this is the xml config file :

<Map background-color="#ffffff" srs="+proj=ortho +lat_0=0 +lon_0=0 +ellps=WGS84 +units=m +x_0=0 +y_0=0 +no_defs">
        <Style name="projet-carte">
                <Rule>
                        <PolygonSymbolizer fill="#ffffff" />
                        <LineSymbolizer stroke="#000000" stroke-width="0.1" />
                </Rule>
        </Style>
        <Layer name="world" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
                <StyleName>projet-carte</StyleName>
                <Datasource>
                        <Parameter name="type">shape</Parameter>
                        <Parameter name="file">lines.shp</Parameter>
                </Datasource>
        </Layer>    
</Map>

1 Answer 1

3

The ortho projection does not cover the whole world, only the visible half.

Using the QGIS GUI, your globe would look like this:

enter image description here

What you see as nasty artefacts will kill the python script.

So you have to clip the world to the visible extent.

See these Q&A for more advice:

Where did the polygons go after projecting a map in QGIS?

Ortho Projection produces artifacts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.