Opened 8 years ago
Closed 8 years ago
#1751 closed defect (fixed)
Mapnik python demo error
Reported by: | darkblueb | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | OSGeoLive10.0 |
Component: | OSGeoLive | Keywords: | mapnik, python, jupyter |
Cc: |
Description
build 196; mapnik3 python;
run Jupyter, execute
http://localhost:8883/notebooks/projects/FIONA/fiona-shapely-mapnik.ipynb
ArgumentError Traceback (most recent call last) <ipython-input-7-dd353890fe83> in <module>() 9 rule = mapnik.Rule() 10 ---> 11 line_symbolizer = mapnik.LineSymbolizer(mapnik.Color('green'),0.4) 12 rule.symbols.append(line_symbolizer) 13 ArgumentError: Python argument types in LineSymbolizer.__init__(LineSymbolizer, Color, float) did not match C++ signature: __init__(_object*)
Change History (6)
comment:2 by , 8 years ago
To me it looks like the iPython notebook is still using the old python-mapnik API (from the Mapnik 2.x times, instead of the current Mapnik 3.x API), because it passes two parameters to LineSymbolizer() instead of an object.
Buildlogs for the python-mapnik package in OSGeo-Live are on Launchpad:
https://launchpad.net/~osgeolive/+archive/ubuntu/nightly/+packages?field.name_filter=python-mapnik
Expand the line to show the 'Publishing details', click the 'amd64' link to the build details page which includes a link to the buildlog.
comment:3 by , 8 years ago
Based on the demo code included in Mapnik (demo/python/rundemo.py), the notebook code should probably be rewritten to:
line_symbolizer = mapnik.LineSymbolizer() line_symbolizer.stroke = mapnik.Color('green') line_symbolizer.stroke_width = 0.4 rule.symbols.append(line_symbolizer)
comment:4 by , 8 years ago
Replacing source in the problematic cell with the following works on build 197:
import mapnik BASE_FOLDER = '/home/user/data/north_carolina/shape' c_shapefile = os.path.join(BASE_FOLDER, 'nc_state.shp') m = mapnik.Map(600, 600) layer = mapnik.Layer('contour') layer.datasource = mapnik.Shapefile(file=c_shapefile) style = mapnik.Style() rule = mapnik.Rule() line_symbolizer = mapnik.LineSymbolizer() line_symbolizer.stroke = mapnik.Color('green') line_symbolizer.stroke_width = 0.4 rule.symbols.append(line_symbolizer) m.layers.append(layer) style.rules.append(rule) m.append_style('My Style', style) layer.styles.append('My Style') m.layers.append(layer) m.zoom_all() show_mapnik(m)
this error look like the same sort of error that occurred when the python bindings were out of synch with the mapnik.so. How to verify?
install_osm.sh
shows:python -v
andimport mapnik
shows the full paths of all components loadedbut, where does the _mapnik get built ? logs for that ?