-
-
Save uekeueke/6cf9503c4acbf51f8f83 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Mapnik supports the PROJ.4 WKT for projections and buried deep in the doc's is one called | |
| 'Two Point Equidistant'. You provide the left and right points and the map is rotated | |
| such that these two points are horizontal in the output. | |
| This allows you to rotate the map to any angle (including south up!!) and the text is | |
| rendered correctly! You don't have to change the projections of your input vectors. | |
| Simply tweak the mapnik generate_image.py script like this: | |
| Change: | |
| merc = mapnik.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 +nadgrids=@null +no_defs +over') | |
| To: | |
| merc = mapnik.Projection('+proj=tpeqd +lat_1=35 +lat_2=35 +lon_1=-80 +lon_2=-122 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs') | |
| And the map will render south up. | |
| For an overlay raster I had transparent grid artifacts until I reprojected the image | |
| to the target SRS. Like this: | |
| gdalwarp -t_srs '+proj=tpeqd +lat_1=35 +lat_2=35 +lon_1=-80 +lon_2=-122 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs' -co TILED=YES src.tif dst.tif | |
| Then change the srs tag in the mapnik project xml for the raster (originally | |
| styled in TileMill): | |
| <Layer name="raster" | |
| srs="+proj=tpeqd +lat_1=35 +lat_2=35 +lon_1=-80 +lon_2=-122 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs"> | |
| <StyleName>raster</StyleName> | |
| <Datasource> | |
| <Parameter name="file"><![CDATA[dst.tif]]></Parameter> | |
| <Parameter name="type"><![CDATA[gdal]]></Parameter> | |
| </Datasource> | |
| </Layer> | |
| The map then overlays the raster correctly, labeled, and with south up. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment