Hi Claire,

Wrapping the dateline can be a tricky issue. For maps that I've made  
that span the pacific, it's always been most straightforward to  
reproject the data into a custom projection with a central meridian in  
the middle of the Pacific.

If you have GDAL/OGR you could take your world_borders.shp and do this:

ogr2ogr -t_srs 
http://spatialreference.org/ref/user/north-pacific-albers-conic-equal-area/ 
  world_borders_pacific_albers.shp world_borders.shp

... which would reproject the shapefile into an albers equal area  
projection with a central meridian around -170 longitude.

*Note: OGR is able to fetch the proj.4 parameters from  
spatialreference.org to transform the data but also excepts the proj.4  
string or EPSG codes. For this projection you can fetch the proj4  
string from here: from: 
http://spatialreference.org/ref/user/north-pacific-albers-conic-equal-area/proj4/

Then, you'll need to either specify your mapnik bbox in that map's  
projection of course or use mapnik to reproject your bbox like:

springmeyer:~ spring$ python
Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import mapnik
registered datasource : gdal
registered datasource : postgis
registered datasource : raster
registered datasource : shape
 >>> albers_proj = mapnik.Projection("+proj=aea +lat_1=30 +lat_2=70  
+lat_0=52 +lon_0=-170 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m  
+no_defs")
 >>> wgs84_bbox = mapnik.Envelope(146.27, 40.52, -173.21, 64.39)
 >>> mapnik.forward_(wgs84_bbox, albers_proj)
Envelope(-1921935.38548,-1339056.57733,-261568.418706,2003177.44933)
 >>>



If this were wrapped in a script it might look like:

#!/usr/bin/env python

from mapnik import *

m = Map(600, 300)
albers_proj = Projection("+proj=aea +lat_1=30 +lat_2=70 +lat_0=52  
+lon_0=-170 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs")
m.projection = albers_proj
m.background = Color('steelblue')
s = Style()
r=Rule()
r.symbols.append(PolygonSymbolizer(Color('#f2eff9')))
r.symbols.append(LineSymbolizer(Color('rgb(50%,50%,50%)'),0.1))
s.rules.append(r)
m.append_style('My Style',s)
lyr = Layer('world')
lyr.datasource = Shapefile(file='data/world_borders_pacific_albers')
lyr.styles.append('My Style')
m.layers.append(lyr)
wgs84_bbox = Envelope(146.27, 40.52, -173.21, 64.39)
bbox = forward_(wgs84_bbox, albers_proj)
m.zoom_to_box(bbox)
render_to_file(m, 'map/world_pacific_albers.png')


Cheers,

Dane




On May 13, 2008, at 9:21 AM, Claire McLister wrote:

> Hi Everyone,
>
>  How do I specify a map bounding box that crosses the international
> date line?
>
>  For example, if I have a bbox of (146.27, 40.52, -173.21, 64.39) I
> really want a map of the Pacific Ocean region and not the whole world.
>
>  Will appreciate any pointers.
>
> Claire
>
>  --
>  Claire McLister                        [EMAIL PROTECTED]
>  21060 Homestead Road Suite 150
>  Cupertino, CA 95014            408-733-2737(fax)
>
>                      http://www.zeemaps.com
>
>
>
> _______________________________________________
> Mapnik-users mailing list
> [email protected]
> https://lists.berlios.de/mailman/listinfo/mapnik-users

_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to