1

I'm trying to use node-mapnik to rasterize vector data into a transparent image and overlay it onto a basemap.

I'm generating OpenStreetMap basemaps with tile-stitch. That's working well.

I'm then using node-mapnik to read vector data from a geojson file and render to an image. I'm getting the image okay, but the projection is off.

The coordinates are all EPSG:4326, decimal notation, derived from a slippy map. My mapnik xml stylesheet looks like this

<Map background-color='#00000000' srs='+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'>
    <Style name='test style'>
        <Rule><PolygonSymbolizer fill='#bb5acc66' /><LineSymbolizer stroke='#3ea3df66' stroke-width='1' /></Rule>
    </Style>
    <Layer name='test' srs='+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'>
        <StyleName>test style</StyleName>
        <Datasource>
            <Parameter name='type'>geojson</Parameter>
            <Parameter name='file'>test.geojson</Parameter>
        </Datasource>
    </Layer>
</Map>

My geojson looks like this:

{"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -1.182891726493835, 51.630744982473551 ], [ -1.183235049247742, 51.630671725935755 ], [ -1.183497905731201, 51.630445295887 ], [ -1.183481812477112, 51.630258823233 ], [ -1.183358430862427, 51.630108978580999 ], [ -1.183213591575622, 51.630029061230999 ], [ -1.182989378008187, 51.630094380903088 ], [ -1.18303120136261, 51.630212204949991 ], [ -1.183058023452759, 51.630352059655998 ], [ -1.182972192764282, 51.630468604915002 ], [ -1.18278980255127, 51.630571830465001 ], [ -1.182720065116882, 51.630675055780998 ], [ -1.182703971862793, 51.630718343745997 ], [ -1.182891726493835, 51.630744982473551 ] ] ] } },
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -1.181958317756653, 51.630367044063 ], [ -1.182041466236115, 51.630565170758999 ], [ -1.182301640510559, 51.630656741628989 ], [ -1.182315051555634, 51.630578490169995 ], [ -1.18239551782608, 51.630508563219998 ], [ -1.182478666305542, 51.630385358331999 ], [ -1.182626187801361, 51.630297116786998 ], [ -1.182596683502197, 51.63016059179499 ], [ -1.182666420936584, 51.629989102503011 ], [ -1.182325780391693, 51.629940818994001 ], [ -1.182111203670502, 51.629947478791003 ], [ -1.1820387840271, 51.630093994089002 ], [ -1.181958317756653, 51.630367044063 ] ] ] } },
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -1.182666420936584, 51.629989102503011 ], [ -1.18283862812109, 51.630068380938702 ], [ -1.182989378008187, 51.630094380903088 ], [ -1.18303120136261, 51.630212204949991 ], [ -1.183058023452759, 51.630352059655998 ], [ -1.182972192764282, 51.630468604915002 ], [ -1.18278980255127, 51.630571830465001 ], [ -1.182720065116882, 51.630675055780998 ], [ -1.182703971862793, 51.630718343745997 ], [ -1.182395517689429, 51.630700862234136 ], [ -1.182301640510559, 51.630656741628989 ], [ -1.182315051555634, 51.630578490169995 ], [ -1.18239551782608, 51.630508563219998 ], [ -1.182478666305542, 51.630385358331999 ], [ -1.182626187801361, 51.630297116786998 ], [ -1.182596683502197, 51.63016059179499 ], [ -1.182666420936584, 51.629989102503011 ] ] ] } }]}

The data on the slippy map looks like this:

enter image description here

but the mapnik image looks like this:

enter image description here

I'm giving tile-stitch and mapnik the same bounds, and the same image dimensions.

0

It turns out the node mapnik wasn't reprojecting to EPSG:3857, which it uses internally. If I reproject the data before passing it to mapnik then it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.