2

I am trying to create a Mapnik layer based on a PostGIS table, and I keep getting an error message when trying to load the layer

Postgis Plugin: ERROR: relation "public.myTable" does not exist ...

. This is my first time working with PostGIS and I've gotten Mapnik working with other layer types, but I was wanting to experiment with the possibility of using PostGIS.

I created the table I'm trying to use with QGIS, and I can see the table inside of QGIS in the database manager and through psql.

This is what my layer definition looks like in Mapnik

  <Layer name="myLayer" srs="+init=epsg:4326">
    <StyleName>My Style</StyleName>
    <Datasource>
      <Parameter name="type">postgis</Parameter>
      <Parameter name="host">localhost</Parameter>
      <Parameter name="dbname">postgis</Parameter>
      <Parameter name="user">postgres</Parameter>
      <Parameter name="password">[password]</Parameter>
      <Parameter name="table">public.myTable</Parameter>
      <Parameter name="estimate_extent">true</Parameter>
    </Datasource>
  </Layer>

I've tried "public.myTable", "public"."myTable", and myTable. I've tried uppercase, lowercase, and actual case.

Why is Mapnik failing to load this table?

0

I'm not sure what has changed, but apparently this was just a random transient problem... or I wasn't patient enough when trying different table names (it takes about 10 seconds for the map to render, and I may have jumped to the conclusion that it wasn't working before it had a chance to finish)

through my experimentation I have found the following

Values that do work

<Parameter name="table">"MyTable"</Parameter>

<Parameter name="table">"public"."MyTable"</Parameter>

Values that do not work

<Parameter name="table">MyTable</Parameter>

<Parameter name="table">public.MyTable</Parameter>

<Parameter name="table">"public.MyTable"</Parameter>

also I found that the table name is case sensitive, so any variation in capitalization of the values that do work like "Public"."MyTable" or "mytable", do not work.

After I got it to work with just the table name I tried doing a select statement on the table, and I found that quotes are necessary for column names as well, which is odd since that is not shown in the Mapnik documentation. I tried something similar to below

<Parameter name="table">(SELECT geom,someColumn from "public"."MyTable") as table</Parameter>

This did not work and instead I had to do the following

<Parameter name="table">(SELECT "geom","someColumn" from "public"."MyTable") as table</Parameter>

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.