[OSM-dev] Plotting data on an equirectangular map, distorted for sphere projection
Christopher Stevens
chris at christopherstevens.cc
Fri Jul 19 18:31:37 UTC 2013
Alright,
Thanks to some great feedback, I've made some good progress on getting
distortions to look better on a sphere. It's not perfect yet, but getting
close. Perhaps I just need to do a little more research on different
projections and more trial and error.
Here's what I've done so far:
#Create mml file with Mollwide projection specifed in <Map>:
<?xml version="1.0" encoding="utf-8"?>
<Map srs="+proj=moll +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84
+units=m +no_defs">
<Stylesheet><![CDATA[
*
{
map-bgcolor: #69f;
}
#world-borders
{
/*line-width: 1;
line-color: #696;*/
polygon-fill: #6f9;
}
#world-borders NAME
{
text-face-name: "DejaVu Sans Book";
text-size: 24;
text-fill: #000;
text-halo-fill: #9ff;
text-halo-radius: 2;
text-placement: point;
text-wrap-width: 50;
text-avoid-edges: true;
}
#world-outline
{
line-width: 10;
line-color: #696;
}
]]></Stylesheet>
<Layer id="world-outline" srs="+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
+wktext +no_defs +over">
<Datasource>
<Parameter name="type">shape</Parameter>
<Parameter name="file">sample_data/world_merc.shp</Parameter>
</Datasource>
</Layer>
<Layer id="world-borders" srs="+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
+wktext +no_defs +over">
<Datasource>
<Parameter name="type">shape</Parameter>
<Parameter name="file">sample_data/world_merc.shp</Parameter>
</Datasource>
</Layer>
</Map>
#create XML
cascadenik-compile.py shapeTest.mml shapeTest.xml
#create Mollwide projection:
nik2img.py shapeTest.xml shapeTest.tif -d 4096 2048 --bbox -180.0 -90.0
180.0 90.0
http://www.flickr.com/photos/8139783@N08/9319568407/
#reproject as EPSG:4326
gdalwarp -s_srs '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84
+datum=WGS84 +units=m +no_defs' -t_srs EPSG:4326 -te -180.0 -90.0 180.0
90.0 -ts 4096 2048 -overwrite shapeTest.tif shapeTestOut.tif
http://www.flickr.com/photos/8139783@N08/9319567933/in/photostream/
#3D render previews:
http://www.flickr.com/photos/8139783@N08/9322359900/in/photostream/
http://www.flickr.com/photos/8139783@N08/9322359828/in/photostream/ (lines
and text a touch thicker near the poles, labels a touch skewed? - so close!)
*Update as I write:*
I can guess that the text is getting skewed due to the stretching from one
projection to the other (more stretching towards the right and left edges).
I imagine that I'll need to calculate and place text separately. Science On
a Sphere allows text to be placed via an accompanying dataset text file as
well. Also, if I make the map outlines, "inlines", things seem to stay less
stretched near the poles.
http://www.flickr.com/photos/8139783@N08/9323320848/ (lines may appear
deceiving as I thinned them out a bit compared to above links)
Thanks again for the feedback. Any additional ideas are welcome as I
research more.
Best regards,
Chris
On Thu, Jul 18, 2013 at 2:12 AM, Martin Raifer <tyr.asd at gmail.com> wrote:
> Hi!
>
> Just a wild guess (didn't try), but what if you rendered your map in an
> equal area projection (e.g. Mollweide) and reprojected the resulting raster
> image - in a second step - to equirectangular (for example using GDAL)?
> That could result in something more towards your objective...
>
> Cheers,
> Martin
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20130719/f8a4cbf9/attachment.html>
More information about the dev
mailing list