Postgis vector provider

537 views
Skip to first unread message

Chad Hammond

unread,
Jan 7, 2012, 12:40:24 PM1/7/12
to Tilestache
Hi all,

I have successfully installed tilestache on Windows7 and run
tilestache-server.py - everything worked.

I am now trying to connect to a postgis database by modifying the
tilestache.cfg file. I created a layer called "nycbuildings" in the
tilestache.cfg file and added the connection params for my postgis
table

I ran tilestache-server.py again and opened the preview URL and
expected to see text json output in the browser but instead I am
seeing errors similar to:

"Bad path: "/nycbuildings/". I was expecting something more like "/
example/0/0/0.png"

I think there is something wrong with my tilestache.cfg file - I
pasted the contents below. I would also be interested in seeing text
of a full working version of a tilestache.cfg file that connects to
postgis if someone would post one. Do I need to add a "preview"
section, for example?

Here is my current tilestache.cfg:

{
"cache":
{
"name": "Test",
"path": "/tmp/stache",
"umask": "0000"
},
"layers":
{
"nycbuildings":
{
"provider": {"name": "vector", "driver": "PostgreSQL",
"parameters": {"dbname": "nyc", "user": "postgres",
"password":"xxxxxx",
"table": "nyc_buildings"}}

}
}
}

Thiyagarajan

unread,
Jan 7, 2012, 4:23:35 PM1/7/12
to tiles...@googlegroups.com
just make sure, you have the db file inside the 'Vector' folder of your TileStache.... rest seems okay to me..

-Thanks
Raj

Chad Hammond

unread,
Jan 8, 2012, 4:21:49 PM1/8/12
to Tilestache

Hi Raj -

Thank you for the response.

Are you saying that I need to locate my postgres data directory within
the tilestache vector folder in my python directory structure? I
understand doing this for a file datasource but it seems like an odd
requirement for a database when the connection parameters are
independent of the data folder location.

I do have some additional information on this. I seemed to be using
the incorrect URL - I had to update my URL to "http://127.0.0.1:8080/
nycbuildings/preview.html"

This caused tilestache to serve tiles, however the tiles displayed in
the browser were empty.

As a test, I modified my layer provider properties to an incorrect
postgis password and I received the exact same result as I did with
the correct connection parameters - blank tiles were served to the
browser.

Chad

On Jan 7, 2:23 pm, Thiyagarajan <arthiyagara...@gmail.com> wrote:
> just make sure, you have the db file inside the 'Vector' folder of your
> TileStache.... rest seems okay to me..
>
> -Thanks
> Raj
>

Michal Migurski

unread,
Jan 10, 2012, 3:26:12 AM1/10/12
to tiles...@googlegroups.com
Hi Chad,

Your configuration below looks legitimate to me, and it's not necessary to locate a postgres data directory any particular place with respect to tilestache or python - the postgres process will find it fine. I'm speaking as a linux user, here, but I'm assuming that windows is similar in this regard.

I'm a little confused by the errors you're seeing, though. Do you have access to your error log? Does tilestache-server.py display anything on the command line that indicates it may have been unable to connect to postgres, or didn't find a required module or something?

-mike.

----------------------------------------------------------------
michal migurski- mi...@stamen.com
415.558.1610

Thiyagarajan

unread,
Jan 10, 2012, 10:14:10 AM1/10/12
to tiles...@googlegroups.com
Hi Chad,

sry.. i coudn't reply you sooner.. you are right, database is no way dependent on the pathing.. sry, my mistake.. i was having in my mind that you use some kind if shape files... even I am curious to see what error the tilestache-server.py shows in command line..

-Thanks
Raj

Chad Hammond

unread,
Jan 13, 2012, 12:13:36 AM1/13/12
to Tilestache

I pasted an updated tilestache.cfg file text below. I am now seeing a
whole slew of error messages, but the server at least seems to be
attempting vector output instead of raster. Seems like progress! I am
using python 27 and have started using the Tilestache scripts from the
2.7 folder. The tilestache-server.py runs find and serves tiles with
the original preview tilestache.cfg file

When I run tilestache-server.py initially with my vector
tilestache.cfg I receive a mapnik2 deprecation warning but the server
starts and waits for requests

I then attempt to connect to the preview in browser and this generates
the error messages that I pasted below. The same series of error
messages appear to be generated for each 'tile' request. I think the
key might be at the end in the list of error messages.

Updated tilestache.cfg:

{
"cache":
{
"name": "Test",
"path": "/tmp/stache"

},

"layers":
{
"rtdroutes":
{
"provider": {"name": "vector", "driver": "postgis",
"parameters": {"dbname": "rtd_spatial", "user": "postgres",
"password":"xxxxxxxx",
"table": "busroutes"}},

"preview":
{
"ext": "geojson"
}

}
}

}


error messages:

