Opened 8 years ago

Closed 8 years ago

#1751 closed defect (fixed)

Mapnik python demo error

Reported by: darkblueb Owned by: live-demo@…
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:1 by darkblueb, 8 years ago

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?

  • looking in the build 196 log, install_osm.sh shows:
    Get:80 http://ppa.launchpad.net/osgeolive/nightly/ubuntu xenial/main amd64 python-mapnik amd64 1:0.0~20160531-f65767a-1~xenial0 [635 kB]
    
  • python -v and import mapnik shows the full paths of all components loaded
    ...
    import mapnik._mapnik # dynamically loaded from /usr/lib/python2.7/dist-packages/mapnik/_mapnik.x86_64-linux-gnu.so
    ...
    

but, where does the _mapnik get built ? logs for that ?

Last edited 8 years ago by darkblueb (previous) (diff)

comment:2 by Bas Couwenberg, 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.

Last edited 8 years ago by Bas Couwenberg (previous) (diff)

comment:3 by Bas Couwenberg, 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 Bas Couwenberg, 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)

comment:5 by darkblueb, 8 years ago

comment:6 by Bas Couwenberg, 8 years ago

Resolution: fixed
Status: newclosed

Confirmed fixed in RC1.

Note: See TracTickets for help on using tickets.