Hi Dan, The reason that your python script works (when it really shouldn't) is that you are setting the map srs to the same projection as the layer srs (+init=epsg:4326 is a lookup to +proj=latlong +datum=WGS84). This causes Mapnik to avoid trying to reproject the geometries to fit the map extent so that they show up even when you zoom the map to the layer's extent despite that these coordinates are in a different projection than EPSG:4326.
Anyway, so the trick here is to make sure to set the layer srs to the right value for the data. In this case I downloaded that shapefile and opened the .prj file and saw it was not in EPSG:4326. Then I took that text and pasted it at http://prj2epsg.org/ to find that it is likely EPSG:2226 (http://prj2epsg.org/epsg/2226). Then I can go to spatialreference.org and find the proj4 string for that epsg: http://spatialreference.org/ref/epsg/2226/proj4/ The other alternative is to reproject the shapefile to your desired/target projection with ogr2ogr like: ogr2ogr -t_srs EPSG:4326 new.shp SOCO_PRMD_City_Limits.shp Dane On Dec 22, 2010, at 3:19 PM, Dan Lyke wrote: > This is probably a stupid newbie question. > > I have the sample BaseWMSFactory subclass from > http://trac.mapnik.org/wiki/OgcServerSvn rendering fine in an > OpenLayers layer using the world_borders.shp that came from somewhere. > > If I replace that with the SOCO_PRMD_City_Limits.shp downloaded from > the "City Limits" data set on > http://www.sonoma-county.org/prmd/gisdata/data_download.htm > I get absolutely nothing. This is with that sample code, replacing the > poly and line definitions with: > > poly = PolygonSymbolizer(Color('yellow')) > line = LineSymbolizer(Color('red'),.1) > > and setting SHAPEFILE to > '/home/danlyke/code/geo/sonomacounty/City_Limits/SOCO_PRMD_City_Limits.shp' > > However, if I create a map and render_to_file(...) using the > following Python code, I see what I'd expect. Am I doing something > stupid with projections? What else might be going wrong? > > And, yes, I can do this switching nothing other than pointing my > ogcserver.conf to the appropriate map factory, with my JavaScript > OpenLayers definition zoomed into the right area that shows up what I'd > expect with the world borders. > > ---- Python to render the shape file to a file ---- > #!/usr/bin/env python > > from mapnik import * > m = Map(600,600,"+proj=latlong +datum=WGS84") > m.background = Color('grey') > > s = Style() > r=Rule() > r.symbols.append(PolygonSymbolizer(Color('yellow'))) > r.symbols.append(LineSymbolizer(Color('red'),0.1)) > s.rules.append(r) > m.append_style('Layer PAR_PARCELS',s) > > layername = 'PAR_PARCELS' > > lyr = Layer(layername,"+init=epsg:4326") > lyr.datasource = > Shapefile(file='../sonomacounty/City_Limits/SOCO_PRMD_City_Limits.shp') > lyr.styles.append('Layer ' + layername) m.layers.append(lyr) > > m.zoom_to_box(lyr.envelope()) > render_to_file(m,'sonoma.png', 'png') > _______________________________________________ > Mapnik-users mailing list > [email protected] > https://lists.berlios.de/mailman/listinfo/mapnik-users _______________________________________________ Mapnik-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/mapnik-users