127.0.0.1 - - [12/Jan/2012 21:49:46] "GET /rtdroutes/
10/166/394.geojson HTTP/1.1
" 500 -
Error on request:
Traceback (most recent call last):
File "D:\Python27\lib\site-packages\werkzeug\serving.py", line 159,
in run_wsg
i
execute(app)
File "D:\Python27\lib\site-packages\werkzeug\serving.py", line 146,
in execute

application_iter = app(environ, start_response)
File "D:\Python27\lib\site-packages\TileStache\__init__.py", line
325, in __ca
ll__
mimetype, content = requestHandler(self.config,
environ['PATH_INFO'], enviro
n['QUERY_STRING'])
File "D:\Python27\lib\site-packages\TileStache\__init__.py", line
231, in requ
estHandler
mimetype, content = getTile(layer, coord, extension)
File "D:\Python27\lib\site-packages\TileStache\__init__.py", line
84, in getTi
le
tile = layer.render(coord, format)
File "D:\Python27\lib\site-packages\TileStache\Core.py", line 300,
in render
tile = provider.renderTile(width, height, srs, coord)
File "D:\Python27\lib\site-packages\TileStache\Vector\__init__.py",
line 506,
in renderTile
layer, ds = _open_layer(self.driver, self.parameters,
self.layer.config.dirp
ath)
File "D:\Python27\lib\site-packages\TileStache\Vector\__init__.py",
line 390,
in _open_layer
datasource = driver.Open(str(source_name))
AttributeError: 'NoneType' object has no attribute 'Open'

djaplat

unread,
Jan 13, 2012, 3:51:57 AM1/13/12
to tiles...@googlegroups.com
I've had the same problem where the ogr postgresql driver wasn't being loaded. Maybe this is the case in your situation. You can try 'ogrinfo --formats' to see if postgresql is available.

Some more information is available here: http://trac.osgeo.org/postgis/wiki/UsersWikiOGR

And this thread might help: http://gis.stackexchange.com/questions/13734/gdal-python-bindings-not-picking-up-ogr-postgresql-driver

Michal Migurski

unread,
Jan 20, 2012, 2:53:59 AM1/20/12
to tiles...@googlegroups.com
Hi Chad,

Apologies for the late response.

Do you have a way of testing the connection to Postgres? I'm looking at the error near the very bottom, and the face that the driver variable is None is telling me that there's something wonky with your gdal installation, like it's missing a Postgres driver. If that's the problem, it's not a bug in Tilestache but is an issue nonetheless. I'm terrible with Windows so I can't offer much besides a guess here.

-mike.

----------------------------------------------------------------
michal migurski- mi...@stamen.com
415.558.1610

Message has been deleted

d.

unread,
Aug 17, 2012, 3:57:21 PM8/17/12
to tiles...@googlegroups.com
Hi Chad, mike and all the others,

on Ubuntu 12.04 I have a very similar problem. I have a running PostGISdb (testet with mapserver reguests and rendering), OGR/GDAL is configurated with PostGIS support (ogrinfo gives me all the infos from the PostGIS tabels like extend, geometry column etc.) and tilestache is installed correctly as the default tilestache.cfg gives me the "official" osm sampel render preview.
Now I have a PostGIS database with a table 'tilestache_line' with the columns 'id' 'name' 'geom'. 'geom' is a geometry of type 'LINESTRING' and has SRID 4326. I have added a testline at 1 1, 4 4 and wanted to see the preview in tilestache but all it gives to me is blank tiles. Connecting to localhost:8080 gives me the "TileStache bellows hello." sign and I dont see any problems in the terminal where i have the tilestache-server.py running.

As mentioned above a when I set the connection parameters to false ones I get the same result: blank white tiles.

Any Ideas?

I was wondering whether I just configures the preview wrong? Wich Srid uses tilestache? How do I get the "center point" in the preview (lat/lon) when I enter the PostGIS data like 'LINESTRING(1 1, 4 4)' (I guess it is lat 1, lon 1, right?). Or is 15 as zoomlevel to high?

Attached ist my config file for tilestache:
{"cache":    {

        "name": "Test",
        "path": "/tmp/stache",
        "umask": "0000"
        },

    "layers":    {
            "test":    {

                "provider":    {
                        "name": "vector",
                        "driver": "PostGIS",
                        "parameters":    {
                                "dbname": "webmap",
                                "user": "XXXX",
                                "password":"XXX",
                                        "table": "tilestache_line"
                                }
                        },
                 "preview":    {
                    "lat": 1,
                    "lon": 1,
                    "zoom": 15,
                    "ext": "jpeg"
                    }

                }
              }

}

thanks!
d.

Todd Albert

unread,
Aug 24, 2012, 3:14:56 PM8/24/12
to tiles...@googlegroups.com
I'm running into similar problems. One thing I see in your configuration, though, is that you're asking for a vector from TileStache, but asking it to supply a .jpeg. Instead, ask for a .geojson or other vector format. See if that helps.

-Todd
Reply all
Reply to author
Forward
0 new messages