#POSTGIS IRC Log - 2009-05-29

For logs after Feb 3, 2007, all times are GMT-8. Prior logs are GMT-9.
Back to Logs
00:35:26 smartnude: How would I go about using ST_Union to make a new larger polygon of several others.. I want to make all zipcodes starting with a 2 into a new polygon
00:37:23 smartnude: I tried with
00:37:24 smartnude: SELECT ST_Union( the_geom ) FROM pnrytor
00:37:25 smartnude: WHERE postnrtext LIKE '261%';
00:37:39 smartnude: but gives me a "" result
00:38:15 smartnude: ( 261 to limit the time for query, 33 polygons instead of 1250 )
00:42:20 dassouki_: smartnude:
00:42:38 dassouki: are you there
00:43:55 dassouki: SELECT ST_Intersection( r.st_union, m.the_geom ) AS intersection_geom
00:43:55 dassouki: FROM "fred_da_wgs_2" AS r, "NBlur" AS m
00:43:55 dassouki: WHERE r."DAUID" LIKE '13%' AND ST_Intersection( r.st_union, m.the_geom )
00:44:18 dassouki: LIMIT 1;
00:50:05 smartnude: that creates a new unified polygon ?
00:51:04 smartnude: guess I need to read up on Intersection
00:51:49 smartnude: but intersection creates a new poly of the part of polyA and polyB that overlap ?
00:52:12 smartnude: I want PolyA + PolyB
00:55:14 dassouki: oops
01:03:23 dassouki: smartnude: can u just select * from all_tables where zipcode = '2%'
01:03:59 dassouki: i'm not really a postgis expert. just thinking out loud
01:20:08 smartnude: hello strk
01:21:28 smartnude: all well today ?
01:29:53 strk: so far... : )
01:30:18 smartnude: EST ?
01:31:15 strk: uhm... never know. CEST ?
01:31:20 strk: GMT+1 ...
01:32:57 smartnude: ah.. same as me then
01:35:30 smartnude: strk: I spoke with the people over at gdal, the current version of the shapelib uses a long int so should go beyond the 2gb... but he was uncertain what version postgis built against
01:37:12 smartnude: you got time for helping me out with ST_Union btw ? trying to unify all zipcodes beginnign with 261 into a new polygon
01:37:55 smartnude: SELECT ST_Union( the_geom ) FROM pnrytor
01:37:55 smartnude: WHERE postnrtext LIKE '261%';
01:38:05 smartnude: is obviously not the way to do it :/
01:41:25 strk: no much time, sorry
01:41:40 strk: check postgis source code of the version you're using to figure which version of shapelib is used there
01:42:04 smartnude: okey
04:53:26 milovanderlinden: Hi there, Is there a way to create a "dummy" unique key for a view that aggregates geometries? Right now my query is: create view serlimar_regio as select regio, st_union( wkb_geometry ) as wkb_geometry from serlimar group by regio;
04:53:30 milovanderlinden: I need it for qGIS
05:37:42 xavier___: Hello!
05:47:04 smartnude: hello xavier___
05:47:23 xavier___: Hey hello smartnude : )
05:47:28 xavier___: how are you ?
05:53:20 smartnude: xavier___: I'm quite alright, nice weather and stuff... bit cloudy atm, but still nice
05:54:02 xavier___: Oh nice : ) Here it's raining :(
05:54:29 smartnude: tomorrow there's suns all over the weather map ^_^
05:55:17 xavier___: oh cool : ) Where you come ?
05:55:23 smartnude: http://svt.se/content/1/c6/60/90/53/1p.jpg <<-- all pretty!
05:56:06 smartnude: and sweden, as you might be able to see : )
05:56:29 xavier___: Yes, cool : )
05:56:53 smartnude: xavier___: you good with ST_Union ?
05:57:46 xavier___: not really lol, im a beginer with Postgis :S
05:58:04 smartnude: as am I
05:58:19 xavier___: hehe ^^
05:59:11 smartnude: purely educational for me
05:59:26 xavier___: ok
05:59:40 smartnude: I'm in informatics normally, but I happened to slide over here when writing my dissertation
05:59:56 xavier___: oh ok
06:00:57 xavier___: well, me too im in informatic but, i have to handle latitude/longitude
06:01:15 smartnude: I'm doing a comparison of postgis and ms sql 2008
06:02:01 xavier___: and i have see PostGis we should be able to do searches in a zone and thing like that
06:02:03 smartnude: currently I'm having trouble unifying my zipcodes into larger groups.. like all zipcodes beginning with 2 into one big multipolygon
06:02:20 smartnude: xavier___: indeed
06:03:25 smartnude: I think I need to make some small test cases and see if I can figure out why it's not working
06:05:07 xavier___: yeah
06:13:07 smartnude: hmm.. that didn't make me wiser
06:13:16 smartnude: all tests I do works fine.. but the real data I have does not work
06:13:25 smartnude: time to get on train.. brb
06:16:51 smartnude: b
06:25:15 xavier___: well for me it's more simple LOL i try to test a way to calculate the distance ( in kilometers ) betweens 2 longitude/latitude
06:25:29 smartnude: ST_Distance!
06:25:37 xavier___: and i compare the result with google earth and it's dosent match of ~ 5 km
06:25:54 smartnude: right
06:26:01 xavier___: google earth give me a distance of 28,2 km
06:26:12 xavier___: but postgis give me 33,8 km
06:26:24 smartnude: between two points ?
06:28:06 xavier___: yeah
06:28:11 xavier___: i test with this simple query
06:28:28 xavier___: SELECT cast( distance_sphere( PointFromText( 'POINT( 46.8061 -71.2072 )', 4326 ) , PointFromText( 'POINT( 46.6569 -71.5075 )', 4326 ) ) / 1000 as decimal( 15,3 ) ) AS "Distance";
06:29:32 smartnude: hmmm.. okey
06:29:38 smartnude: dunno.. I'm not too much into GIS in general
06:30:43 xavier___: well i have take a chance ^^
09:57:38 davidfetter: hello
09:57:56 davidfetter: is there an easy, mechanical way to import current TIGER files?
10:05:53 CIA-34: kneufeld * r4113 /trunk/doc/reference.xml: small typo in Populate_Geometry_Columns doc
10:07:34 rudenstam: Anyone got some wisdom to share of why I can't ST_Union some multipolygons ?
10:08:00 kneufeld: are they valid?
10:08:13 davidfetter: did i just ask a FAQ?
10:08:24 kneufeld: yes : )
10:08:32 davidfetter: where is it?
10:08:59 kneufeld: oh sorry .. I meant to rudenstam
10:09:26 kneufeld: to import TIGER shapefiles, you can probably just ust the shp2pgsql loader utility
10:09:46 rudenstam: kneufeld: ST_IsValid sais they are yes
10:10:17 kneufeld: rudenstam: what's the error?
10:10:24 davidfetter: kneufeld, thanks. next question, also probably a FAQ
10:10:32 rudenstam: kneufeld: none, I just get a "" returned instead of a geometry
10:11:00 davidfetter: where do i find example queries like, "stores within 5 miles of 94607" ?
10:11:49 kneufeld: david: does dwithin help you?
10:11:49 kneufeld: http://postgis.refractions.net/documentation/manual-svn/ST_DWithin.html
10:11:50 sigq: Title: ST_DWithin ( at postgis.refractions.net )
10:12:34 davidfetter: kneufeld, lots : )
10:12:44 davidfetter: sigq, thanks, too : )
10:13:14 kneufeld: rudenstam: you get null when unioning geometries? and they're all valid?
10:13:16 kneufeld: mmm curious
10:13:27 rudenstam: kneufeld: hold on and I'll boot the dev computer
10:13:46 kneufeld: can you isolate an example?
10:14:07 rudenstam: I can do my very best to try to
10:14:13 kneufeld: k
10:16:38 xavier___: Hey hello : )
10:24:16 xavier___: Im new in GIS and i have to handle some geographical data ( long/lat points ) and i have some difficulties to get the distance between 2 lat/long position :S someone can help me with my issue? i will appreciate : )
10:24:32 rudenstam: kneufeld: http://pastebin.com/d3d14570a
10:24:33 sigq: Title: SQL pastebin - collaborative debugging tool ( at pastebin.com )
10:24:46 rudenstam: kneufeld: returns t, t and ""
10:25:08 rudenstam: I'm just going to go start up a machine of washing
10:25:10 rudenstam: brb
10:35:56 rudenstam: backs
10:36:01 rudenstam: kneufeld: any comments ?
10:36:07 rudenstam: guess not :/
10:56:09 dylanB_UCD: howdy.
10:56:23 dylanB_UCD: anyone know how to check the current definition of an aggregate in postgresql?
10:56:40 dylanB_UCD: i just upgraded to postgis-1.4, and want to make sure that the correct aggregate is being used...
10:58:33 cgs_bob: hello dylanB_UCD. so you finally upgraded to 1.4. you should look at the definition in pgadmin3
10:59:19 dylanB_UCD: yeah -- unfortunately aggregates do not show up.
10:59:41 dylanB_UCD: dang... ok- figured out the problem from yesterday-- needed to restart postgres after installing new postgis
11:00:00 dylanB_UCD: however, i have not found a clean way to upgrade from postgis 1.3.3 --> 1.4
11:00:08 cgs_bob: I'll go take a look...brb
11:00:17 dylanB_UCD: the AGGREGATE defs are not re-made
11:00:23 dylanB_UCD: ( cannot be overwritten )
11:04:18 cgs_bob: so, did you try to do a make check after compiling?
11:10:25 dylanB_UCD: i know the upgrade worked... i just have some old AGGREGATE definitions lying around..
11:15:57 cgs_bob: it's strange. the old pgadmin3 showed the aggregates. I'm using 1.10. how about looking in the pg_ tables. take a look at this: http://www.postgresql.org/docs/8.3/interactive/catalog-pg-aggregate.html
11:15:58 sigq: Title: PostgreSQL: Documentation: Manuals: PostgreSQL 8.3: pg_aggregate ( at www.postgresql.org )
11:39:56 dylanB_UCD: thanks'
11:49:57 dylanB_UCD: hmm... ended up manually deleting the aggregates
12:10:05 pramsey: rudenstam: also what is select postgis_full_version( ); ?
12:11:35 rudenstam: *boots dev box again*
12:12:27 pramsey: sorry, need to know that to tie the example to a particular software version : )
12:12:46 rudenstam: of course
12:12:56 rudenstam: POSTGIS="1.3.6" GEOS="3.1.0-CAPI-1.5.0" PROJ="Rel. 4.6.1, 21 August 2008" USE_STATS
12:15:50 rudenstam: pramsey: so it's just not me doing something seriously wrong then ? ; )
12:19:21 rudenstam: on windows if it matters
12:24:27 pramsey: I'll tell you in 2 secs rudenstam , as I run your query here.
12:29:55 pramsey: rudenstam: you say you get null?
12:31:04 rudenstam: hmm... this is interesting
12:31:15 rudenstam: I just ran it in psql.exe instead of pgadminIII
12:31:23 rudenstam: works in psql.exe it seems
12:31:24 pramsey: oh, that's a display issue, man : )
12:31:40 pramsey: wrap the st_union( ) in an st_area( ).
12:31:43 pramsey: null things don't have areas
12:32:08 pramsey: pgadmin chokes on large stuff, it doesn't display long long things ( like geometries )
12:32:14 rudenstam: ugh
12:32:30 rudenstam: good to know! ; )
12:32:57 pramsey: thanks for the good test case though : )
12:32:58 rudenstam: is there any more sane way of running psql than in cmd ? ie.. fullscreen window, font customization etc.
12:33:36 pramsey: not that I know of. I guess any alternate shell might be better.
12:33:45 pramsey: "powershell"? I don't know my windoze
12:33:47 rudenstam: thanks for informing me of the pgadmin problem
12:33:59 rudenstam: powershell is also somewhat limited.. better than cmd though
12:34:06 rudenstam: oh well.. perhaps I should boot up my debian instead..
12:34:59 rudenstam: annoying little problem.. dunno how many hours I spent earlier today trying to figure out what the hell was wrong
13:24:41 dylanB_UCD: hi pramsey
13:24:52 dylanB_UCD: any tips on upgrading AGGREGATES in a postgis-enabled DB?
13:25:01 dylanB_UCD: apart from manual deletion?
13:25:17 pramsey: hum hum
13:25:32 pramsey: so, you've done a make install on top of your running installation
13:25:38 dylanB_UCD: yes
13:25:40 pramsey: and you want everything to be upgraded, but not do a dump/restore?
13:25:46 dylanB_UCD: if possible
13:25:59 dylanB_UCD: seems to have worked in the past ( 1.3.x --> 1.3.3 )
13:26:01 pramsey: and you have put 1.4 onto a 1.3 database
13:26:06 dylanB_UCD: yes
13:26:18 pramsey: there is no infrastructure for that right now
13:26:24 dylanB_UCD: hehahah, great.
13:26:28 pramsey: but, it is worth a ticket, if you'd be so kind as to file one?
13:26:32 dylanB_UCD: i wonder if my approach fuxored the DB
13:26:37 dylanB_UCD: sure
13:26:38 pramsey: no probably not
13:26:43 pramsey: if you check the contents of pg_proc
13:26:52 pramsey: you'll probably find all your functions are still bound to the old dll
13:26:55 pramsey: ( .so )
13:27:27 dylanB_UCD: how would i check this?
13:27:38 pramsey: select proname, probin from pg_proc and go to the end
13:27:59 dylanB_UCD: postgis_lib_version | $libdir/postgis-1.4
13:28:06 dylanB_UCD: st_estimate_histogram2d | $libdir/liblwgeom
13:28:35 dylanB_UCD: st_curvetoline | $libdir/postgis-1.4
13:28:41 pramsey: a mix
13:28:50 dylanB_UCD: should I dump any libs from /usr/local/pgpsql/lib ?
13:28:52 : * pramsey hrm hrms
13:29:03 dylanB_UCD: ikes...
13:29:47 pramsey: ( as an aside... )
13:30:36 pramsey: ( if you store all your application data in a schema, and allow nothing into public except system stuff like postgis, then a dump/restore upgrade is a trivial operation, because you just make a fresh empty db, install postgis ( whateever version you like ) into it, and then dump your app schema from the old and load it into the new )
13:30:55 dylanB_UCD: makes sense
13:32:07 dylanB_UCD: one nice thing about my broken upgrade: ST_Union( ) only took 21 minutes instead of > 4 hours + error
13:32:27 pramsey: interesting.
13:32:34 pramsey: sorry, I have no easy way to clean your install...
13:33:02 pramsey: a simple hack clean would be to do a dump/restore by table
13:33:18 pramsey: to pull a list of your tables out into a text file, then foreach through them, dumping form old and restoring to new
13:33:28 dylanB_UCD: heh... ok -- so I would dump/restore each table into a new db?
13:33:31 pramsey: yes
13:33:55 pramsey: and when you're done run select probe_geometry_columns( ) to populate your geometry_columns table
13:34:11 pramsey: wait, not 'probe', 'populate'
13:34:14 pramsey: anyhow
13:38:16 dylanB_UCD: hmmm, i wonder if my messed-up install is responsible for this:
13:38:18 dylanB_UCD: ERROR: LWGEOM_estimated_extent: couldn't locate table within current schema
13:38:18 dylanB_UCD: STATEMENT: select estimated_extent( 'public','ca_ssurgo_mask','wkb_geometry' )
13:38:29 dylanB_UCD: ( when trying to access data from QGIS )
13:38:47 dylanB_UCD: would installing 1.3.3 back over the 1.4 install fix things?
13:41:18 : * pramsey guarantees nothing at this point.
13:41:30 dylanB_UCD: hehah-- yeah. i should have asked
13:41:34 dylanB_UCD: before recking things
13:42:35 : * xavier___ have found is big stupid mistake... i have inverted longitude and latitude... i have passed a big part of the night to work on this to find my error --__--''
13:43:22 dylanB_UCD: ok, if I dump with 'pg_dump' how do I keep the functions from postgis from being included in the dump?
13:43:33 rudenstam: xavier___: hahaha
13:43:43 rudenstam: xavier___: google agrees with you now ?
13:44:06 rudenstam: xavier___: did you read about the solution for my problem ? ; )
13:44:07 pramsey: dylanB_UCD: by doing it one table at a time
13:44:17 pramsey: ( this is why having a separate schema... )
13:44:21 pramsey: ( is so nice... )
13:44:50 dylanB_UCD: right --
13:45:01 dylanB_UCD: ok, ok, ok... time to move things into schemas!
13:45:09 dylanB_UCD: thanks for putting up with these questions
13:45:10 pramsey: you can even do it while you recover from your error...
13:45:24 dylanB_UCD: yeah, good "opportunity" i suppose
13:45:26 pramsey: by setting your search_path to your schema before running your create table as you re-load
13:45:40 dylanB_UCD: at least I got my ST_Union-ed data in 21 minutes
13:45:45 xavier___: not really rudenstam, i haven't get this issue :S
13:45:48 dylanB_UCD: that alone is worth the hassle
13:45:52 pramsey: prepend "set search_path = myschema,public" to your dump files as you reload
13:46:14 pramsey: er s/=/to/
13:46:19 dylanB_UCD: i will need to make the schema first, yes
13:46:25 pramsey: set search path to myschema,public;
13:46:34 rudenstam: xavier___: PgAdminIII apparently does not display very long strings... so it was working all the time.. just didn't display it
13:46:46 xavier___: yeah i know
13:46:52 xavier___: also i have found an other issue
13:47:12 xavier___: but is not really related to Postgris
13:47:17 xavier___: postgis*
13:47:48 xavier___: is when you type some chars not present in the US ascii
13:47:51 xavier___: for example
13:47:53 pramsey: select tablename from pg_tables where schemaname = 'public' and tablename not in ( 'spatial_ref_sys','geometry_columns' );
13:48:06 xavier___: something like "Bon été"
13:48:10 xavier___: ( in french )
13:48:34 xavier___: the "é" seems to dont be accepted by pgadmin III
13:49:28 xavier___: at least, is for the mac version ^^
13:49:55 pramsey: echo "set search_path to app,public" > search.txt
13:51:59 pramsey: foreach t ( `cat tables.txt` )
13:51:59 pramsey: pg_dump -d pramsey -t $t > tmp.txt
13:52:07 pramsey: cat search.txt tmp.txt | psql newdb
13:52:08 pramsey: end
13:52:12 pramsey: or something like that : )
13:52:27 pramsey: it's easier than I thought
13:52:33 dylanB_UCD: wow, thanks!
13:52:47 dylanB_UCD: all the new features in 1.4... i just couldn't wait!
13:54:37 : * pramsey notes he's missing a ; at that set search path file
13:54:47 pramsey: but otherwise it worked like a hot damn.
13:55:01 pramsey: dump table names into text file, iterate on table names into a nice clean database
13:55:07 dylanB_UCD: right.. ok i have some schemas defined, i just have *some tables* in public
13:56:09 dylanB_UCD: pg_dump -n
14:09:27 dylanB_UCD: so pramsey, should i install the postgis functions before re-loading tables, so that the geometry datatype is defined?
14:09:34 pramsey: right
14:09:37 dylanB_UCD: ok
14:09:48 pramsey: nice clean db, with a freash postgis and spatial_ref_sys table
14:10:59 dylanB_UCD: got it.
14:14:35 dylanB_UCD: foreach t ( `cat davis_tables.txt` ) <--- is this bash?
14:17:25 pramsey: tcsh
14:17:34 dylanB_UCD: ah, right... translated to bash.. ok
14:17:43 dylanB_UCD: list=`cat davis_tables.txt`
14:17:43 dylanB_UCD: for t in $list
14:17:44 dylanB_UCD: do
14:18:02 pramsey: btw...
14:18:05 pramsey: this is easier
14:18:28 pramsey: alter table foo set schema to bar;
14:18:39 pramsey: before you dump, then you just have the schema dumps
14:18:47 : * pramsey is a silly bugger.
14:19:05 dylanB_UCD: ah...
14:19:07 dylanB_UCD: ok.
14:23:32 dylanB_UCD: thanks for all the help pramsey
14:23:39 pramsey: thanks for the patience!
14:23:45 dylanB_UCD: hehe-- postgis is worth it
14:28:27 dylanB_UCD: hmmm... the dumping / restoring is resulting in :
14:28:29 dylanB_UCD: ERROR: syntax error at or near "SET"
14:28:29 dylanB_UCD: LINE 5: SET client_encoding = 'UTF8';
14:30:50 pramsey: yes
14:30:57 pramsey: that "echo" I wrote...
14:31:14 pramsey: should be echo "set search_path to app,public;" > search.txt
14:31:20 pramsey: note the trailing ;
14:32:13 dylanB_UCD: ah... right...
14:32:23 dylanB_UCD: looks like i bungled some other stuff too
14:33:59 dylanB_UCD: that caused the tables not to put into their schemas...
14:34:05 dylanB_UCD: and thus table name collisions
14:34:06 dylanB_UCD: right.
14:36:36 dylanB_UCD: humm... my tables aren't going into their schema.
14:38:04 dylanB_UCD: aha!
14:38:12 dylanB_UCD: it is being overwritten later on in the dump script.,
14:38:17 dylanB_UCD: SET search_path = public, pg_catalog;
14:42:53 dylanB_UCD: added a | sed 's/SET search_path = public, pg_catalog;/SET search_path = davis, public;/g'
14:43:00 dylanB_UCD: seems to do the trick
15:13:56 : * davidfetter waves to pramsey
15:14:27 pramsey: hi davidfetter
15:14:30 dylanB_UCD: finished fixing bungled postgis upgrade on 1 machine... next one up