Well, the purpose of the forward projection code is to take the ll
variable as lat long and then use the defined projection to calculate
what the projected c0 and c1 points are in projected coordinates. So
you should leave the ll in degrees.

But it does sound like the projection string isn't working. I'd first
test in postgis whether you can project in the fashion you describe.
And not all projections are possible in one step - for example, you
need to project twice to get from spherical mercator on disk to
latlon, so you end up with things like this:

<quote>
Can't go 900913 -> 4326, but you can do 900913 -> 3395, and 3395 -> 4326. Gah!
select astext(transform(transform(way, 3395), 4326)) from
planet_osm_point where name like '%utney%';
</quote>

I'd try messing with postgis to get good OSGB results as somewhere to start.

Cheers,
Andy

On Wed, Apr 22, 2009 at 12:18 PM, Oliver O'Brien
<[email protected]> wrote:
> Have you tried using the full PROJ4s string for EPSG:27700 rather than using
> +init?
> e.g. follow the "Proj4js" link at:
> http://spatialreference.org/ref/epsg/27700/
> I'm wondering whether your installation knows the settings for 27700.
> Certainly I've had a similar problem with WebMercator.
>
> Certainly you definitely want to use metres rather than km or degrees when
> specifying the bounding box.
>
> Your 20km difference is probably because your installation is not
> recognising +init=EPSG:27700, defaulting to WGS84 (which uses a different
> world-shape than OSGB36 used for the BNG) and then drawing a map containing
> a few metres of ocean around 0deg N, 0deg E.
>
> The Ireland/Norwich problems suggest something more complicated is going
> wrong too, but try this and see what happens.
>
> Ollie
>
> -----Original Message-----
> Date: Wed, 22 Apr 2009 10:19:05 +0100
> From: Kev js1982 <[email protected]>
> Subject: [Talk-GB] Generating Mapnik Images to epsg:27700 (British
>        National        Grid) Projection
> To: [email protected]
> Message-ID:
>        <[email protected]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Sorry if this is the wrong place to ask this (I can't find a better one).
>
> I am trying to generate some tiles to generate a set of tiles to cover the
> British Isles in the OSGB Projection (epsg:27700)
>
> The files I have use an quite possibly unique naming schema (we are
> intending to use them as a drop in replacement for some OS supplied tiles
> when the licence expires, extending coverage to Northern Ireland* in the
> process) - an example of which is
> map-n440000-e360000-s420000-w340000-px250.png the numbers are the meters
> north/east of the OSGB origin (centered on western edge of the city of
> Preston in this example)  so it should be relatively easy to generate the
> tiles - but I am coming unstuck at generating the images.
>
> Modifying generate_image.py and using (chopped a bit for brevity - full code
> at http://kjs.me.uk/wiki/Talk:Mapnik , the main Mapnik page contains my
> installation notes)
>
> prj = Projection("+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 +nadgri...@null +no_defs +over")
> ll = (-6.5, 49.5, 2.1, 59)
> c0 = prj.forward(Coord(ll[0],ll[1]))
> c1 = prj.forward(Coord(ll[2],ll[3]))
> bbox = Envelope(c0.x,c0.y,c1.x,c1.y)
> m.zoom_to_box(bbox)
>
> gives me a map of the British Isles which generates okay :)
>
>
> Changing the projection line to
>
> prj = Projection('+init=epsg:27700')
>
> gives me a map centered some 500km or so south of Ghana on the equator
>
> Thinking I need to use Geocodes (aka Eastings and Northings) changing the ll
> line to
>
> ll = (0,0,500000,500000)
>
> This gives me a box of ocean, as does using km instead of meters
>
> ll = (0,0,500.000,500.000)
>
> Various combinations of changing the bbox and ll result in getting either
> Ghana or ocean - I guess i'm doing somet slightly wrong somewhere along the
> way.
>
> Taking the Eastings/Northings and converting to Latitude/Longitude means
> they don't quite match (Holyhead ends up around 20km north of it's original
> location for example) and the tiles don't join properly - this (as you would
> expect) results in noticable "tearing" of the map, particulally on the west
> coast of Ireland (for example Limerick is shown twice) and results in the
> town of Norwich disappearing on the east coast of England.
>
> Does anyone know/have a working example of how to generate a single tile
> using generate_image.py (or based on) based on the geocodes that bound the
> tile?
>
> * Yes I know the Island is on a different grid but all our points use Great
> Britain geocodes, which means negative eastings.
>
> Thanks
>
> Kev :o)
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.openstreetmap.org/pipermail/talk-gb/attachments/20090422/89535c
> ce/attachment-0001.htm
>
> ------------------------------
>
> _______________________________________________
> Talk-GB mailing list
> [email protected]
> http://lists.openstreetmap.org/listinfo/talk-gb
>
>
> End of Talk-GB Digest, Vol 31, Issue 13
> ***************************************
>
>
> _______________________________________________
> Talk-GB mailing list
> [email protected]
> http://lists.openstreetmap.org/listinfo/talk-gb
>

_______________________________________________
Talk-GB mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/talk-gb

Reply via email to