0

I am trying to generate a tile with Mapnik with a GeoJSON. The stylesheet.xml with the part to render the GeoJSON is the following:

<Style name="cities" filter-mode="first">
  <Rule>
    <MarkersSymbolizer width="50" fill="#ff4455" stroke="#881133" allow-overlap="true" ignore-placement="true" />
  </Rule>
</Style>
<Layer name="cities"
  srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
    <StyleName>cities</StyleName>
    <Datasource>
       <Parameter name="file"><![CDATA[/home/uli/projects/tiles/test.geojson]]></Parameter>
       <Parameter name="layer"><![CDATA[OGRGeoJSON]]></Parameter>
       <Parameter name="type"><![CDATA[ogr]]></Parameter>
    </Datasource>
  </Layer>

It does not render the GeoJSON. Also it doesn't throw an error. If I use a shapefile with the same settings (except type and file) it works fine. Any ideas why it is not rendered?

I used TileMill to generate the XML. The GeoJSON is shown properly in TileMill.

The GeoJSON file I used is https://gist.github.com/anonymous/2a140b557716c4237e96.

  • There is not enough data to answer the question. What is in the GeoJSON file? Is the path correct? If you create your project in TileMill, did you try to carto -l project.mml > test.xml and then feed it to Mapnik? Can it be a projection error? – Ilja Zverev Jun 2 '14 at 14:09
  • @IljaZverev, sorry for the late response. I added to the question a sample GeoJSON file. The path is correct. I tried carto -l project.mml > test.xml, it produces the same xml and also there the GeoJSON won't show up. – ustroetz Jun 11 '14 at 11:35
2

Things may be different from when you posted this originally. With current Mapnik versions (3.0.10 for example), this should work:

<Style name="cities" filter-mode="first">
  <Rule>
    <MarkersSymbolizer width="50" fill="#ff4455" stroke="#881133" allow-overlap="true" ignore-placement="true" />
  </Rule>
</Style>
<Layer name="cities"
  srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
    <StyleName>cities</StyleName>
    <Datasource>
       <Parameter name="file">/home/uli/projects/tiles/test.geojson</Parameter>
       <Parameter name="type">geojson</Parameter>
    </Datasource>
</Layer>

Basically, the plugin is now called "geojson", and accepts at most 3 parameters: "file" (required), "type" (required), and "encoding" (defaults to "utf-8").

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.