Hello list!!<br><br>I'm using a python dll to create images out from shapefiles. I import a python module and its functions, when I want to use this library, I get a message which tells me the file I want to work with doesn't exist, but it does. I'm running the script from Windows. This is the code:<br>
import mapnik<br>import os,fnmatc<br>file_list = []<br>folders = None<br>for root, folders, files in os.walk( "C:\\" ):<br> for filename in fnmatch.filter(files, '*.shp'):<br> file_list.append(os.path.join(root, filename))<br>
for row, filepath in enumerate(file_list, start=1): <br> (ruta, filename) = os.path.split(filepath) <br> i = archivo[0]+'.png'<br> m = mapnik.Map(800,500,"+proj=latlong +datum=WGS84")<br> m.background = mapnik.Color('#f2eff9')<br>
s = mapnik.Style()<br> r=mapnik.Rule()<br> r.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color('steelblue')))<br> r.symbols.append(mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'),0.1))<br>
s.rules.append(r)<br> m.append_style('My Style',s)<br> lyr = mapnik.Layer('world',"+proj=latlong +datum=WGS84")<br> lyr.datasource = mapnik.Shapefile(base=filepath, file=filepath)<br>
lyr.styles.append('My Style')<br> m.layers.append(lyr)<br> m.zoom_to_box(lyr.envelope())<br> mapnik.render_to_file(m,i, 'png')<br>print "Listo"<br>I get the next error:<br>Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on<br>
win32<br>Type "help", "copyright", "credits" or "license" for more information.<br>>>> import imagen_shp<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br>
File "imagen_shp.py", line 32, in <module><br> lyr.datasource = mapnik.Shapefile(base=filepath, file=filepath)<br> File "C:\mapnik-0.7.1\python\2.6\site-packages\mapnik\__init__.py", line 282,<br>
in Shapefile<br> return CreateDatasource(keywords)<br>RuntimeError: C:\Ưndice.shp/C:\Ưndice does not exist<br>>>><br>I also reviewed the line which causes the error, it's a script from the mapnik library:<br>
def Shapefile(**keywords):<br> """Create a Shapefile Datasource.<br> Required keyword arguments:<br> file -- path to shapefile without extension<br> Optional keyword arguments:<br> base -- path prefix (default None)<br>
encoding -- file encoding (default 'utf-8')<br> >>> from mapnik import Shapefile, Layer<br> >>> shp = Shapefile(base='/home/mapnik/data',file='world_borders') <br> >>> lyr = Layer('Shapefile Layer')<br>
>>> lyr.datasource = shp<br> """<br>keywords['type'] = 'shape'<br> return CreateDatasource(keywords)<br>Does anyone could help me?<br>