Created
July 30, 2012 15:33
-
-
Save dandye/3207829 to your computer and use it in GitHub Desktop.
quick python script to test mapnik rendering of gdal datasource
This file contains 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
[ec2-user@ip-10-195-227-243 ~]$ python | |
Python 2.7.3 (default, Apr 30 2012, 21:18:10) | |
[GCC 4.7.0 20120416 (Red Hat 4.7.0-2)] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> from mapnik import * | |
m = Map(400,500,'+proj=latlong +datum=WGS84') | |
m.background = Color('transparent') | |
s = Style() | |
r = Rule() | |
r.symbols.append(RasterSymbolizer()) | |
s.rules.append(r) | |
m.append_style('My Style',s) | |
lyr = Layer('world') | |
lyr.datasource = Gdal(file='/home/ec2-user/329612o.tif') | |
lyr.styles.append('My Style') | |
m.layers.append(lyr) | |
m.zoom_to_box(lyr.envelope()) | |
render_to_file(m, '/home/ec2-user/test.png') | |
save_map(m, 'test.xml')>>> m = Map(400,500,'+proj=latlong +datum=WGS84') | |
>>> | |
>>> m.background = Color('transparent') | |
>>> s = Style() | |
>>> r = Rule() | |
>>> r.symbols.append(RasterSymbolizer()) | |
>>> s.rules.append(r) | |
>>> m.append_style('My Style',s) | |
True | |
>>> lyr = Layer('world') | |
>>> lyr.datasource = Gdal(file='/home/ec2-user/329612o.tif') | |
>>> lyr.styles.append('My Style') | |
>>> m.layers.append(lyr) | |
>>> | |
>>> m.zoom_to_box(lyr.envelope()) | |
>>> render_to_file(m, '/home/ec2-user/test.png') | |
>>> save_map(m, 'test.xml') | |
>>> exit() | |
[ec2-user@ip-10-195-227-243 ~]$ ls -l test.png | |
-rw-rw-r--. 1 ec2-user ec2-user 52499 Jul 30 11:31 test.png | |
[ec2-user@ip-10-195-227-243 ~]$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment