I have a problem with Tilestache. I got to set it up correctly (localhost:8080/example/previews.html and osm/preview.html work just fine). But when I want to set it up using GeoJSON or PostGIS it is just giving me blank tiles.
However there are no files created it the tmp/stache directory at all, not even one with 0kb. The user login for postgis is alright, as i can access it from pgAdmin with the same user/password also the tablename is correct. The json file can be rendered correctly in polymaps itself, so no bad file format or something like that.
I am running tilestache on ubuntu 12.04 64bit. I am just wondering why the originial examples work and my basic tests fail.
Any help would be very much appreciated! Thanks! d.
The preview.html page is designed to preview image tiles, but the vector provider returns JSON data tiles. Can you try changing some of the requests below to say ".json" instead of ".png" on the end?
> I have a problem with Tilestache. I got to set it up correctly (localhost:8080/example/previews.html and osm/preview.html work just fine). But when I want to set it up using GeoJSON or PostGIS it is just giving me blank tiles.
> However there are no files created it the tmp/stache directory at all, not even one with 0kb.
> The user login for postgis is alright, as i can access it from pgAdmin with the same user/password also the tablename is correct. The json file can be rendered correctly in polymaps itself, so no bad file format or something like that.
> I am running tilestache on ubuntu 12.04 64bit. I am just wondering why the originial examples work and my basic tests fail.
> Any help would be very much appreciated!
> Thanks!
> d.
----------------------------------------------------------------
michal migurski- m...@stamen.com
415.558.1610
so no error. Is it possible that tilestache is only serving tiles/jsons when I request them via polymaps? Could you maybe post me a example.html for using polymaps with tilestache.vector postgis? a very basic one would probably help.
I am struggling with the same basic setup. I am using polymaps and overlaying a very large vector layer (600,000+ polygons!).
I created a small subset of the polygons and put these into a .json file. This overlays on the map beautifully.
The entire dataset is too large and must be tiled. So I've turned to TileStache.
I've tried this several ways and have yet to find a working solution.
I've used a straight .json file and asked TileStache to tile it. No dice. Not even when using the smaller subset.
I've imported the data into my PostGIS database, but when I try to access the tiles, I am told that TileStache cannot connect to the database using my dbuser/pw. I have checked these settings multiple times. I can access the database using these settings, but TileStache cannot?
Finally, I used TileMill to create a (huge) .mbtiles file. TileStache is able to serve the mbtiles, but it is extremely slow and doesn't show every tile. This method, while it looks ok (not as nice as vectors), it does not suffice since I have data associated with each polygon that I need access to.
Any help on getting TileStache to work with my .json file (GeoJSON format) would be greatly appreciated!
Also, Michal, is there a way to preview your vector layers using a method similar to previe.html?
@ Todd: You got an error message when you tried to enter the PostGIS-DB? The strange thing for me is, that I do not get even though if I am entering the wrong connection parameters.
@ all: I have now created a test-html with polymaps. I also added the "host" paramters to my tilestache.vector - PostGIS provided db. I have still the same results with the preview, which does not wonder me, since tilestache.vescot delivers *.jsons. The test.hml + polymaps code looks like the following
*geojsontest.js:* var po = org.polymaps;
var map = po.map() .container(document.getElementById("map").appendChild(po.svg("svg"))) .zoom(1) .zoomRange([1, 10]) .add(po.interact());
function load(e) { for (var i = 0; i < e.features.length; i++) { var feature = e.features[i]; feature.element.appendChild(po.svg("circle") .appendChild(document.createTextNode(feature.data.id)) .parentNode);
when I have the polymaps po.geojson object configured as a local geojson file, everything works perfectly, when set it up like abothe and try to get out tiles out of tilestache, der is no error in the terminal window i run tilestache in, but firebug gives me the following for each tile:
in specific for one: Response Headers Content-Length5250Content-Typetext/plainDateWed, 22 Aug 2012 18:25:10 GMT ServerWerkzeug/0.8.3 Python/2.7.3 Request Headers Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encodinggzip, deflateAccept-Languageen-us,en;q=0.5Connection keep-aliveHost127.0.0.1:8080Originhttp://localhostReferer http://localhost/polymaps/test/GeoJSON/geojsontest.htmlUser-AgentMozi... (X11; Ubuntu; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1 and polymaps.js says on line 307 req.send(null);
Thats it. No vectors are beeing shown. Btw the SRID of my postgisdb is 4326 - do I maybe have to use 900913? As in another topic somebody wrote that is problem was the unmatching zoomlevels of the tiles and the layers -> how do I get (if that is possbile) the zoomlevel out of a postgis db?
any thoughts on this? I really want to get this going :/
I'll just answer a small part of your question since I'm traveling with limited email access for the moment. Can you paste here your postgres settings in the config file, alongside the psql command you run to connect to the database? If you are comfortable with Python, can you attempt to connect using the psycopg2 library that TileStache uses under the hood? Are you using Mapnik at all, and does it have trouble connecting? It would help to see more information to help troubleshoot the postgres connection.
> I am struggling with the same basic setup. I am using polymaps and overlaying a very large vector layer (600,000+ polygons!).
> I created a small subset of the polygons and put these into a .json file. This overlays on the map beautifully.
> The entire dataset is too large and must be tiled. So I've turned to TileStache.
> I've tried this several ways and have yet to find a working solution.
> I've used a straight .json file and asked TileStache to tile it. No dice. Not even when using the smaller subset.
> I've imported the data into my PostGIS database, but when I try to access the tiles, I am told that TileStache cannot connect to the database using my dbuser/pw. I have checked these settings multiple times. I can access the database using these settings, but TileStache cannot?
> Finally, I used TileMill to create a (huge) .mbtiles file. TileStache is able to serve the mbtiles, but it is extremely slow and doesn't show every tile. This method, while it looks ok (not as nice as vectors), it does not suffice since I have data associated with each polygon that I need access to.
> Any help on getting TileStache to work with my .json file (GeoJSON format) would be greatly appreciated!
> Also, Michal, is there a way to preview your vector layers using a method similar to previe.html?
> Thanks,
> Todd
----------------------------------------------------------------
michal migurski- m...@stamen.com
415.558.1610
Thanks for the reply. Here are my settings in /etc/postgresql/9.1/main/postgresql.conf:*
# ----------------------------- # PostgreSQL configuration file # ----------------------------- # # This file consists of lines of the form: # # name = value # # (The "=" is optional.) Whitespace may be used. Comments are introduced with # "#" anywhere on a line. The complete list of parameter names and allowed # values can be found in the PostgreSQL documentation. # # The commented-out settings shown in this file represent the default values. # Re-commenting a setting is NOT sufficient to revert it to the default value; # you need to reload the server. # # This file is read on server startup and when the server receives a SIGHUP # signal. If you edit the file on a running system, you have to SIGHUP the # server for the changes to take effect, or use "pg_ctl reload". Some # parameters, which are marked below, require a server shutdown and restart to # take effect. # # Any parameter can also be given as a command-line option to the server, e.g., # "postgres -c log_connections=on". Some parameters can be changed at run time # with the "SET" SQL command. # # Memory units: kB = kilobytes Time units: ms = milliseconds # MB = megabytes s = seconds # GB = gigabytes min = minutes # h = hours # d = days
# The default values of these variables are driven from the -D command-line # option or PGDATA environment variable, represented here as ConfigDir.
data_directory = '/var/lib/postgresql/9.1/main' # use data in another directory # (change requires restart) hba_file = '/etc/postgresql/9.1/main/pg_hba.conf' # host-based authentication file # (change requires restart) ident_file = '/etc/postgresql/9.1/main/pg_ident.conf' # ident configuration file # (change requires restart)
# If external_pid_file is not explicitly set, no extra PID file is written. external_pid_file = '/var/run/postgresql/9.1-main.pid' # write an extra PID file # (change requires restart)
#-------------------------------------------------------------------------- ---- # CONNECTIONS AND AUTHENTICATION #-------------------------------------------------------------------------- ----
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on; # comma-separated list of addresses; # defaults to 'localhost', '*' = all # (change requires restart) port = 5432 # (change requires restart) max_connections = 100 # (change requires restart) # Note: Increasing max_connections costs ~400 bytes of shared memory per # connection slot, plus lock space (see max_locks_per_transaction). #superuser_reserved_connections = 3 # (change requires restart) unix_socket_directory = '/var/run/postgresql' # (change requires restart) #unix_socket_group = '' # (change requires restart) #unix_socket_permissions = 0777 # begin with 0 to use octal notation # (change requires restart) #bonjour = off # advertise server via Bonjour # (change requires restart) #bonjour_name = '' # defaults to the computer name # (change requires restart)
# - Security and Authentication -
#authentication_timeout = 1min # 1s-600s ssl = true # (change requires restart) #ssl_ciphers = 'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH' # allowed SSL ciphers # (change requires restart) #ssl_renegotiation_limit = 512MB # amount of data between renegotiations #password_encryption = on #db_user_namespace = off
# Kerberos and GSSAPI #krb_server_keyfile = '' #krb_srvname = 'postgres' # (Kerberos only) #krb_caseins_users = off
# - TCP Keepalives - # see "man 7 tcp" for details
#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; # 0 selects the system default #tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; # 0 selects the system default #tcp_keepalives_count = 0 # TCP_KEEPCNT; # 0 selects the system default
shared_buffers = 24MB # min 128kB # (change requires restart) #temp_buffers = 8MB # min 800kB #max_prepared_transactions = 0 # zero disables the feature # (change requires restart) # Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory # per transaction slot, plus lock space (see max_locks_per_transaction). # It is not advisable to set max_prepared_transactions nonzero unless you # actively intend to use prepared transactions. #work_mem = 1MB # min 64kB #maintenance_work_mem = 16MB # min 1MB #max_stack_depth = 2MB # min 100kB
#wal_level = minimal # minimal, archive, or hot_standby # (change requires restart) #fsync = on # turns forced synchronization on or off #synchronous_commit = on # synchronization level; on, off, or local #wal_sync_method = fsync # the default is the first option # supported by the operating system: # open_datasync # fdatasync (default on Linux) # fsync # fsync_writethrough # open_sync #full_page_writes = on # recover from partial page writes #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers # (change requires restart) #wal_writer_delay = 200ms # 1-10000 milliseconds
#commit_delay = 0 # range 0-100000, in microseconds #commit_siblings = 5 # range 1-1000
# - Checkpoints -
#checkpoint_segments = 3 # in logfile segments, min 1, 16MB each #checkpoint_timeout = 5min # range 30s-1h #checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 #checkpoint_warning = 30s # 0 disables
# - Archiving -
#archive_mode = off # allows archiving to be done # (change requires restart) #archive_command = '' # command to use to archive a logfile segment #archive_timeout = 0 # force a logfile segment switch after this # number of seconds; 0 disables
#max_wal_senders = 0 # max number of walsender processes # (change requires restart) #wal_sender_delay = 1s # walsender cycle time, 1-10000 milliseconds #wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables #vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed #replication_timeout = 60s # in milliseconds; 0 disables #synchronous_standby_names = '' # standby servers that provide sync rep # comma-separated list of application_name # from standby(s); '*' = all
# - Standby Servers -
# These settings are ignored on a master server
#hot_standby = off # "on" allows queries during recovery # (change requires restart) #max_standby_archive_delay = 30s # max delay before canceling queries # when reading WAL from archive; # -1 allows indefinite delay #max_standby_streaming_delay = 30s # max delay before canceling queries # when reading streaming WAL; # -1 allows indefinite delay #wal_receiver_status_interval = 10s # send replies at least this often # 0 disables #hot_standby_feedback = off # send info from standby to prevent # query conflicts
#enable_bitmapscan = on #enable_hashagg = on #enable_hashjoin = on #enable_indexscan = on #enable_material = on #enable_mergejoin = on #enable_nestloop = on #enable_seqscan = on
...
My apache error logs show that there is a problem when I try to use vectors in TileStache. The script is hanging up in TileStache/Vector/__init__.py, line 378, which has the command: driver = ogr.GetDriverByName(str(driver_name))
The error that is returned is that 'ogr' is not defined.
I have no trouble accessing ogr from bash, but I tried within python and ogr is unreachable. The command "from osgeo import ogr" within python yields the error: File "<stdin>", line 1, in <module> ImportError: No module named osgeo
So, apparently, GDAL/OGR is installed properly and python is installed properly, but either the bindings are not installed properly or their is a config-file or path not setup correctly.
Now I got python and postgresql talking. Now I need to get TileStache working. Well, it works… it will serve tiles from direct data sources, but not (yet) the database.
Still no luck on this, Mike. I am able to produce a .geojson tile from a .json source, but still not from my database.
I've assured that everything is properly installed, the database is working, and everything seems to be setup correctly, but… when I request a single tile from the database, I still get a 500 Internal Server Error. A look at the apache error log shows:
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] mod_python (pid=1484, interpreter='localhost', phase='PythonHandler', handler='TileStache::modpythonHandler'): Application error
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] ServerName: 'localhost'
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] DocumentRoot: '/var/www'
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] URI: '/tiles/tiles.py/parcels2/16/18185/27794.geojson'
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Location: None
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Directory: '/var/www/tiles/'
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Filename: '/var/www/tiles/tiles.py'
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] PathInfo: '/parcels2/16/18185/27794.geojson'
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Traceback (most recent call last):
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent)
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg)
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg)
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 462, in modpythonHandler\n mimetype, content = requestHandler(config_path, path_info, query_string)
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 287, in requestHandler\n mimetype, content = getTile(layer, coord, extension)
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 96, in getTile\n tile = layer.render(coord, format)
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Core.py", line 384, in render\n tile = provider.renderTile(width, height, srs, coord)
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Vector/__init__.py", line 561, in renderTile\n layer, ds = _open_layer(self.driver, self.parameters, self.layer.config.dirpath)
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Vector/__init__.py", line 436, in _open_layer\n datasource = driver.Open(str(source_name))
[Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] AttributeError: 'NoneType' object has no attribute 'Open'
If I am defining PostgreSQL as my provider, I am not sure why the script is even executing line 436.
Please, please, please help me out here. I need to get this running by Monday.
On Wednesday, August 22, 2012 5:40:22 PM UTC-4, Michal Migurski wrote:
> Hi Todd,
> I'll just answer a small part of your question since I'm traveling with > limited email access for the moment. Can you paste here your postgres > settings in the config file, alongside the psql command you run to connect > to the database? If you are comfortable with Python, can you attempt to > connect using the psycopg2 library that TileStache uses under the hood? Are > you using Mapnik at all, and does it have trouble connecting? It would help > to see more information to help troubleshoot the postgres connection.
> -mike.
> On Aug 22, 2012, at 5:52 PM, Todd Albert wrote:
> > I am struggling with the same basic setup. I am using polymaps and > overlaying a very large vector layer (600,000+ polygons!).
> > I created a small subset of the polygons and put these into a .json > file. This overlays on the map beautifully.
> > The entire dataset is too large and must be tiled. So I've turned to > TileStache.
> > I've tried this several ways and have yet to find a working solution.
> > I've used a straight .json file and asked TileStache to tile it. No > dice. Not even when using the smaller subset.
> > I've imported the data into my PostGIS database, but when I try to > access the tiles, I am told that TileStache cannot connect to the database > using my dbuser/pw. I have checked these settings multiple times. I can > access the database using these settings, but TileStache cannot?
> > Finally, I used TileMill to create a (huge) .mbtiles file. TileStache is > able to serve the mbtiles, but it is extremely slow and doesn't show every > tile. This method, while it looks ok (not as nice as vectors), it does not > suffice since I have data associated with each polygon that I need access > to.
> > Any help on getting TileStache to work with my .json file (GeoJSON > format) would be greatly appreciated!
> > Also, Michal, is there a way to preview your vector layers using a > method similar to previe.html?
> > Thanks, > > Todd
> ---------------------------------------------------------------- > michal migurski- mi...@stamen.com <javascript:> > 415.558.1610
Gdal wants a string like "PG:dbname='foo' user='blah'" in order to make a connection to the database. What happens if you execute this minimal bit of Python?
> Still no luck on this, Mike. I am able to produce a .geojson tile from a .json source, but still not from my database.
> I've assured that everything is properly installed, the database is working, and everything seems to be setup correctly, but… when I request a single tile from the database, I still get a 500 Internal Server Error. A look at the apache error log shows:
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] mod_python (pid=1484, interpreter='localhost', phase='PythonHandler', handler='TileStache::modpythonHandler'): Application error
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] ServerName: 'localhost'
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] DocumentRoot: '/var/www'
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] URI: '/tiles/tiles.py/parcels2/16/18185/27794.geojson'
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Location: None
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Directory: '/var/www/tiles/'
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Filename: '/var/www/tiles/tiles.py'
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] PathInfo: '/parcels2/16/18185/27794.geojson'
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Traceback (most recent call last):
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent)
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg)
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg)
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 462, in modpythonHandler\n mimetype, content = requestHandler(config_path, path_info, query_string)
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 287, in requestHandler\n mimetype, content = getTile(layer, coord, extension)
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 96, in getTile\n tile = layer.render(coord, format)
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Core.py", line 384, in render\n tile = provider.renderTile(width, height, srs, coord)
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Vector/__init__.py", line 561, in renderTile\n layer, ds = _open_layer(self.driver, self.parameters, self.layer.config.dirpath)
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Vector/__init__.py", line 436, in _open_layer\n datasource = driver.Open(str(source_name))
> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] AttributeError: 'NoneType' object has no attribute 'Open'
> If I am defining PostgreSQL as my provider, I am not sure why the script is even executing line 436.
> Please, please, please help me out here. I need to get this running by Monday.
> Desperately,
> Todd
> On Wednesday, August 22, 2012 5:40:22 PM UTC-4, Michal Migurski wrote:
> Hi Todd,
> I'll just answer a small part of your question since I'm traveling with limited email access for the moment. Can you paste here your postgres settings in the config file, alongside the psql command you run to connect to the database? If you are comfortable with Python, can you attempt to connect using the psycopg2 library that TileStache uses under the hood? Are you using Mapnik at all, and does it have trouble connecting? It would help to see more information to help troubleshoot the postgres connection.
> -mike.
> On Aug 22, 2012, at 5:52 PM, Todd Albert wrote:
> > I am struggling with the same basic setup. I am using polymaps and overlaying a very large vector layer (600,000+ polygons!).
> > I created a small subset of the polygons and put these into a .json file. This overlays on the map beautifully.
> > The entire dataset is too large and must be tiled. So I've turned to TileStache.
> > I've tried this several ways and have yet to find a working solution.
> > I've used a straight .json file and asked TileStache to tile it. No dice. Not even when using the smaller subset.
> > I've imported the data into my PostGIS database, but when I try to access the tiles, I am told that TileStache cannot connect to the database using my dbuser/pw. I have checked these settings multiple times. I can access the database using these settings, but TileStache cannot?
> > Finally, I used TileMill to create a (huge) .mbtiles file. TileStache is able to serve the mbtiles, but it is extremely slow and doesn't show every tile. This method, while it looks ok (not as nice as vectors), it does not suffice since I have data associated with each polygon that I need access to.
> > Any help on getting TileStache to work with my .json file (GeoJSON format) would be greatly appreciated!
> > Also, Michal, is there a way to preview your vector layers using a method similar to previe.html?
> > Thanks, > > Todd
> ---------------------------------------------------------------- > michal migurski- mi...@stamen.com > 415.558.1610
----------------------------------------------------------------
michal migurski- m...@stamen.com
415.558.1610
I tried executing ogrinfo PG:"dbname:'gis' user:'gisuser'"
(or whatever the proper command is - I'm on my phone at the moment) from bash and it failed because OGR was not installed with the PG driver.
So, I rebuilt GDAL with Python, Geos, and PostgreSQL, all configured properly (I think), and reinstalled. I also reinstalled PostgreSQL and PostGIS.
Still no dice. Still no driver.
So, it's obviously not a TileStache bug. It's that I can't seem to get GDAL/OGR installed with the required PG driver.
Any thoughts or suggestions?
Thanks,
Todd
P.S. safe travels!
On Aug 25, 2012, at 7:33 AM, Michal Migurski <m...@stamen.com> wrote:
> Gdal wants a string like "PG:dbname='foo' user='blah'" in order to make a connection to the database. What happens if you execute this minimal bit of Python?
> I'm still traveling, but I'll be on email later tonight (UK time).
> -mike.
> On Aug 24, 2012, at 6:44 PM, Todd Albert wrote:
>> Still no luck on this, Mike. I am able to produce a .geojson tile from a .json source, but still not from my database.
>> I've assured that everything is properly installed, the database is working, and everything seems to be setup correctly, but… when I request a single tile from the database, I still get a 500 Internal Server Error. A look at the apache error log shows:
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] mod_python (pid=1484, interpreter='localhost', phase='PythonHandler', handler='TileStache::modpythonHandler'): Application error
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] ServerName: 'localhost'
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] DocumentRoot: '/var/www'
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] URI: '/tiles/tiles.py/parcels2/16/18185/27794.geojson'
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Location: None
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Directory: '/var/www/tiles/'
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Filename: '/var/www/tiles/tiles.py'
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] PathInfo: '/parcels2/16/18185/27794.geojson'
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Traceback (most recent call last):
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent)
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg)
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg)
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 462, in modpythonHandler\n mimetype, content = requestHandler(config_path, path_info, query_string)
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 287, in requestHandler\n mimetype, content = getTile(layer, coord, extension)
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 96, in getTile\n tile = layer.render(coord, format)
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Core.py", line 384, in render\n tile = provider.renderTile(width, height, srs, coord)
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Vector/__init__.py", line 561, in renderTile\n layer, ds = _open_layer(self.driver, self.parameters, self.layer.config.dirpath)
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Vector/__init__.py", line 436, in _open_layer\n datasource = driver.Open(str(source_name))
>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] AttributeError: 'NoneType' object has no attribute 'Open'
>> If I am defining PostgreSQL as my provider, I am not sure why the script is even executing line 436.
>> Please, please, please help me out here. I need to get this running by Monday.
>> Desperately,
>> Todd
>> On Wednesday, August 22, 2012 5:40:22 PM UTC-4, Michal Migurski wrote:
>> Hi Todd,
>> I'll just answer a small part of your question since I'm traveling with limited email access for the moment. Can you paste here your postgres settings in the config file, alongside the psql command you run to connect to the database? If you are comfortable with Python, can you attempt to connect using the psycopg2 library that TileStache uses under the hood? Are you using Mapnik at all, and does it have trouble connecting? It would help to see more information to help troubleshoot the postgres connection.
>> -mike.
>> On Aug 22, 2012, at 5:52 PM, Todd Albert wrote:
>>> I am struggling with the same basic setup. I am using polymaps and overlaying a very large vector layer (600,000+ polygons!).
>>> I created a small subset of the polygons and put these into a .json file. This overlays on the map beautifully.
>>> The entire dataset is too large and must be tiled. So I've turned to TileStache.
>>> I've tried this several ways and have yet to find a working solution.
>>> I've used a straight .json file and asked TileStache to tile it. No dice. Not even when using the smaller subset.
>>> I've imported the data into my PostGIS database, but when I try to access the tiles, I am told that TileStache cannot connect to the database using my dbuser/pw. I have checked these settings multiple times. I can access the database using these settings, but TileStache cannot?
>>> Finally, I used TileMill to create a (huge) .mbtiles file. TileStache is able to serve the mbtiles, but it is extremely slow and doesn't show every tile. This method, while it looks ok (not as nice as vectors), it does not suffice since I have data associated with each polygon that I need access to.
>>> Any help on getting TileStache to work with my .json file (GeoJSON format) would be greatly appreciated!
>>> Also, Michal, is there a way to preview your vector layers using a method similar to previe.html?
>>> Thanks, >>> Todd
>> ---------------------------------------------------------------- >> michal migurski- mi...@stamen.com >> 415.558.1610
> ----------------------------------------------------------------
> michal migurski- m...@stamen.com
> 415.558.1610
My experience with Postgis 2.0 is very limited, and I can see that the instructions you followed include postgres in the gdal build step. Did you see any errors go by when you did that, about missing postgres-anything?
Maybe a more blunt question: do you actually need postgis 2.0, or would it be enough to use the older postgis 1.5 which is well-supported in Ubuntu package managers? I've only installed Postgis 2.0 once myself, and I remember it being a multiple-hours-long affair that I only put myself through because I needed the offset curves function. Maybe you can get by without it?
I'll fire up a 12.04 machine and try to retrace your steps.
> I tried executing ogrinfo PG:"dbname:'gis' user:'gisuser'"
> (or whatever the proper command is - I'm on my phone at the moment) from bash and it failed because OGR was not installed with the PG driver.
> So, I rebuilt GDAL with Python, Geos, and PostgreSQL, all configured properly (I think), and reinstalled. I also reinstalled PostgreSQL and PostGIS.
> Still no dice. Still no driver.
> So, it's obviously not a TileStache bug. It's that I can't seem to get GDAL/OGR installed with the required PG driver.
> Any thoughts or suggestions?
> Thanks,
> Todd
> P.S. safe travels!
> On Aug 25, 2012, at 7:33 AM, Michal Migurski <m...@stamen.com> wrote:
>> Gdal wants a string like "PG:dbname='foo' user='blah'" in order to make a connection to the database. What happens if you execute this minimal bit of Python?
>> I'm still traveling, but I'll be on email later tonight (UK time).
>> -mike.
>> On Aug 24, 2012, at 6:44 PM, Todd Albert wrote:
>>> Still no luck on this, Mike. I am able to produce a .geojson tile from a .json source, but still not from my database.
>>> I've assured that everything is properly installed, the database is working, and everything seems to be setup correctly, but… when I request a single tile from the database, I still get a 500 Internal Server Error. A look at the apache error log shows:
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] mod_python (pid=1484, interpreter='localhost', phase='PythonHandler', handler='TileStache::modpythonHandler'): Application error
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] ServerName: 'localhost'
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] DocumentRoot: '/var/www'
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] URI: '/tiles/tiles.py/parcels2/16/18185/27794.geojson'
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Location: None
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Directory: '/var/www/tiles/'
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Filename: '/var/www/tiles/tiles.py'
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] PathInfo: '/parcels2/16/18185/27794.geojson'
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Traceback (most recent call last):
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent)
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg)
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg)
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 462, in modpythonHandler\n mimetype, content = requestHandler(config_path, path_info, query_string)
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 287, in requestHandler\n mimetype, content = getTile(layer, coord, extension)
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 96, in getTile\n tile = layer.render(coord, format)
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Core.py", line 384, in render\n tile = provider.renderTile(width, height, srs, coord)
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Vector/__init__.py", line 561, in renderTile\n layer, ds = _open_layer(self.driver, self.parameters, self.layer.config.dirpath)
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Vector/__init__.py", line 436, in _open_layer\n datasource = driver.Open(str(source_name))
>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] AttributeError: 'NoneType' object has no attribute 'Open'
>>> If I am defining PostgreSQL as my provider, I am not sure why the script is even executing line 436.
>>> Please, please, please help me out here. I need to get this running by Monday.
>>> Desperately,
>>> Todd
>>> On Wednesday, August 22, 2012 5:40:22 PM UTC-4, Michal Migurski wrote:
>>> Hi Todd,
>>> I'll just answer a small part of your question since I'm traveling with limited email access for the moment. Can you paste here your postgres settings in the config file, alongside the psql command you run to connect to the database? If you are comfortable with Python, can you attempt to connect using the psycopg2 library that TileStache uses under the hood? Are you using Mapnik at all, and does it have trouble connecting? It would help to see more information to help troubleshoot the postgres connection.
>>> -mike.
>>> On Aug 22, 2012, at 5:52 PM, Todd Albert wrote:
>>>> I am struggling with the same basic setup. I am using polymaps and overlaying a very large vector layer (600,000+ polygons!).
>>>> I created a small subset of the polygons and put these into a .json file. This overlays on the map beautifully.
>>>> The entire dataset is too large and must be tiled. So I've turned to TileStache.
>>>> I've tried this several ways and have yet to find a working solution.
>>>> I've used a straight .json file and asked TileStache to tile it. No dice. Not even when using the smaller subset.
>>>> I've imported the data into my PostGIS database, but when I try to access the tiles, I am told that TileStache cannot connect to the database using my dbuser/pw. I have checked these settings multiple times. I can access the database using these settings, but TileStache cannot?
>>>> Finally, I used TileMill to create a (huge) .mbtiles file. TileStache is able to serve the mbtiles, but it is extremely slow and doesn't show every tile. This method, while it looks ok (not as nice as vectors), it does not suffice since I have data associated with each polygon that I need access to.
>>>> Any help on getting TileStache to work with my .json file (GeoJSON format) would be greatly appreciated!
>>>> Also, Michal, is there a way to preview your vector layers using a method similar to previe.html?
>>>> Thanks, >>>> Todd
>>> ---------------------------------------------------------------- >>> michal migurski- mi...@stamen.com >>> 415.558.1610
>> ----------------------------------------------------------------
>> michal migurski- m...@stamen.com
>> 415.558.1610
----------------------------------------------------------------
michal migurski- m...@stamen.com
415.558.1610
I followed George MacKerron's instructions on a clean Ubuntu 12.04 install, with some minor differences:
- I have skipped PostGIS 2.0 since it's not really the part I'm testing
- I modified /etc/postgresql/9.1/main/pg_hba.conf, to set all methods to "trust" (so passwords, etc. wouldn't be needed)
...and this works:
from sys import path
path.append('/opt/gdal/lib/python2.7/site-packages') # needed due to /opt prefix from build
from osgeo import ogr
driver = ogr.GetDriverByName('PostgreSQL')
src_name = "PG:dbname='postgres' user='postgres'"
datasource = driver.Open(src_name)
assert datasource
So I've at least gotten a working PG driver this way. Does the sys.path line above look like something you've done as well? Might you be importing from the wrong osgeo package? What about the edit to pg_hba.conf? I typically set everything to "trust" when I work with Postgres on my own systems, might that be an important difference?
-mike.
On Aug 25, 2012, at 6:21 PM, Michal Migurski wrote:
> My experience with Postgis 2.0 is very limited, and I can see that the instructions you followed include postgres in the gdal build step. Did you see any errors go by when you did that, about missing postgres-anything?
> Maybe a more blunt question: do you actually need postgis 2.0, or would it be enough to use the older postgis 1.5 which is well-supported in Ubuntu package managers? I've only installed Postgis 2.0 once myself, and I remember it being a multiple-hours-long affair that I only put myself through because I needed the offset curves function. Maybe you can get by without it?
> I'll fire up a 12.04 machine and try to retrace your steps.
> -mike.
> On Aug 25, 2012, at 3:10 PM, Todd Albert wrote:
>> Mike,
>> I tried executing ogrinfo PG:"dbname:'gis' user:'gisuser'"
>> (or whatever the proper command is - I'm on my phone at the moment) from bash and it failed because OGR was not installed with the PG driver.
>> So, I rebuilt GDAL with Python, Geos, and PostgreSQL, all configured properly (I think), and reinstalled. I also reinstalled PostgreSQL and PostGIS.
>> Still no dice. Still no driver.
>> So, it's obviously not a TileStache bug. It's that I can't seem to get GDAL/OGR installed with the required PG driver.
>> Any thoughts or suggestions?
>> Thanks,
>> Todd
>> P.S. safe travels!
>> On Aug 25, 2012, at 7:33 AM, Michal Migurski <m...@stamen.com> wrote:
>>> Gdal wants a string like "PG:dbname='foo' user='blah'" in order to make a connection to the database. What happens if you execute this minimal bit of Python?
>>> I'm still traveling, but I'll be on email later tonight (UK time).
>>> -mike.
>>> On Aug 24, 2012, at 6:44 PM, Todd Albert wrote:
>>>> Still no luck on this, Mike. I am able to produce a .geojson tile from a .json source, but still not from my database.
>>>> I've assured that everything is properly installed, the database is working, and everything seems to be setup correctly, but… when I request a single tile from the database, I still get a 500 Internal Server Error. A look at the apache error log shows:
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] mod_python (pid=1484, interpreter='localhost', phase='PythonHandler', handler='TileStache::modpythonHandler'): Application error
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] ServerName: 'localhost'
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] DocumentRoot: '/var/www'
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] URI: '/tiles/tiles.py/parcels2/16/18185/27794.geojson'
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Location: None
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Directory: '/var/www/tiles/'
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Filename: '/var/www/tiles/tiles.py'
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] PathInfo: '/parcels2/16/18185/27794.geojson'
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Traceback (most recent call last):
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent)
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg)
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg)
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 462, in modpythonHandler\n mimetype, content = requestHandler(config_path, path_info, query_string)
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 287, in requestHandler\n mimetype, content = getTile(layer, coord, extension)
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 96, in getTile\n tile = layer.render(coord, format)
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Core.py", line 384, in render\n tile = provider.renderTile(width, height, srs, coord)
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Vector/__init__.py", line 561, in renderTile\n layer, ds = _open_layer(self.driver, self.parameters, self.layer.config.dirpath)
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Vector/__init__.py", line 436, in _open_layer\n datasource = driver.Open(str(source_name))
>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] AttributeError: 'NoneType' object has no attribute 'Open'
>>>> If I am defining PostgreSQL as my provider, I am not sure why the script is even executing line 436.
>>>> Please, please, please help me out here. I need to get this running by Monday.
>>>> Desperately,
>>>> Todd
>>>> On Wednesday, August 22, 2012 5:40:22 PM UTC-4, Michal Migurski wrote:
>>>> Hi Todd,
>>>> I'll just answer a small part of your question since I'm traveling with limited email access for the moment. Can you paste here your postgres settings in the config file, alongside the psql command you run to connect to the database? If you are comfortable with Python, can you attempt to connect using the psycopg2 library that TileStache uses under the hood? Are you using Mapnik at all, and does it have trouble connecting? It would help to see more information to help troubleshoot the postgres connection.
>>>> -mike.
>>>> On Aug 22, 2012, at 5:52 PM, Todd Albert wrote:
>>>>> I am struggling with the same basic setup. I am using polymaps and overlaying a very large vector layer (600,000+ polygons!).
>>>>> I created a small subset of the polygons and put these into a .json file. This overlays on the map beautifully.
>>>>> The entire dataset is too large and must be tiled. So I've turned to TileStache.
>>>>> I've tried this several ways and have yet to find a working solution.
>>>>> I've used a straight .json file and asked TileStache to tile it. No dice. Not even when using the smaller subset.
>>>>> I've imported the data into my PostGIS database, but when I try to access the tiles, I am told that TileStache cannot connect to the database using my dbuser/pw. I have checked these settings multiple times. I can access the database using these settings, but TileStache cannot?
>>>>> Finally, I used TileMill to create a (huge) .mbtiles file. TileStache is able to serve the mbtiles, but it is extremely slow and doesn't show every tile. This method, while it looks ok (not as nice as vectors), it does not suffice since I have data associated with each polygon that I need access to.
>>>>> Any help on getting TileStache to work with my .json file (GeoJSON format) would be greatly appreciated!
>>>>> Also, Michal, is there a way to preview your vector layers using a method similar to previe.html?
>>>>> Thanks, >>>>> Todd
>>>> ---------------------------------------------------------------- >>>> michal migurski- mi...@stamen.com >>>> 415.558.1610
>>> ----------------------------------------------------------------
>>> michal migurski- m...@stamen.com
>>> 415.558.1610
> ----------------------------------------------------------------
> michal migurski- m...@stamen.com
> 415.558.1610
----------------------------------------------------------------
michal migurski- m...@stamen.com
415.558.1610
I tried George MacKerron's instructions again, but without the prefix to simplify things. I skipped PostGIS. I will probably need it later on, but I don't think I need 2.0 for any reason.
I got everything installed and then ran, line-by-line in Python:
I assume this means that PostgreSQL is not a valid driver.
So I don't think this solved the problem.
I even tried the "from sys import path" line first.
I did edit pg_hba.conf to set everything to trust.
I don't think I am importing from the wrong osgeo package, because before I rebuilt it, the line "from osgeo import ogr" wasn't working. And I uninstalled the package before rebuilding it.
At bash, the command ogrinfo -- formats does not list a PG, PostgreSQL, or PostGIS driver. The closest thing I see is DXF or PGDump. So I am back to thinking that even though I am configuring gdal with PostgreSQL (--with-pg=/usr/lib/postgresql/9.1/bin/pg_config), it doesn't seem to be installing that driver. Ugh!
So I'm still stuck here… but I feel like I am SO close!! Any other ideas??
Thanks so much for all of the help!!
-Todd
On Aug 25, 2012, at 1:53 PM, Michal Migurski <m...@stamen.com> wrote:
> I followed George MacKerron's instructions on a clean Ubuntu 12.04 install, with some minor differences:
> - I have skipped PostGIS 2.0 since it's not really the part I'm testing
> - I modified /etc/postgresql/9.1/main/pg_hba.conf, to set all methods to "trust" (so passwords, etc. wouldn't be needed)
> ...and this works:
> from sys import path
> path.append('/opt/gdal/lib/python2.7/site-packages') # needed due to /opt prefix from build
> from osgeo import ogr
> driver = ogr.GetDriverByName('PostgreSQL')
> src_name = "PG:dbname='postgres' user='postgres'"
> datasource = driver.Open(src_name)
> assert datasource
> So I've at least gotten a working PG driver this way. Does the sys.path line above look like something you've done as well? Might you be importing from the wrong osgeo package? What about the edit to pg_hba.conf? I typically set everything to "trust" when I work with Postgres on my own systems, might that be an important difference?
> -mike.
> On Aug 25, 2012, at 6:21 PM, Michal Migurski wrote:
>> My experience with Postgis 2.0 is very limited, and I can see that the instructions you followed include postgres in the gdal build step. Did you see any errors go by when you did that, about missing postgres-anything?
>> Maybe a more blunt question: do you actually need postgis 2.0, or would it be enough to use the older postgis 1.5 which is well-supported in Ubuntu package managers? I've only installed Postgis 2.0 once myself, and I remember it being a multiple-hours-long affair that I only put myself through because I needed the offset curves function. Maybe you can get by without it?
>> I'll fire up a 12.04 machine and try to retrace your steps.
>> -mike.
>> On Aug 25, 2012, at 3:10 PM, Todd Albert wrote:
>>> Mike,
>>> I tried executing ogrinfo PG:"dbname:'gis' user:'gisuser'"
>>> (or whatever the proper command is - I'm on my phone at the moment) from bash and it failed because OGR was not installed with the PG driver.
>>> So, I rebuilt GDAL with Python, Geos, and PostgreSQL, all configured properly (I think), and reinstalled. I also reinstalled PostgreSQL and PostGIS.
>>> Still no dice. Still no driver.
>>> So, it's obviously not a TileStache bug. It's that I can't seem to get GDAL/OGR installed with the required PG driver.
>>> Any thoughts or suggestions?
>>> Thanks,
>>> Todd
>>> P.S. safe travels!
>>> On Aug 25, 2012, at 7:33 AM, Michal Migurski <m...@stamen.com> wrote:
>>>> Gdal wants a string like "PG:dbname='foo' user='blah'" in order to make a connection to the database. What happens if you execute this minimal bit of Python?
>>>> I'm still traveling, but I'll be on email later tonight (UK time).
>>>> -mike.
>>>> On Aug 24, 2012, at 6:44 PM, Todd Albert wrote:
>>>>> Still no luck on this, Mike. I am able to produce a .geojson tile from a .json source, but still not from my database.
>>>>> I've assured that everything is properly installed, the database is working, and everything seems to be setup correctly, but… when I request a single tile from the database, I still get a 500 Internal Server Error. A look at the apache error log shows:
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] mod_python (pid=1484, interpreter='localhost', phase='PythonHandler', handler='TileStache::modpythonHandler'): Application error
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] ServerName: 'localhost'
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] DocumentRoot: '/var/www'
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] URI: '/tiles/tiles.py/parcels2/16/18185/27794.geojson'
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Location: None
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Directory: '/var/www/tiles/'
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Filename: '/var/www/tiles/tiles.py'
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] PathInfo: '/parcels2/16/18185/27794.geojson'
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] Traceback (most recent call last):
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent)
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg)
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg)
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 462, in modpythonHandler\n mimetype, content = requestHandler(config_path, path_info, query_string)
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 287, in requestHandler\n mimetype, content = getTile(layer, coord, extension)
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/__init__.py", line 96, in getTile\n tile = layer.render(coord, format)
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Core.py", line 384, in render\n tile = provider.renderTile(width, height, srs, coord)
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Vector/__init__.py", line 561, in renderTile\n layer, ds = _open_layer(self.driver, self.parameters, self.layer.config.dirpath)
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] File "/usr/local/lib/python2.7/dist-packages/TileStache/Vector/__init__.py", line 436, in _open_layer\n datasource = driver.Open(str(source_name))
>>>>> [Fri Aug 24 10:21:11 2012] [error] [client 192.168.37.1] AttributeError: 'NoneType' object has no attribute 'Open'
>>>>> If I am defining PostgreSQL as my provider, I am not sure why the script is even executing line 436.
>>>>> Please, please, please help me out here. I need to get this running by Monday.
>>>>> Desperately,
>>>>> Todd
>>>>> On Wednesday, August 22, 2012 5:40:22 PM UTC-4, Michal Migurski wrote:
>>>>> Hi Todd,
>>>>> I'll just answer a small part of your question since I'm traveling with limited email access for the moment. Can you paste here your postgres settings in the config file, alongside the psql command you run to connect to the database? If you are comfortable with Python, can you attempt to connect using the psycopg2 library that TileStache uses under the hood? Are you using Mapnik at all, and does it have trouble connecting? It would help to see more information to help troubleshoot the postgres connection.
>>>>> -mike.
>>>>> On Aug 22, 2012, at 5:52 PM, Todd Albert wrote:
>>>>>> I am struggling with the same basic setup. I am using polymaps and overlaying a very large vector layer (600,000+ polygons!).
>>>>>> I created a small subset of the polygons and put these into a .json file. This overlays on the map beautifully.
>>>>>> The entire dataset is too large and must be tiled. So I've turned to TileStache.
>>>>>> I've tried this several ways and have yet to find a working solution.
>>>>>> I've used a straight .json file and asked TileStache to tile it. No
Ok, so far this works (see below). But I have not yet installed mapnik, apache, and tilestache, nor have I imported any data into my database. But the PG driver is installed in OGR and working from Python.
As for the rest, I'll keep you posted…
# from a clean install of Ubuntu-Server
sudo aptitude update
sudo aptitude upgrade
> I tried George MacKerron's instructions again, but without the prefix to simplify things. I skipped PostGIS. I will probably need it later on, but I don't think I need 2.0 for any reason.
> I got everything installed and then ran, line-by-line in Python:
> I assume this means that PostgreSQL is not a valid driver.
This is actually really weird. A NameError is raised when a variable doesn't exist, which shouldn't be true no matter what the return value of ogr.GetDriverByName is. It could be None or False or whatever, and you still should not be seeing a NameError from these four lines of Python *no matter what*.
-mike.
----------------------------------------------------------------
michal migurski- m...@stamen.com
415.558.1610
Below is a detailed list of what I've done (most recently).
Results:
+ PG-driver is installed
+ Apache is serving me web pages
– I cannot SFTP anything into /var/www
– TileStache tests all return 500 Internal Server Error
So close… but yet so far…
# from a clean install of Ubuntu-Server
sudo aptitude update
sudo aptitude upgrade
# PIL has some quirks in Ubuntu 11.10 so we need to do some quick fixes
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
Several more problems solved. Another problem encountered.
I figured out one issue from my apache error.log:
[Sat Aug 25 21:55:08 2012] [error] [client 192.168.37.1] AttributeError: module '/usr/local/lib/python2.7/dist-packages/TileStache/__init__.pyc' contains no 'ModpythonHandler'
It seems that I had accidentally capitalized the M in what should have been 'modpythonHandler' in my httpd.conf file!
I've now managed to get TileStache working again with .json files.
At first, it is still was not able to connect to the database. I tweaked some permissions and modified the database, and now I can connect to the database from Python using the script you provided. But since I didn't modify any prefixes, I just used:
Known unknown!
Couldn't get a layer from data source PG:dbname='gis' user='gisuser'
So, do I perhaps now have my database setup incorrectly? I can generate a .geojson tile from a .json file, but so far have not been able to from the database. I imported my data into the database from a .shp file. The same .shp file that I used to create the .json file that is working.
Two steps forward, one step back… but I feel like I am really close. Still…
> Several more problems solved. Another problem encountered.
> I figured out one issue from my apache error.log:
> [Sat Aug 25 21:55:08 2012] [error] [client 192.168.37.1] AttributeError: module '/usr/local/lib/python2.7/dist-packages/TileStache/__init__.pyc' contains no 'ModpythonHandler'
> It seems that I had accidentally capitalized the M in what should have been 'modpythonHandler' in my httpd.conf file!
> I've now managed to get TileStache working again with .json files.
> At first, it is still was not able to connect to the database. I tweaked some permissions and modified the database, and now I can connect to the database from Python using the script you provided. But since I didn't modify any prefixes, I just used:
> So, do I perhaps now have my database setup incorrectly? I can generate a .geojson tile from a .json file, but so far have not been able to from the database. I imported my data into the database from a .shp file. The same .shp file that I used to create the .json file that is working.
> Two steps forward, one step back… but I feel like I am really close. Still…
I had to go into the PostGIS database and manually insert my SRID into the geometry_columns table. It had my SRID as -1 instead of 2236. I updated that.
On Sunday, August 26, 2012 2:34:35 PM UTC-4, Todd Albert wrote:
> Mike,
> Ok, I'm making good progress here…
> I had to go into the PostGIS database and manually insert my SRID into the > geometry_columns table. It had my SRID as -1 instead of 2236. I updated > that.
> But, just when I thought I had things going well, I look at the .geojson > file that it server and I see:
> {"type": "FeatureCollection", "features": []}
> It's empty!
> So, I looked at my geography_columns table and it is empty. It has > columns, but there are 0 rows.
> Do I need the geography_columns to be defined for my table?
> What am I doing wrong here?!
> On Aug 26, 2012, at 12:37 PM, Todd Albert wrote:
> Grr…
> I went back and recreated the database, redid my shp2pgsql command with > the original shapefile, and re-imported the data into PostGIS.
> I still get the error:
> Known unknown!
> Couldn't get a layer from data source PG:dbname='gis' user='gisuser'
> Nothing valuable appears in the apache logs this time…
Well, my ability to help with your own database is fairly limited, but here's what I'd look out for:
1. The vector provider will try to figure out your layer's projection, but if it can't for some reason it will default back to plain geographic 4326, so to be on the safe side keep your database unprojected and in lat, lon:
https://github.com/migurski/TileStache/blob/master/TileStache/Vector/...
2. I'm pretty sure you don't need anything in geography_columns, it's a new PostGIS 2.0-ism and I've never used it, but as I've said my experience with 2.0 is limited.
3. Can you make normal spatial queries of your table using psql itself for a given tile? You seem to have data in Florida, can you query for features within a known tile bounding box like 14/4546/6948 (http://teczno.com/s/yjh)? southwest: 26.33280 -80.11230 (geographic)
northeast: 26.35249 -80.09033 (geographic)
upper-left: -8918061 3042804 (spherical mercator)
lower-right: -8915615 3040358 (spherical mercator)
4. If you need to see inside whatever Tilestache is doing, you can turn on logging output and modify the source code of TileStache/Vector/__init__.py to insert your own logging statements and watch your web server's log, wherever that goes:
http://tilestache.org/doc/#logging
> I am running out of time to figure this out. We're on the threshold of switching to a commercial solution which is much less flexible.
> Please help!
> Desperately,
> Todd
> On Sunday, August 26, 2012 2:34:35 PM UTC-4, Todd Albert wrote:
> Mike,
> Ok, I'm making good progress here…
> I had to go into the PostGIS database and manually insert my SRID into the geometry_columns table. It had my SRID as -1 instead of 2236. I updated that.
> But, just when I thought I had things going well, I look at the .geojson file that it server and I see:
> {"type": "FeatureCollection", "features": []}
> It's empty!
> So, I looked at my geography_columns table and it is empty. It has columns, but there are 0 rows.
> Do I need the geography_columns to be defined for my table?
> What am I doing wrong here?!
> On Aug 26, 2012, at 12:37 PM, Todd Albert wrote:
>> Grr…
>> I went back and recreated the database, redid my shp2pgsql command with the original shapefile, and re-imported the data into PostGIS.
>> I still get the error:
>> Known unknown!
>> Couldn't get a layer from data source PG:dbname='gis' user='gisuser'
>> Nothing valuable appears in the apache logs this time…
>> –Todd
----------------------------------------------------------------
michal migurski- m...@stamen.com
415.558.1610