[postgis-users] Extrude_Tesselate_and_Altitudemode_Support KML, POSTGIS

eehab hamzeh eehab40 at hotmail.com
Thu Jul 17 03:22:48 PDT 2008


Hello,

Is POSTGIS,  ASKML command support  extrude, tesselate, altitudemode now.

thank you 

ihab hijazi


> From: postgis-users-request at postgis.refractions.net
> Subject: postgis-users Digest, Vol 69, Issue 16
> To: postgis-users at postgis.refractions.net
> Date: Wed, 16 Jul 2008 12:01:04 -0700
> 
> Send postgis-users mailing list submissions to
> 	postgis-users at postgis.refractions.net
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://postgis.refractions.net/mailman/listinfo/postgis-users
> or, via email, send a message with subject or body 'help' to
> 	postgis-users-request at postgis.refractions.net
> 
> You can reach the person managing the list at
> 	postgis-users-owner at postgis.refractions.net
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of postgis-users digest..."
> 
> 
> Today's Topics:
> 
>    1. RE: newbie question: PostGIS and .NET? (Rob Tester)
>    2. Re: Query that locks up system memory/disk usage (Kevin Neufeld)
>    3. Re: Raster elevation x/y lookup (was:	Splitting/merging
>       linework into equal interval linestrings) (Dane Springmeyer)
>    4. match line with road segment (searchelite)
>    5. Need help with a query (Pedro Doria Meunier)
>    6. Re: newbie question: PostGIS and .NET? (Saka Royban)
>    7. contains syntax (jj.wag at gmx.de)
>    8. RE: newbie question: PostGIS and .NET? (Obe, Regina)
>    9. RE: contains syntax (Obe, Regina)
>   10. Re: newbie question: PostGIS and .NET? (Saka Royban)
>   11. Re: Windows Crash (Chris Hermansen)
>   12. Re: match line with road segment (Stephen Woodbridge)
>   13. Re: Transform overlapping polygons to non-overlapping?
>       (Brent Fraser)
>   14. RE: Transform overlapping polygons to non-overlapping?
>       (Paragon Corporation)
>   15. RE: Transform overlapping polygons to non-overlapping?
>       (Paragon Corporation)
>   16. Re: Transform overlapping polygons to non-overlapping?
>       (Brent Fraser)
>   17. Re: Transform overlapping polygons to non-overlapping?
>       (Dylan Beaudette)
>   18. Re: Transform overlapping polygons to non-overlapping?
>       (Brent Fraser)
>   19. Re: Transform overlapping polygons to non-overlapping?
>       (Kevin Neufeld)
>   20. RE: Transform overlapping polygons to non-overlapping?
>       (Obe, Regina)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Tue, 15 Jul 2008 12:33:44 -0700
> From: "Rob Tester" <robtester at gmail.com>
> Subject: RE: [postgis-users] newbie question: PostGIS and .NET?
> To: "'PostGIS Users Discussion'"
> 	<postgis-users at postgis.refractions.net>
> Message-ID: <018501c8e6b1$b2f13050$18d390f0$@com>
> Content-Type: text/plain; charset="us-ascii"
> 
> Not 100%  sure what you are looking for, but if you want access to
> PostgreSQL with the PostGIS extensions from .NET use NPGSQL:
> 
>  
> 
>  
> 
> http://npgsql.projects.postgresql.org
> 
>  
> 
>  
> 
> If you want more than that, we commonly use GDAL tools from here: 
> 
>  
> 
> http://www.gdal.org/
> 
>  
> 
> Rob
> 
>  
> 
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Saka
> Royban
> Sent: Tuesday, July 15, 2008 11:03 AM
> To: PostGIS
> Subject: [postgis-users] newbie question: PostGIS and .NET?
> 
>  
> 
> Hi all.
> Sorry for elementary question. but i didn't find anything to support PostGIS
> in .NET environment. 
> just some driver for Java. 
> I mainly wanna make a desktop GIS applications and it sounds PostGIS helpful
> to be used as a back-end to manage large number of shapefiles. So, is there
> a way to use this spatial database in .NET? 
> Queries support by PostGIS are excellent but i need to have export of SQL
> commands in shapefile.
> Thanks
> 
> saka
> 
>  
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.refractions.net/pipermail/postgis-users/attachments/20080715/06d14228/attachment-0001.html
> 
> ------------------------------
> 
> Message: 2
> Date: Mon, 14 Jul 2008 17:18:50 -0700
> From: Kevin Neufeld <kneufeld at refractions.net>
> Subject: Re: [postgis-users] Query that locks up system memory/disk
> 	usage
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> Message-ID: <487BECEA.3000402 at refractions.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Paul, while "kill -9" will undoubtedly stop the current running query, 
> it will also crash the entire database cluster since the shared memory 
> will become corrupt. 
> 
> I recommend using a "kill -2" instead which is the same thing as issuing 
> a ctrl^c while in the terminal program.  It may take longer since it has 
> to rollback the transaction, but it will do so gracefully.
> 
> -- Kevin
> 
> Paul Ramsey wrote:
> > Break yourself of the subquery habit:
> >
> > select a.* from a join b on (st_dwithin(a.the_geom,b.the_geom,50000))
> > where b.gid = 10;
> >
> >
> > On your process:
> >
> > ps ax | grep postgres
> >
> > Find the process id that is using all the CPU and just kill -9 it. The
> > glory of running a proper ACID database like PgSQL is that if you
> > don't like what it's doing, you can rip the power cord out of the
> > wall, and it'll still start up clean. (Do not try this with MySQL.)
> >
> > P.
> >
> > buffer((select b.the_geom
> >   
> >> where gid = 10),50000));
> >>     
> >
> > On Mon, Jul 14, 2008 at 4:33 PM, Mike Leahy <mgleahy at alumni.uwaterloo.ca> wrote:
> >   
> >> Hello list,
> >>
> >> I've run into some situations where running certain queries end up locking
> >> up all of my system's ram memory, with constant disk access.  I can't cancel
> >> the query by hitting ctrl+c in the psql terminal, by restarting the service,
> >> or even killing the postmaster.  I'm running on a fairly high end system, so
> >> it's not an issue with CPU power or available ram.  Here's an example of
> >> what I did today that caused this:
> >>
> >> Table A is a table I imported from a tile index shapefile.
> >>
> >> Table B has several fairly large irregular polygons of different study
> >> areas.
> >>
> >> To get all of the polygons in Table A within a certain distance (50km) of
> >> one of the polygons in Table B, without giving it much thought I did the
> >> following:
> >>
> >> select * from a where st_intersects(a.the_geom,buffer((select b.the_geom
> >> where gid = 10),50000));
> >>
> >> I realize how wrong that is, as calculates the buffer for every tile it
> >> compares to...I should have done something like:
> >>
> >> select * from a where st_intersects(a.the_geom,(select b.the_geom where gid
> >> = 10)) or st_distance(a.the_geom,(select b.the_geom where gid = 10))<=50000;
> >>
> >> The problem is...I'm still waiting for the first query to either finish, or
> >> cancel, or something.  In the meantime, postmaster is still using 99% of my
> >> memory, and the disk is still thrashing away (though CPU usage pretty much
> >> at 0).  What's the best strategy to kill the previous query without having
> >> to shut down the entire server?
> >>
> >> Keep in mind that is just an example of how this can happen for me - I've
> >> had it happen in other more complex situations where it was less obvious
> >> what I was doing wrong in the logic of the query.  I'm just wondering how I
> >> can recover from these sorts of mistakes without potentially damaging the
> >> database.
> >>
> >> Regards,
> >> Mike
> >>
> >>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> >>     
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> >   
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Tue, 15 Jul 2008 18:20:19 -0700
> From: Dane Springmeyer <blake at hailmail.net>
> Subject: Re: [postgis-users] Raster elevation x/y lookup (was:
> 	Splitting/merging linework into equal interval linestrings)
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> Message-ID: <59CE83AC-6EB1-461D-8F49-A3DD0B6717AE at hailmail.net>
> Content-Type: text/plain; charset="us-ascii"
> 
> For anyone interested I've worked up Regina's great python snippet  
> into a full script.
> 
> The script pulls records of x/y values from a river hydrography  
> network from both upstream and downstream nodes of each equi-length  
> linestring. It then iterates through each record and updates the table  
> with the elevation values for the low and highpoint of each river  
> segment. Stream gradient is then easy to calculate back inside the  
> database.
> 
> I'm sure there are ways to improve or optimize this script, so if  
> anyone has any pointers don't hesitate to send them along.
> 
> Thanks again to Regina for the great push forward.
> 
> Cheers,
> Dane
> 
> 
> ###########
> 
> from osgeo import gdal
> import math
> import struct
> 
> import psycopg2
> import psycopg2.extras
> 
> gdal.SetCacheMax(15)
> 
> connection = psycopg2.connect("dbname='beaver' user='postgres'  
> host='localhost'");
> sql = connection.cursor(cursor_factory=psycopg2.extras.DictCursor)
> 
> dataset = gdal.Open('/Volumes/Wren/Users/spring/projects/beaver/data/ 
> elevation/uw/tiff/methow-tiled.tif', gdal.GA_ReadOnly)
> geotransform = dataset.GetGeoTransform()
> min_x = geotransform[0]
> max_y = geotransform[3]
> res_x = abs(geotransform[1])
> res_y = abs(geotransform[5])
> 
> sql.execute("""SELECT oid, ST_X(ST_StartPoint(geometry)) as down_x,  
> ST_Y(ST_StartPoint(geometry)) as down_y,ST_X(ST_EndPoint(geometry)) as  
> up_x, ST_Y(ST_EndPoint(geometry)) as up_y FROM sshiap_splits ORDER by  
> OID;""")
> 
> query_records = float(sql.rowcount) - 1.0
> 
> print 'Beginning lookup of %s features...' % query_records
> 
> for row in sql.fetchall():
>      oid = row['oid']
>      down_x = row['down_x']
>      down_y = row['down_y']
>      up_x = row['up_x']
>      up_y = row['up_y']
>      down_row = int(math.ceil((max_y - down_y)/res_y))
>      down_col = int(math.ceil((down_x - min_x)/res_x))
>      up_row = int(math.ceil((max_y - up_y)/res_y))
>      up_col = int(math.ceil((up_x - min_x)/res_x))
>      if down_row > 0  and down_col > 0 and up_row > 0  and up_col > 0  
> and dataset.RasterYSize > down_row and dataset.RasterXSize > down_col  
> and dataset.RasterYSize > up_row and dataset.RasterXSize > up_col:
>          down_raster_scan = dataset.ReadRaster(down_col - 1, down_row  
> - 1, 1, 1)
>          down_raster_area = struct.unpack('f' * 1, down_raster_scan)
>          lowpoint = int(down_raster_area[0])
>          up_raster_scan = dataset.ReadRaster(up_col - 1, up_row - 1,  
> 1, 1)
>          up_raster_area = struct.unpack('f' * 1, up_raster_scan)
>          highpoint = int(up_raster_area[0])
>          sql.execute("""UPDATE sshiap_splits SET lowpoint = %s,  
> highpoint = %s WHERE oid = %s""" % (lowpoint, highpoint, oid))
>          if oid/query_records in [.1,.2,.5,.10,.15,.20, . 
> 25,.30,.35,.40,.45,.50,.55,.60,.65,.70,.75,.80,.85,.90,.95,1.0]:
>           print '%s%s completed' % (oid/query_records*100, '%')
>      else:
>          print 'error  
> ---------------------------------------------------------------------------------'
> 
> print 'Complete'
> connection.commit()
> 
> 
> 
> 
> On Jul 10, 2008, at 11:38 AM, Dane Springmeyer wrote:
> 
> > Regina and Brent:
> >
> > Wow. Thanks so much for the pointers.
> >
> > I've now got a single query that is working excellently so far.  
> > Without indexes it runs on the entire dataset in about 5 minutes  
> > when splitting lines to ~ 150 m, which is just fine.
> >
> > I was able to use the ST_Reverse function to make sure that any  
> > fragments at the end of the linestrings would occur at the upstream  
> > end, which I think handles my minimum requirement (for now).
> >
> > Below is what just a slight reworking of Regina's second email  
> > example looks like.
> >
> > Thanks!
> >
> > Dane
> >
> >
> > ------
> >
> > drop table if exists test2;
> > create table test2 (oid serial,strahler varchar, geometry geometry);
> > INSERT
> > INTO test2 (strahler, geometry)
> > SELECT strahler,
> >   -- take a substring if the length is greater than 152.4 meters  
> > otherwise take the remainder
> >   ST_Line_Substring(geometry, 152.4*n/length,
> >   CASE
> >     WHEN 152.4*(n+1) < length THEN 152.4*(n+1)/length
> >     ELSE 1
> >   END) As geometry
> > FROM
> >   (SELECT strahler,
> >   -- reverse the vertex order so that the upstream end of each  
> > linestring will be the remainder
> >   ST_LineMerge(ST_Reverse(ts.geometry)) AS geometry,
> >   ST_Length(ts.geometry) As length
> >   FROM sshiap_lines ts
> >   ) t
> > CROSS JOIN generate_series(0,10000) n
> > WHERE n*152.4/length < 1;
> >
> >
> >
> > On Jul 9, 2008, at 10:21 PM, Paragon Corporation wrote:
> >
> >> Dane,
> >>
> >> I recall doing something along 2 and 3 before and I did it in python
> >> (although I was interested in getting each measure at x distance  
> >> along the
> >> line so I was collecting
> >> Points every x distance meters along the way rather than breaking  
> >> up the
> >> lines.  So my translation of what I did to what you want may have a  
> >> lot of
> >> logical errors)
> >>
> >> For 2 - I think your logic would look something like
> >>
> >> 2) SELECT gid, length*frac As dist,  
> >> ST_Line_Substring(the_geom,startfrac,
> >> endfrac) As the_geom
> >> FROM (SELECT gid, 500*n/length As startfrac, CASE WHEN 500*(n+1) <  
> >> length
> >> THEN 500*(n+1)/length ELSE 1 END As endfrac, length, the_geom
> >> 	FROM (SELECT ts.gid, ST_LineMerge(ts.the_geom) As the_geom,
> >> ST_Length(ts.the_geom) As length FROM line_segments ts
> >> 		) t CROSS JOIN generate_series(0,10000) n
> >> 	WHERE n*500/length < 1) As segments_500
> >>
> >>
> >>
> >> The above basically assumes your data is in some meter projection  
> >> and you
> >> have no line segment that has got more than 10000 (500 ft segments)
> >> If you know for sure there is no way you have a line segment  
> >> greater than
> >> 500*10000 then you can safely reduce that generate_series number  
> >> and get
> >> better performance.
> >>
> >> This I did do in python by the way - and my logic is much more  
> >> complicated
> >> than above but hopefully I cut out enough for you to get the basic  
> >> idea
> >>
> >> 3)  For this I used python and the gdal and psycopg libraries.   
> >> Basic logic
> >> looks something like Below
> >> open up a tile (my above query (maybe taking the centroid of each  
> >> point I
> >> actually limited to only those linesegments that intersected the  
> >> tile I was
> >> loading so I processed one tile at a time) - so my above query had  
> >> an extra
> >> join with the tile extent
> >>
> >> Looks something like below where pt is an array of the centroid  
> >> points of
> >> the above query
> >>
> >> 			dataset =
> >> osgeo.gdal.Open('%(atilefolder)s/%(atilefile)s'% 
> >> {'atilefolder':atilefolder,'
> >> atilefile':atilefile}, GA_ReadOnly)
> >> 			geot = dataset.GetGeoTransform()
> >> 			#0 0 row col is at top left corner of the tif so we
> >> need min_x, max_y that corresponds to pos (0,0)
> >> 			min_x = geot[0]
> >> 			max_y = geot[3]
> >> 			res_x = abs(geot[1])
> >> 			res_y = abs(geot[5])
> >> 			print 'Origin of tile ', atilefile , '= (',min_x,
> >> ',',max_y,')'
> >> 			print 'Pixel Size = (',res_x, ',',res_y,')'
> >> 			print 'Size is
> >> ',dataset.RasterXSize,'x',dataset.RasterYSize,  
> >> 'x',dataset.RasterCount
> >> 			for pt in r:
> >> 				#for each point figure out the row col
> >> position in the tiff
> >> 				gid = pt[0]
> >> 				x = pt[2]
> >> 				y = pt[3]
> >> 				#print max_y - y
> >> 				row = int(math.ceil((max_y - y)/res_y))
> >> 				col = int(math.ceil((x - min_x)/res_x))
> >> 				
> >> 				#If point falls in grid proceed to determine
> >> elevation from tiff
> >> 				#Some line segments may have measures that
> >> span multiple tiles so we need to skip the measurement points that  
> >> don't
> >> fall in the tile
> >> 				if row > 0  and col > 0 and
> >> dataset.RasterYSize > row and dataset.RasterXSize > col:
> >> 					numpoints = numpoints + 1
> >> 					pt_dist = pt[1]
> >> 					
> >> 					#grab  1 pixel at row col position
> >> in tif and return the band1 - which is the elevation
> >> 					rd_scan = dataset.ReadRaster(col -
> >> 1, row - 1, 1, 1)
> >> 					rd_area = struct.unpack('f' * 1,
> >> rd_scan)
> >> 					elev = int(rd_area[0])
> >> 					#your update statement goes here
> >> 		
> >>
> >>   Hope that helps,
> >> Regina
> >>
> >>
> >>
> >> -----Original Message-----
> >> From: postgis-users-bounces at postgis.refractions.net
> >> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of  
> >> Dane
> >> Blakely Springmeyer
> >> Sent: Wednesday, July 09, 2008 11:25 PM
> >> To: postgis-users at postgis.refractions.net
> >> Subject: [postgis-users] Splitting/merging linework into equal
> >> intervallinestrings
> >>
> >> PostGIS users,
> >>
> >> I have 1:24k hydrographic linework that I need process in several  
> >> successive
> >> steps using a postgis workflow.
> >>
> >> I'm stuck at step 2 of this overall workflow:
> >>
> >> 1) separate all linestrings into distinct Strahler Order groups  
> >> (done)
> >> 2) split all linework into linestrings of 500 ft (while avoiding any
> >> linestring fragments smaller than 500 ft)
> >> 3) perform an elevation lookup to raster data to calculate the  
> >> gradient of
> >> each 500 ft segment and..
> >> 4) combine all adjacent linestrings which fall into similar gradient
> >> classes.
> >>
> >> For step 2 I'm investigating using ST_Segmentize() and/or
> >> ST_Line_substring(), but I'd really appreciate some help with how  
> >> to best
> >> approach the problem.
> >>
> >> ST_Segmentize seems to only insert more nodes/points into already  
> >> very high
> >> resolution linework (ie nodes already exist at intervals much more  
> >> frequent
> >> than 500ft), thus extracting linestrings from the result of  
> >> ST_Segmentize
> >> clearly isn't as simple as using MakeLine() between each segment.
> >>
> >> ST_Line_Substring works on percentages which is smart, but I have  
> >> yet to
> >> wrap my mind around how to measure each individual line such that I  
> >> can
> >> translate percentage distance along a linestring into equal distance
> >> intervals.
> >>
> >> Anyone have examples or guidance?
> >>
> >> Thanks,
> >>
> >> Dane
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> >>
> >>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.refractions.net/pipermail/postgis-users/attachments/20080715/65087217/attachment-0001.html
> 
> ------------------------------
> 
> Message: 4
> Date: Tue, 15 Jul 2008 21:27:26 -0700 (PDT)
> From: searchelite <searchelite at gmail.com>
> Subject: [postgis-users] match line with road segment
> To: postgis-users at postgis.refractions.net
> Message-ID: <18479996.post at talk.nabble.com>
> Content-Type: text/plain; charset=us-ascii
> 
> 
> hi all..
> i have a line table consists of gps points, i'm using
> ST_makeline(gps_points) to create the line..my question is, how to match the
> gps line into road segment in postgis? 
> 
> thank you
> -- 
> View this message in context: http://www.nabble.com/match-line-with-road-segment-tp18479996p18479996.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
> 
> 
> 
> ------------------------------
> 
> Message: 5
> Date: Wed, 16 Jul 2008 09:54:08 +0100
> From: Pedro Doria Meunier <pdoria at netmadeira.com>
> Subject: [postgis-users] Need help with a query
> To: postgis-users at postgis.refractions.net
> Message-ID:
> 	<1216198449.3915.20.camel at 213-190-214-90-cmts01.netmadeira.com>
> Content-Type: text/plain; charset="us-ascii"
> 
> Hi all,
> 
> I need help with an unusual query (at least for me :] )
> 
> The objective is to find road segments with a type defined to tunnel
> within a given distance.
> This is needed because of gps signal spikes (speed-wise) at tunnel
> exits...
> 
> Now given the following scenario of road segments:
> 
> 
> =====*-----------------*==========
> ====V===*========================*
> *======
> 
> =====*-----------------*==========
>                     |
>                     |
>                     |
>                     |
>                     |
>                     |
>                     |
>                     |
>                     |
>                     |
> ==========-----------------------=======================
> 
> = | road
> - tunnel
> * nodes
> V vehicle
> 
> Now when I execute a distance-based query (for road segments of tunnel
> type) I get the lower tunnel, which is closer.
> But I want the upper one which is actually the one on the top.
> 
> the actual query is as follows (tunnels (road type=67) within a 150
> metres radius) -- the road map is in WGS84:
> SELECT name, road_type FROM $road_net WHERE 
> transform(geometry,$srid) &&
> setsrid(expand(transform(geomfromtext('POINT($lon $lat)',4326),
> $srid),150),$srid) 
> AND distance(transform(geomfromtext('POINT($lon $lat)',4326),$srid),
> transform(geometry,$srid)) <=150 AND road_type=67;
> 
> Already thankful for any tips,
> 
> -- 
> Pedro Doria Meunier <pdoria at netmadeira.com>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.refractions.net/pipermail/postgis-users/attachments/20080716/79ab6bec/attachment-0001.html
> 
> ------------------------------
> 
> Message: 6
> Date: Wed, 16 Jul 2008 03:16:24 -0700 (PDT)
> From: Saka Royban <srph124 at yahoo.com>
> Subject: Re: [postgis-users] newbie question: PostGIS and .NET?
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> Message-ID: <875184.66925.qm at web58203.mail.re3.yahoo.com>
> Content-Type: text/plain; charset="us-ascii"
> 
> It means using SharpMap i can load shapfiles to PostGIS, perform the query and finally have the result in shapefile format? Am i right?
> Thanks in advance
> 
> 
> 
> ----- Original Message ----
> From: "Obe, Regina" <robe.dnd at cityofboston.gov>
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>; postgis-users at postgis.refractions.net
> Sent: Tuesday, July 15, 2008 10:10:39 PM
> Subject: RE: [postgis-users] newbie question: PostGIS and .NET?
> 
> Re: [postgis-users] newbie question: PostGIS and .NET? 
> David,
>  
> Have him take a look at SharpMap.  Its got .NET drivers for PostGIS and other layer types.
>  
> http://www.codeplex.com/SharpMap
>  
> It works for both ASP.NET and windows .net apps.
>  
> Hope that helps,
> Regina
>  
>  
>  
>  
> 
> ________________________________
>  From: postgis-users-bounces at postgis.refractions.net on behalf of Jean David TECHER
> Sent: Tue 7/15/2008 2:32 PM
> To: postgis-users at postgis.refractions.net
> Subject: Re: [postgis-users] newbie question: PostGIS and .NET?
> 
> 
> 
> 
> Quoting Saka Royban <srph124 at yahoo.com>:
> 
> > Hi all.
> > Sorry for elementary question. but i didn't find anything to support 
> >  PostGIS in .NET environment.
> > just some driver for Java.
> > I mainly wanna make a desktop GIS applications and it sounds PostGIS 
> >  helpful to be used as a back-end to manage large number of  
> > shapefiles. So, is there a way to use this spatial database in .NET?
> For PostgreSQL you have Npgsql that support PostgreSQL queries
> 
> 
> > Queries support by PostGIS are excellent but i need to have export  
> > of SQL commands in shapefile.
> 
> You have pgsql2shp that could do it! Perhaps need to use API to .net?
> 
> > Thanks
> >
> > saka
> >
> >
> >
> >
> 
> 
> 
> ===================
> Jean David TECHER
> 06 60 46 85 05
> 04 99 77 17 87
> ===================
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> ________________________________
> 
> The substance of this message, including any attachments, may be confidential, legally privileged and/or exempt from disclosure pursuant to Massachusetts law. It is intended solely for the addressee. If you received this in error, please contact the sender and delete the material from any computer. 
> ________________________________
> 
> Help make the earth a greener place. If at all possible resist printing this email and join us in saving paper. 
> 
> 
>       
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.refractions.net/pipermail/postgis-users/attachments/20080716/e36ff65f/attachment-0001.html
> 
> ------------------------------
> 
> Message: 7
> Date: Wed, 16 Jul 2008 12:18:09 +0200
> From: <jj.wag at gmx.de>
> Subject: [postgis-users] contains syntax
> To: <postgis-users at postgis.refractions.net>
> Message-ID: <004101c8e72d$3fb35100$08b2a8c0 at SVEN>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
> 	reply-type=original
> 
> Hi all,
> 
> I have 2 tables:
> 
> 1. table "landkreise" (polygon) with column "lk" (names of administrative 
> borders (polygons))
> 2. standorte (point) with column "lk" (empty, I want to write the name of 
> the administrative borders from the polygon-feature that contains the point)
> 
> When I use following select-statement it seems to work:
> 
> SELECT l.lk FROM landkreise as l, standorte as s WHERE 
> contains(l.the_geom,s.the_geom) = TRUE;
> 
> When I want to update the column "lk" in table standorte allways the same 
> name is written:
> 
> UPDATE standorte SET lk = l.lk FROM landkreise as l, standorte AS s WHERE 
> contains(l.the_geom,s.the_geom) = TRUE;
> 
> What is wrong with my syntax?
> 
> Thanks
> Jo
> 
> 
> 
> 
> ------------------------------
> 
> Message: 8
> Date: Wed, 16 Jul 2008 06:38:46 -0400
> From: "Obe, Regina" <robe.dnd at cityofboston.gov>
> Subject: RE: [postgis-users] newbie question: PostGIS and .NET?
> To: "PostGIS Users Discussion" <postgis-users at postgis.refractions.net>
> Message-ID:
> 	<53F9CF533E1AA14EA1F8C5C08ABC08D204623CF6 at ZDND.DND.boston.cob>
> Content-Type: text/plain;	charset="us-ascii"
> 
> Well you could load shape files with SharpMap directly into PostGIS
> since it supports both types but you would have to roll your own a bit,
> although you can encode the password info etc which you can't with
> shp2pgsql. 
> 
> SharpMap is more designed for if you already have data in PostGIS and
> you want to query it from PostGIS and display it without having to dump
> to shape file format first. 
> 
> If you just want a shape file to PostGIS loader  - may be easier to just
> call shp2pgsql or ogr2ogr using the .NET Process class, which is
> described here
> http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
> .  
> 
> I haven't had a need to do that for loading shape files, but I use the
> process class for doing xcopy all the time (from one server to another)
>  
> .NET Process class  would look something like this I imagine -- you may
> need to fiddle with security, pemissions etc.  I have never tested this
> so not sure what issues would arise or if you can even do a | using
> process.  You may need to dump to sql and then load sql file first.
>  
>    Process.Start("path/to/shp2pgsql", " -s 4269 -I someshapefile
> somepgtable | psql -h someserver -d gisdb -U somepguser")
> 
> Hope that helps,
> Regina
>  
>  
>  
> 
>  
>  
> 
> ________________________________
> 
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Saka
> Royban
> Sent: Wednesday, July 16, 2008 6:16 AM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] newbie question: PostGIS and .NET?
> 
> 
> It means using SharpMap i can load shapfiles to PostGIS, perform the
> query and finally have the result in shapefile format? Am i right?
> Thanks in advance
> 
> 
> ----- Original Message ----
> From: "Obe, Regina" <robe.dnd at cityofboston.gov>
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>;
> postgis-users at postgis.refractions.net
> Sent: Tuesday, July 15, 2008 10:10:39 PM
> Subject: RE: [postgis-users] newbie question: PostGIS and .NET?
> 
> 
> David,
>  
> Have him take a look at SharpMap.  Its got .NET drivers for PostGIS and
> other layer types.
>  
> http://www.codeplex.com/SharpMap
>  
> It works for both ASP.NET and windows .net apps.
>  
> Hope that helps,
> Regina
>  
>  
>  
>  
> 
> ________________________________
> 
> From: postgis-users-bounces at postgis.refractions.net on behalf of Jean
> David TECHER
> Sent: Tue 7/15/2008 2:32 PM
> To: postgis-users at postgis.refractions.net
> Subject: Re: [postgis-users] newbie question: PostGIS and .NET?
> 
> 
> 
> 
> Quoting Saka Royban <srph124 at yahoo.com>:
> 
> > Hi all.
> > Sorry for elementary question. but i didn't find anything to support 
> >  PostGIS in .NET environment.
> > just some driver for Java.
> > I mainly wanna make a desktop GIS applications and it sounds PostGIS 
> >  helpful to be used as a back-end to manage large number of  
> > shapefiles. So, is there a way to use this spatial database in .NET?
> For PostgreSQL you have Npgsql that support PostgreSQL queries
> 
> 
> > Queries support by PostGIS are excellent but i need to have export  
> > of SQL commands in shapefile.
> 
> You have pgsql2shp that could do it! Perhaps need to use API to .net?
> 
> > Thanks
> >
> > saka
> >
> >
> >
> >
> 
> 
> 
> ===================
> Jean David TECHER
> 06 60 46 85 05
> 04 99 77 17 87
> ===================
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> ________________________________
> 
> The substance of this message, including any attachments, may be
> confidential, legally privileged and/or exempt from disclosure pursuant
> to Massachusetts law. It is intended solely for the addressee. If you
> received this in error, please contact the sender and delete the
> material from any computer. 
> 
> ________________________________
> 
> Help make the earth a greener place. If at all possible resist printing
> this email and join us in saving paper. 
> 
> 
> -----------------------------------------
> The substance of this message, including any attachments, may be
> confidential, legally privileged and/or exempt from disclosure
> pursuant to Massachusetts law. It is intended
> solely for the addressee. If you received this in error, please
> contact the sender and delete the material from any computer.
> 
> 
> 
> ------------------------------
> 
> Message: 9
> Date: Wed, 16 Jul 2008 07:07:09 -0400
> From: "Obe, Regina" <robe.dnd at cityofboston.gov>
> Subject: RE: [postgis-users] contains syntax
> To: "PostGIS Users Discussion" <postgis-users at postgis.refractions.net>
> Message-ID:
> 	<53F9CF533E1AA14EA1F8C5C08ABC08D204623CFC at ZDND.DND.boston.cob>
> Content-Type: text/plain;	charset="us-ascii"
> 
> Jo,
> Your update syntax should be
> 
> UPDATE standorte 
> 	SET lk = l.lk 
> 	FROM landkreise as l
> WHERE 
> ST_Contains(l.the_geom,standorte.the_geom) = TRUE;
> 
> Note - your below query is not using indexes.  If you are using Postgis
> 1.2.1 or above, use the new
> 
> ST_Contains instead (that will use indexes since it automagically adds
> the && operator)
> 
> If you are using older PostGIS, then use
> 
> l.the_geom && s.the_geom AND Contains(l.the_geom, s.the_geom)
> 
> Hope that helps,
> Regina
>  
> 
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
> jj.wag at gmx.de
> Sent: Wednesday, July 16, 2008 6:18 AM
> To: postgis-users at postgis.refractions.net
> Subject: [postgis-users] contains syntax
> 
> Hi all,
> 
> I have 2 tables:
> 
> 1. table "landkreise" (polygon) with column "lk" (names of
> administrative 
> borders (polygons))
> 2. standorte (point) with column "lk" (empty, I want to write the name
> of 
> the administrative borders from the polygon-feature that contains the
> point)
> 
> When I use following select-statement it seems to work:
> 
> SELECT l.lk FROM landkreise as l, standorte as s WHERE 
> contains(l.the_geom,s.the_geom) = TRUE;
> 
> When I want to update the column "lk" in table standorte allways the
> same 
> name is written:
> 
> UPDATE standorte SET lk = l.lk FROM landkreise as l, standorte AS s
> WHERE 
> contains(l.the_geom,s.the_geom) = TRUE;
> 
> What is wrong with my syntax?
> 
> Thanks
> Jo
> 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> -----------------------------------------
> The substance of this message, including any attachments, may be
> confidential, legally privileged and/or exempt from disclosure
> pursuant to Massachusetts law. It is intended
> solely for the addressee. If you received this in error, please
> contact the sender and delete the material from any computer.
> 
> 
> 
> ------------------------------
> 
> Message: 10
> Date: Wed, 16 Jul 2008 06:00:38 -0700 (PDT)
> From: Saka Royban <srph124 at yahoo.com>
> Subject: Re: [postgis-users] newbie question: PostGIS and .NET?
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> Message-ID: <285528.51138.qm at web58214.mail.re3.yahoo.com>
> Content-Type: text/plain; charset="us-ascii"
> 
> Very helpful
> Thanks
> 
> 
> 
> ----- Original Message ----
> From: "Obe, Regina" <robe.dnd at cityofboston.gov>
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> Sent: Wednesday, July 16, 2008 2:08:46 PM
> Subject: RE: [postgis-users] newbie question: PostGIS and .NET?
> 
> Well you could load shape files with SharpMap directly into PostGIS
> since it supports both types but you would have to roll your own a bit,
> although you can encode the password info etc which you can't with
> shp2pgsql. 
> 
> SharpMap is more designed for if you already have data in PostGIS and
> you want to query it from PostGIS and display it without having to dump
> to shape file format first. 
> 
> If you just want a shape file to PostGIS loader  - may be easier to just
> call shp2pgsql or ogr2ogr using the .NET Process class, which is
> described here
> http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx 
> .  
> 
> I haven't had a need to do that for loading shape files, but I use the
> process class for doing xcopy all the time (from one server to another)
> 
> .NET Process class  would look something like this I imagine -- you may
> need to fiddle with security, pemissions etc.  I have never tested this
> so not sure what issues would arise or if you can even do a | using
> process.  You may need to dump to sql and then load sql file first.
> 
>    Process.Start("path/to/shp2pgsql", " -s 4269 -I someshapefile
> somepgtable | psql -h someserver -d gisdb -U somepguser")
> 
> Hope that helps,
> Regina
> 
> 
> 
> 
> 
> 
> 
> ________________________________
> 
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Saka
> Royban
> Sent: Wednesday, July 16, 2008 6:16 AM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] newbie question: PostGIS and .NET?
> 
> 
> It means using SharpMap i can load shapfiles to PostGIS, perform the
> query and finally have the result in shapefile format? Am i right?
> Thanks in advance
> 
> 
> ----- Original Message ----
> From: "Obe, Regina" <robe.dnd at cityofboston.gov>
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>;
> postgis-users at postgis.refractions.net
> Sent: Tuesday, July 15, 2008 10:10:39 PM
> Subject: RE: [postgis-users] newbie question: PostGIS and .NET?
> 
> 
> David,
> 
> Have him take a look at SharpMap.  Its got .NET drivers for PostGIS and
> other layer types.
> 
> http://www.codeplex.com/SharpMap 
> 
> It works for both ASP.NET and windows .net apps.
> 
> Hope that helps,
> Regina
> 
> 
> 
> 
> 
> ________________________________
> 
> From: postgis-users-bounces at postgis.refractions.net on behalf of Jean
> David TECHER
> Sent: Tue 7/15/2008 2:32 PM
> To: postgis-users at postgis.refractions.net
> Subject: Re: [postgis-users] newbie question: PostGIS and .NET?
> 
> 
> 
> 
> Quoting Saka Royban <srph124 at yahoo.com>:
> 
> > Hi all.
> > Sorry for elementary question. but i didn't find anything to support 
> >  PostGIS in .NET environment.
> > just some driver for Java.
> > I mainly wanna make a desktop GIS applications and it sounds PostGIS 
> >  helpful to be used as a back-end to manage large number of  
> > shapefiles. So, is there a way to use this spatial database in .NET?
> For PostgreSQL you have Npgsql that support PostgreSQL queries
> 
> 
> > Queries support by PostGIS are excellent but i need to have export  
> > of SQL commands in shapefile.
> 
> You have pgsql2shp that could do it! Perhaps need to use API to .net?
> 
> > Thanks
> >
> > saka
> >
> >
> >
> >
> 
> 
> 
> ===================
> Jean David TECHER
> 06 60 46 85 05
> 04 99 77 17 87
> ===================
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users 
> 
> 
> ________________________________
> 
> The substance of this message, including any attachments, may be
> confidential, legally privileged and/or exempt from disclosure pursuant
> to Massachusetts law. It is intended solely for the addressee. If you
> received this in error, please contact the sender and delete the
> material from any computer. 
> 
> ________________________________
> 
> Help make the earth a greener place. If at all possible resist printing
> this email and join us in saving paper. 
> 
> 
> -----------------------------------------
> The substance of this message, including any attachments, may be
> confidential, legally privileged and/or exempt from disclosure
> pursuant to Massachusetts law. It is intended
> solely for the addressee. If you received this in error, please
> contact the sender and delete the material from any computer.
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> 
>       
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.refractions.net/pipermail/postgis-users/attachments/20080716/6f35a38f/attachment-0001.html
> 
> ------------------------------
> 
> Message: 11
> Date: Wed, 16 Jul 2008 06:11:18 -0700
> From: Chris Hermansen <chris.hermansen at timberline.ca>
> Subject: Re: [postgis-users] Windows Crash
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> Message-ID: <487DF376.20308 at timberline.ca>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Heck, Regina, you certainly didn't offend me.  I just didn't find any 
> useful information on that site.  It reminded me of the talking heads 
> seen on news channels.  The discussion of the 4.0 release of KDE for 
> example - on and on and on and on about how stupid it was to release KDE 
> 4.0 in that state.  OK, we get the point, next?
> 
> I guess anyone with enough starch in their boxers could write something 
> equally negative about pretty much anything - Windows, OS/X, gardening, 
> string theory, waste management.  Maybe even about PostGIS!  :-) :-)  I 
> just don't personally see a whole lot of point in being so 
> single-mindedly provocative.
> 
> Really, I guess this holds especially true in relation to open source.  
> Why spend a LOT of energy criticizing it, when it's possible to spend 
> the same amount of time improving it?  Instead of carping, file bug 
> reports or enhancement reports or whatever.  Write code.  Write 
> documentation.  Write tutorials.  Help people out on mailing lists!
> 
> If you believe that Windows is better than Linux because various Linux 
> distros offer too many choices when it comes to package managers or 
> whatever, that's a good reason for you to use Windows.  For me, it's a 
> good reason to pick a good Linux distro and stay with it for awhile.  
> Both valid points of view, I think.
> 
> You're right about this being off-topic, but to try to bring it back a 
> bit - you help people out a HUGE amount on this list.  You are a 
> significant contributor to the success of us all in our day to day use 
> of PostGIS.  I think it's fair to say that PostGIS, and many other 
> things like PostGIS, would not exist if it were not for you and other 
> similar-minded people.
> 
> So thanks!  Thanks for all the individual and specific bits of help you 
> give to people, and thanks even more for seeing value - to you and to 
> others - in the activity of supporting us all on this list.
> 
> Obe, Regina wrote:
> > Chris,
> >
> > I apologize if I offended anyone here.  I guess this really was very
> > off-topic and probably was inappropriate for this list.
> >
> > >From a monetary stand-point humor sales and if you amass enough audience
> > you can get a lot of advertising revenue.
> >
> > I think its a matter of opininion and not taking yourself too seriously
> > also. Most people take themselves too seriously and get offended easily
> > when you suggest something they are doing is not peachy.  
> >
> > I personally found the site educational.  I think there are silly things
> > that all sides of the fence do and to pretend these silly things don't
> > exist is not doing anyone any good. People who complain about things get
> > results.  As they say the squeaky wheel gets the grease.
> >
> > There are things in Linux I absolutely love, but it does frustrate me a
> > bit that each Linux distro is very different.  I open up OpenSuse -
> > there's yahtz or whatever, Redhat has YUM and the place they decide to
> > install things is slightly different between Fedora and EL, and Ubuntu
> > (well I haven't really used that enough to complain about it - except it
> > has its apt-get and its apt-get crashed my last pc when I tried to
> > upgrade my open office). But that is all of minor consequence - I'm sure
> > if I dug deeper I would see a reason why no one can decide where to put
> > things.
> >
> > Similar things can be said about Windows and MacOSX I am sure.  Although
> > I guess I've been drinking the Windows cool-aid for so long that I can't
> > think of anything bad to say about it except its command-line sucks
> > compared to Linux - but its new Windows Powershell interface is changing
> > all of that (so now I can run rm and ls and some of those other great
> > commands I learned in my Linux world in windows).  Makes me wonder hey -
> > is Microsoft secretly injecting some unix juice in their system.  I
> > expect their new upcoming OS to be "Hey guys we are Unix too".
> >
> > Thanks,
> > Regina
> >
> >
> > -----Original Message-----
> > From: postgis-users-bounces at postgis.refractions.net
> > [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
> > Chris Hermansen
> > Sent: Sunday, July 13, 2008 1:47 PM
> > To: PostGIS Users Discussion
> > Subject: Re: [postgis-users] Windows Crash
> >
> > Regina, all;
> >
> > I read the top four articles on this blog and I guess I just don't 
> > understand why someone would waste their valuable (?) time writing such 
> > pointless material, whether the topic be Windows or Linux or OS/X or 
> > whatever.
> >
> > Obe, Regina wrote:
> >   
> >> Slightly off topic.  Has anyone seen this Linux Haters Blog.  All 
> >> Linux users should read it to understand how the mind of a windows 
> >> user works so that we can interoperate.
> >>  
> >> http://linuxhaters.blogspot.com/
> >>  
> >> Similarly I would like to see a windows haters blog so I can form a 
> >> fully unbiased opinion of the various factions.  Is there such a
> >>     
> > thing?
> >   
> >>     
> > ------------------------------------------------------------------------
> >   
> >> *From:* postgis-users-bounces at postgis.refractions.net 
> >> [mailto:postgis-users-bounces at postgis.refractions.net] *On Behalf Of 
> >> *Bruce Rindahl
> >> *Sent:* Thursday, June 26, 2008 3:53 PM
> >> *To:* PostGIS Users Discussion
> >> *Subject:* Re: [postgis-users] Windows Crash
> >>
> >> Also on a long shot - do you have any hardware conflicts?
> >> Start->Control Panel->System->Hardware->Device Manager
> >> Are there any little yellow info symbols?
> >> Bruce
> >>
> >> Paul Ramsey wrote:
> >>     
> >>> This is in no way a PostGIS problem, certainly nothing we can ever
> >>> fix, just something that the particular combination of PgAdmin, the
> >>> geometry we are feeding it, and the way the Windows rendering system
> >>> are interacting.
> >>>
> >>> My experience has been that these days the thing that causes a modern
> >>> operating system (Windows, Linux, whatever) to crash is bad hardware,
> >>> usually bad memory, but sometimes other things. Basically, the
> >>> operating system itself is usually rock solid until you shake the
> >>> foundations it sits on, the hardware.
> >>>
> >>> So basically, all I can offer is the doctor's advice to the patient
> >>> who said "doctor, doctor, it hurts when I raise my arm over my
> >>> head!"... "don't raise your arm over your head".
> >>>
> >>> In the meantime, if you want to fiddle with things, swapping the
> >>>       
> > order
> >   
> >>> of your memory in the sockets, changing out the video card, even
> >>> changing your screen resolution, might change the interaction such
> >>> that you can exercise this particular use case without dropping your
> >>> OS to the floor.
> >>>
> >>> P.
> >>>
> >>> On Thu, Jun 26, 2008 at 10:31 AM, Obe, Regina
> >>>       
> > <robe.dnd at cityofboston.gov> wrote:
> >   
> >>>   
> >>>       
> >>>> I second Bruce's comment about unhelpful comments.
> >>>>
> >>>> It may actually have nothing to do with Windows in fact.
> >>>>
> >>>> Now getting back to the crash issue.  Bob if you are still having
> >>>>         
> > the same
> >   
> >>>> issue with that file, maybe you can post that (or provide a link to
> >>>>         
> > the
> >   
> >>>> shape file you loaded).  It could be something to do with the
> >>>>         
> > shapefile.
> >   
> >>>> I recall having this same issue with one particular geometry file
> >>>>         
> > way back
> >   
> >>>> in PgAdmin 1.6 and it was when I scrolled to a specific record it
> >>>>         
> > would
> >   
> >>>> crash, but then later additions (I either maybe never selected the
> >>>>         
> > geometry
> >   
> >>>> field again) or it was fixed in later versions.  Doing an AsText
> >>>> always seemed to work where as displaying the raw binary was where I
> >>>>         
> > ran
> >   
> >>>> into issues.
> >>>>
> >>>> The other possibility is that it could be a defective graphics card.
> >>>>         
> > I
> >   
> >>>> forget which video cards I had bad runs with, but I remember having
> >>>>         
> > this
> >   
> >>>> same exact issue with my favorite programming editor JEdit.  I had 2
> >>>> identical computers with same drivers etc and for some reason I
> >>>>         
> > would get
> >   
> >>>> intermittent crashes on one of them.  I finally just got fed up and
> >>>>         
> > replaced
> >   
> >>>> the graphics card and then it worked fine.
> >>>>
> >>>> Just some thoughts.
> >>>>
> >>>> Thanks,
> >>>> Regina
> >>>>
> >>>>
> >>>>
> >>>> ________________________________
> >>>>
> >>>> The substance of this message, including any attachments, may be
> >>>> confidential, legally privileged and/or exempt from disclosure
> >>>>         
> > pursuant to
> >   
> >>>> Massachusetts law. It is intended solely for the addressee. If you
> >>>>         
> > received
> >   
> >>>> this in error, please contact the sender and delete the material
> >>>>         
> > from any
> >   
> >>>> computer.
> >>>>
> >>>> ________________________________
> >>>>
> >>>> Help make the earth a greener place. If at all possible resist
> >>>>         
> > printing this
> >   
> >>>> email and join us in saving paper.
> >>>>
> >>>> _______________________________________________
> >>>> postgis-users mailing list
> >>>> postgis-users at postgis.refractions.net
> >>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>>
> >>>>
> >>>>     
> >>>>         
> >>> _______________________________________________
> >>> postgis-users mailing list
> >>> postgis-users at postgis.refractions.net
> >>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>
> >>>
> >>>   
> >>>       
> >>     
> > ------------------------------------------------------------------------
> >   
> >> *The substance of this message, including any attachments, may be 
> >> confidential, legally privileged and/or exempt from disclosure 
> >> pursuant to Massachusetts law. It is intended solely for the 
> >> addressee. If you received this in error, please contact the sender 
> >> and delete the material from any computer. *
> >>
> >>
> >>     
> > ------------------------------------------------------------------------
> >   
> >> * Help make the earth a greener place. If at all possible resist 
> >> printing this email and join us in saving paper. *
> >>
> >> * *
> >>
> >> * *
> >>
> >>
> >>     
> > ------------------------------------------------------------------------
> >   
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>   
> >>     
> >
> >
> >   
> 
> 
> -- 
> Regards,
> 
> Chris Hermansen         mailto:chris.hermansen at timberline.ca
> tel+1.604.714.2878 · fax+1.604.733.0631 · mob+1.778.232.0644
> Timberline Natural Resource Group · http://www.timberline.ca
> 401 · 958 West 8th Avenue  · Vancouver BC · Canada · V5Z 1E5
> 
> 
> 
> ------------------------------
> 
> Message: 12
> Date: Wed, 16 Jul 2008 10:24:25 -0500
> From: Stephen Woodbridge <woodbri at swoodbridge.com>
> Subject: Re: [postgis-users] match line with road segment
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> Message-ID: <487E12A9.2070705 at swoodbridge.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> searchelite wrote:
> > hi all..
> > i have a line table consists of gps points, i'm using
> > ST_makeline(gps_points) to create the line..my question is, how to match the
> > gps line into road segment in postgis? 
> > 
> > thank you
> 
> You can buffer the line and see which segments fall inside the buffer.
> 
> select * from roads
>   where ST_Contains(the_geom, ST_makeline(gps_points));
> 
> -Steve
> 
> 
> ------------------------------
> 
> Message: 13
> Date: Wed, 16 Jul 2008 10:13:19 -0600
> From: Brent Fraser <bfraser at geoanalytic.com>
> Subject: Re: [postgis-users] Transform overlapping polygons to
> 	non-overlapping?
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> Message-ID: <487E1E1F.9070409 at geoanalytic.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> To all,
> 
>   My quest for non-overlapping polygons continues:
> 
> I started with a table (temp_polys) of 3253 polygons (with some overlap) with a "class" attribute.
> 
> To get rid of overlapping polys with the same class value:
> 	CREATE TABLE temp2_polys as SELECT class, ST_UNION(the_geom) from temp_polys GROUP BY class;
> 
> This created a table of 32 multi-polygons (grouped by class).  I still have to remove the overlap between polygons with different class values, so my plan is to convert to linestrings, node the linestrings, polygonize, and (re)assign the class value using StarSpan. So first:
> 
> Convert to linestrings:
> 	INSERT INTO temp3_lines (the_geom) SELECT ST_ExteriorRing( ST_GeometryN(the_geom, generate_series(1, ST_NumGeometries(the_geom)))) AS the_geom FROM temp2_polys;
> 
> This produced 1768 linestring records.  Attempting to node the linestrings:
> 	INSERT INTO temp4_lines (the_geom) SELECT St_Union(the_geom) AS the_geom FROM temp3_lines;
> 
> Yikes!  This query ran for 4.5 hours and crashed Postgres (1.8 gHz Windows XP, Postgres 8.3.3, PostGIS 1.3.3).
> 
> I dumped the temp3_lines table into a shapefile and asked OpenJump to node AND polygonize.  That took 24 seconds.
> 
> Since the above data is a small sub-set of my 1.2 million polygons, OpenJump is not really a solution for cleaning the data all at once.  Looks like some scripting is in order...
> 
> Brent
> 
> 
> Brent Fraser wrote:
> > Regina,
> > 
> >  The "SELECT MAX..." query didn't work on my sub-set of 12800 polygons.  
> > It created 12643 polygons some of which overlap (I expected more, not 
> > less, than the original).
> > 
> >  I may try converting to linestrings, creating one "minimum bounding 
> > rectangle" for the entire dataset, then doing an intersect of the lines 
> > with the MBR.  In my case this would be ok as there are not attributes 
> > on the polygons yet.
> > 
> > Thanks!
> > Brent
> > 
> > Obe, Regina wrote:
> >> Brent,
> >>  
> >> I guess it really depends on how exactly you want to achieve 
> >> non-overlapping.
> >> If for example you are basing it on some sort of attribute and all 
> >> your overlapping polygons are valid
> >>  
> >> Then a simple
> >>  
> >> SELECT ST_Union(the_geom) As newgeom, field1
> >> FROM sometable
> >> GROUP BY field1
> >>  
> >> I think will guarantee non-overlapping polygons because as part of the 
> >> process of ST_Union - it would irradicate the overlapping regions to 
> >> just create one.  That is part of the reason why its so much slower 
> >> than ST_Collect for example.
> >>  
> >> For your exact case below - you would union all the overlapping 
> >> polygons together which could be really slow depending on how many 
> >> overlap. The query I would write to achieve that would be something 
> >> like this
> >>  
> >> SELECT MAX(a.gid) As newgid, ST_Union(a.the_geom) As the_geom
> >> FROM poly a
> >> GROUP BY (SELECT MAX(r.gid) FROM poly r
> >>    WHERE (a.gid = r.gid OR ST_Overlaps(r.the_geom, a.the_geom)));
> >>  
> >> Hope that helps,
> >> Regina
> >>
> >> ------------------------------------------------------------------------
> >> *From:* postgis-users-bounces at postgis.refractions.net on behalf of 
> >> Brent Fraser
> >> *Sent:* Fri 7/11/2008 12:14 PM
> >> *To:* PostGIS Users Discussion
> >> *Subject:* Re: [postgis-users] Transform overlapping polygons to 
> >> non-overlapping?
> >>
> >> To All,
> >>
> >>   There doesn't seem to be an obvious answer to the problem given 
> >> below (aka cleaning polygons, creating planar polygons, etc).  I did 
> >> see a note on the PostGIS wiki wishlist to "Add a geometry cleaner". 
> >> There is also a suggestion to convert to linestrings, node, then 
> >> polygonize (while that may work for a small set of polygons, I've got 
> >> 1.1 million to clean).  JTS, Geos, etc will likely fail due to the 
> >> large number of polygons so I'll need a different approach.
> >>
> >>   I'm considering writing some code to iterate through my table of 
> >> polygons, cleaning a small subset at a time.  I think using PostGIS 
> >> for the geometry storage and spatial query/selection makes sense.  Any 
> >> suggestions on which API to use?
> >>         GDAL's OGR
> >>         PostgreSQL's libpq
> >>         other?
> >>
> >> Thanks!
> >> Brent Fraser
> >>
> >> Brent Fraser wrote:
> >>>  PostGIS'ers,
> >>>
> >>>  I've got a table of overlapping polygons.  How can I make it a table of
> >>>  non-overlapping polygons?
> >>>
> >>>  For example, if table "polys2" contains two polygons A1 and B1 which
> >>>  overlap.  I'd like to create table "polys3" with polygons A2, B2, C2,
> >>>  where C2 is the overlap region of A1 and B1, and A2 = A1 - C2, and B2 =
> >>>  B1 - C2.
> >>>
> >>>  Looking at the overlay operations in the JTS doc it looks like doing an
> >>>  Intersection (to get only the overlapping area) then adding the
> >>>  Symmetric Difference (to get the non-overlapping areas) might work.
> >>>
> >>>  Am I on the right track or is there an easier way (since all the
> >>>  polygons are in one table)?
> >>>
> >>>  Thanks!
> >>>  Brent Fraser
> >>>  _______________________________________________
> >>>  postgis-users mailing list
> >>>  postgis-users at postgis.refractions.net
> >>>  http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> >> ------------------------------------------------------------------------
> >>
> >> * The substance of this message, including any attachments, may be 
> >> confidential, legally privileged and/or exempt from disclosure 
> >> pursuant to Massachusetts law. It is intended solely for the 
> >> addressee. If you received this in error, please contact the sender 
> >> and delete the material from any computer. *
> >>
> >> ------------------------------------------------------------------------
> >>
> >> * Help make the earth a greener place. If at all possible resist 
> >> printing this email and join us in saving paper. *
> >>
> >> * *
> >>
> >> * *
> >>
> >>
> >> ------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> > 
> 
> 
> ------------------------------
> 
> Message: 14
> Date: Wed, 16 Jul 2008 12:40:49 -0400
> From: "Paragon Corporation" <lr at pcorp.us>
> Subject: RE: [postgis-users] Transform overlapping polygons to
> 	non-overlapping?
> To: "'PostGIS Users Discussion'"
> 	<postgis-users at postgis.refractions.net>
> Message-ID: <9ECA0A60357B4AF2AFA91EECE971CA8F at H>
> Content-Type: text/plain;	charset="us-ascii"
> 
> Brent,
> 
>  INSERT INTO temp3_lines (the_geom) 
> 	SELECT ST_ExteriorRing( ST_GeometryN(the_geom, generate_series(1,
> ST_NumGeometries(the_geom)))) AS the_geom FROM temp2_polys;
> 
> Can be done more efficiently using ST_Dump
> 
>  INSERT INTO temp3_lines (the_geom) 
> 	SELECT ST_ExteriorRing((ST_Dump(the_geom)).geom) AS the_geom FROM
> temp2_polys;
> 
> 
> Regarding the unioning I mentioned - I thought about more why what I
> proposed had still overlapping polygons and I realized its because the
> grouping I proposed needs to be 
> A recursive query (which means you'd need to wrap it in an sql or plpgsql
> function)  since as it stands it would only find the first root overlaps and
> not the A overlap B overlap C  (e.g. c would not be in the same grouping and
> A,B if it doesn't also overlap with A) .
> 
> So two ways
> 1) Write recursive query (using a plpgsql or sql helper function) - which I
> haven't given much thought to the most efficient way of doing that
> 
> Or
> 
> 2) Repeat the union thing I mentioned over and over again until you have a
> set that has no more overlapping polygons.
> 
> Then you do a ST_Dump to get back individual polygons.
> 
> Hope that helps,
> Regina
> 
> 
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Brent
> Fraser
> Sent: Wednesday, July 16, 2008 12:13 PM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] Transform overlapping polygons to
> non-overlapping?
> 
> To all,
> 
>   My quest for non-overlapping polygons continues:
> 
> I started with a table (temp_polys) of 3253 polygons (with some overlap)
> with a "class" attribute.
> 
> To get rid of overlapping polys with the same class value:
> 	CREATE TABLE temp2_polys as SELECT class, ST_UNION(the_geom) from
> temp_polys GROUP BY class;
> 
> This created a table of 32 multi-polygons (grouped by class).  I still have
> to remove the overlap between polygons with different class values, so my
> plan is to convert to linestrings, node the linestrings, polygonize, and
> (re)assign the class value using StarSpan. So first:
> 
> Convert to linestrings:
> 	INSERT INTO temp3_lines (the_geom) SELECT ST_ExteriorRing(
> ST_GeometryN(the_geom, generate_series(1, ST_NumGeometries(the_geom)))) AS
> the_geom FROM temp2_polys;
> 
> This produced 1768 linestring records.  Attempting to node the linestrings:
> 	INSERT INTO temp4_lines (the_geom) SELECT St_Union(the_geom) AS
> the_geom FROM temp3_lines;
> 
> Yikes!  This query ran for 4.5 hours and crashed Postgres (1.8 gHz Windows
> XP, Postgres 8.3.3, PostGIS 1.3.3).
> 
> I dumped the temp3_lines table into a shapefile and asked OpenJump to node
> AND polygonize.  That took 24 seconds.
> 
> Since the above data is a small sub-set of my 1.2 million polygons, OpenJump
> is not really a solution for cleaning the data all at once.  Looks like some
> scripting is in order...
> 
> Brent
> 
> 
> Brent Fraser wrote:
> > Regina,
> > 
> >  The "SELECT MAX..." query didn't work on my sub-set of 12800 polygons.  
> > It created 12643 polygons some of which overlap (I expected more, not 
> > less, than the original).
> > 
> >  I may try converting to linestrings, creating one "minimum bounding 
> > rectangle" for the entire dataset, then doing an intersect of the 
> > lines with the MBR.  In my case this would be ok as there are not 
> > attributes on the polygons yet.
> > 
> > Thanks!
> > Brent
> > 
> > Obe, Regina wrote:
> >> Brent,
> >>  
> >> I guess it really depends on how exactly you want to achieve 
> >> non-overlapping.
> >> If for example you are basing it on some sort of attribute and all 
> >> your overlapping polygons are valid
> >>  
> >> Then a simple
> >>  
> >> SELECT ST_Union(the_geom) As newgeom, field1 FROM sometable GROUP BY 
> >> field1
> >>  
> >> I think will guarantee non-overlapping polygons because as part of 
> >> the process of ST_Union - it would irradicate the overlapping regions 
> >> to just create one.  That is part of the reason why its so much 
> >> slower than ST_Collect for example.
> >>  
> >> For your exact case below - you would union all the overlapping 
> >> polygons together which could be really slow depending on how many 
> >> overlap. The query I would write to achieve that would be something 
> >> like this
> >>  
> >> SELECT MAX(a.gid) As newgid, ST_Union(a.the_geom) As the_geom FROM 
> >> poly a GROUP BY (SELECT MAX(r.gid) FROM poly r
> >>    WHERE (a.gid = r.gid OR ST_Overlaps(r.the_geom, a.the_geom)));
> >>  
> >> Hope that helps,
> >> Regina
> >>
> >> ---------------------------------------------------------------------
> >> ---
> >> *From:* postgis-users-bounces at postgis.refractions.net on behalf of 
> >> Brent Fraser
> >> *Sent:* Fri 7/11/2008 12:14 PM
> >> *To:* PostGIS Users Discussion
> >> *Subject:* Re: [postgis-users] Transform overlapping polygons to 
> >> non-overlapping?
> >>
> >> To All,
> >>
> >>   There doesn't seem to be an obvious answer to the problem given 
> >> below (aka cleaning polygons, creating planar polygons, etc).  I did 
> >> see a note on the PostGIS wiki wishlist to "Add a geometry cleaner".
> >> There is also a suggestion to convert to linestrings, node, then 
> >> polygonize (while that may work for a small set of polygons, I've got
> >> 1.1 million to clean).  JTS, Geos, etc will likely fail due to the 
> >> large number of polygons so I'll need a different approach.
> >>
> >>   I'm considering writing some code to iterate through my table of 
> >> polygons, cleaning a small subset at a time.  I think using PostGIS 
> >> for the geometry storage and spatial query/selection makes sense.  
> >> Any suggestions on which API to use?
> >>         GDAL's OGR
> >>         PostgreSQL's libpq
> >>         other?
> >>
> >> Thanks!
> >> Brent Fraser
> >>
> >> Brent Fraser wrote:
> >>>  PostGIS'ers,
> >>>
> >>>  I've got a table of overlapping polygons.  How can I make it a 
> >>> table of  non-overlapping polygons?
> >>>
> >>>  For example, if table "polys2" contains two polygons A1 and B1 
> >>> which  overlap.  I'd like to create table "polys3" with polygons A2, 
> >>> B2, C2,  where C2 is the overlap region of A1 and B1, and A2 = A1 - 
> >>> C2, and B2 =
> >>>  B1 - C2.
> >>>
> >>>  Looking at the overlay operations in the JTS doc it looks like 
> >>> doing an  Intersection (to get only the overlapping area) then 
> >>> adding the  Symmetric Difference (to get the non-overlapping areas)
> might work.
> >>>
> >>>  Am I on the right track or is there an easier way (since all the  
> >>> polygons are in one table)?
> >>>
> >>>  Thanks!
> >>>  Brent Fraser
> >>>  _______________________________________________
> >>>  postgis-users mailing list
> >>>  postgis-users at postgis.refractions.net
> >>>  http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> >> ---------------------------------------------------------------------
> >> ---
> >>
> >> * The substance of this message, including any attachments, may be 
> >> confidential, legally privileged and/or exempt from disclosure 
> >> pursuant to Massachusetts law. It is intended solely for the 
> >> addressee. If you received this in error, please contact the sender 
> >> and delete the material from any computer. *
> >>
> >> ---------------------------------------------------------------------
> >> ---
> >>
> >> * Help make the earth a greener place. If at all possible resist 
> >> printing this email and join us in saving paper. *
> >>
> >> * *
> >>
> >> * *
> >>
> >>
> >> ---------------------------------------------------------------------
> >> ---
> >>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> > 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> 
> 
> ------------------------------
> 
> Message: 15
> Date: Wed, 16 Jul 2008 13:05:59 -0400
> From: "Paragon Corporation" <lr at pcorp.us>
> Subject: RE: [postgis-users] Transform overlapping polygons to
> 	non-overlapping?
> To: "'PostGIS Users Discussion'"
> 	<postgis-users at postgis.refractions.net>
> Message-ID: <2A0B206E275A48A791393C6AEE6CFFF0 at H>
> Content-Type: text/plain;	charset="us-ascii"
> 
> One more question -  you sure you want ST_Overlaps and not ST_Intersects.
> If one geometry sits completely inside another, it is not considered to
> overlap, but they do intersect. 
> 
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Paragon
> Corporation
> Sent: Wednesday, July 16, 2008 12:41 PM
> To: 'PostGIS Users Discussion'
> Subject: RE: [postgis-users] Transform overlapping polygons to
> non-overlapping?
> 
> Brent,
> 
>  INSERT INTO temp3_lines (the_geom) 
> 	SELECT ST_ExteriorRing( ST_GeometryN(the_geom, generate_series(1,
> ST_NumGeometries(the_geom)))) AS the_geom FROM temp2_polys;
> 
> Can be done more efficiently using ST_Dump
> 
>  INSERT INTO temp3_lines (the_geom) 
> 	SELECT ST_ExteriorRing((ST_Dump(the_geom)).geom) AS the_geom FROM
> temp2_polys;
> 
> 
> Regarding the unioning I mentioned - I thought about more why what I
> proposed had still overlapping polygons and I realized its because the
> grouping I proposed needs to be A recursive query (which means you'd need to
> wrap it in an sql or plpgsql
> function)  since as it stands it would only find the first root overlaps and
> not the A overlap B overlap C  (e.g. c would not be in the same grouping and
> A,B if it doesn't also overlap with A) .
> 
> So two ways
> 1) Write recursive query (using a plpgsql or sql helper function) - which I
> haven't given much thought to the most efficient way of doing that
> 
> Or
> 
> 2) Repeat the union thing I mentioned over and over again until you have a
> set that has no more overlapping polygons.
> 
> Then you do a ST_Dump to get back individual polygons.
> 
> Hope that helps,
> Regina
> 
> 
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Brent
> Fraser
> Sent: Wednesday, July 16, 2008 12:13 PM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] Transform overlapping polygons to
> non-overlapping?
> 
> To all,
> 
>   My quest for non-overlapping polygons continues:
> 
> I started with a table (temp_polys) of 3253 polygons (with some overlap)
> with a "class" attribute.
> 
> To get rid of overlapping polys with the same class value:
> 	CREATE TABLE temp2_polys as SELECT class, ST_UNION(the_geom) from
> temp_polys GROUP BY class;
> 
> This created a table of 32 multi-polygons (grouped by class).  I still have
> to remove the overlap between polygons with different class values, so my
> plan is to convert to linestrings, node the linestrings, polygonize, and
> (re)assign the class value using StarSpan. So first:
> 
> Convert to linestrings:
> 	INSERT INTO temp3_lines (the_geom) SELECT ST_ExteriorRing(
> ST_GeometryN(the_geom, generate_series(1, ST_NumGeometries(the_geom)))) AS
> the_geom FROM temp2_polys;
> 
> This produced 1768 linestring records.  Attempting to node the linestrings:
> 	INSERT INTO temp4_lines (the_geom) SELECT St_Union(the_geom) AS
> the_geom FROM temp3_lines;
> 
> Yikes!  This query ran for 4.5 hours and crashed Postgres (1.8 gHz Windows
> XP, Postgres 8.3.3, PostGIS 1.3.3).
> 
> I dumped the temp3_lines table into a shapefile and asked OpenJump to node
> AND polygonize.  That took 24 seconds.
> 
> Since the above data is a small sub-set of my 1.2 million polygons, OpenJump
> is not really a solution for cleaning the data all at once.  Looks like some
> scripting is in order...
> 
> Brent
> 
> 
> Brent Fraser wrote:
> > Regina,
> > 
> >  The "SELECT MAX..." query didn't work on my sub-set of 12800 polygons.  
> > It created 12643 polygons some of which overlap (I expected more, not 
> > less, than the original).
> > 
> >  I may try converting to linestrings, creating one "minimum bounding 
> > rectangle" for the entire dataset, then doing an intersect of the 
> > lines with the MBR.  In my case this would be ok as there are not 
> > attributes on the polygons yet.
> > 
> > Thanks!
> > Brent
> > 
> > Obe, Regina wrote:
> >> Brent,
> >>  
> >> I guess it really depends on how exactly you want to achieve 
> >> non-overlapping.
> >> If for example you are basing it on some sort of attribute and all 
> >> your overlapping polygons are valid
> >>  
> >> Then a simple
> >>  
> >> SELECT ST_Union(the_geom) As newgeom, field1 FROM sometable GROUP BY
> >> field1
> >>  
> >> I think will guarantee non-overlapping polygons because as part of 
> >> the process of ST_Union - it would irradicate the overlapping regions 
> >> to just create one.  That is part of the reason why its so much 
> >> slower than ST_Collect for example.
> >>  
> >> For your exact case below - you would union all the overlapping 
> >> polygons together which could be really slow depending on how many 
> >> overlap. The query I would write to achieve that would be something 
> >> like this
> >>  
> >> SELECT MAX(a.gid) As newgid, ST_Union(a.the_geom) As the_geom FROM 
> >> poly a GROUP BY (SELECT MAX(r.gid) FROM poly r
> >>    WHERE (a.gid = r.gid OR ST_Overlaps(r.the_geom, a.the_geom)));
> >>  
> >> Hope that helps,
> >> Regina
> >>
> >> ---------------------------------------------------------------------
> >> ---
> >> *From:* postgis-users-bounces at postgis.refractions.net on behalf of 
> >> Brent Fraser
> >> *Sent:* Fri 7/11/2008 12:14 PM
> >> *To:* PostGIS Users Discussion
> >> *Subject:* Re: [postgis-users] Transform overlapping polygons to 
> >> non-overlapping?
> >>
> >> To All,
> >>
> >>   There doesn't seem to be an obvious answer to the problem given 
> >> below (aka cleaning polygons, creating planar polygons, etc).  I did 
> >> see a note on the PostGIS wiki wishlist to "Add a geometry cleaner".
> >> There is also a suggestion to convert to linestrings, node, then 
> >> polygonize (while that may work for a small set of polygons, I've got
> >> 1.1 million to clean).  JTS, Geos, etc will likely fail due to the 
> >> large number of polygons so I'll need a different approach.
> >>
> >>   I'm considering writing some code to iterate through my table of 
> >> polygons, cleaning a small subset at a time.  I think using PostGIS 
> >> for the geometry storage and spatial query/selection makes sense.
> >> Any suggestions on which API to use?
> >>         GDAL's OGR
> >>         PostgreSQL's libpq
> >>         other?
> >>
> >> Thanks!
> >> Brent Fraser
> >>
> >> Brent Fraser wrote:
> >>>  PostGIS'ers,
> >>>
> >>>  I've got a table of overlapping polygons.  How can I make it a 
> >>> table of  non-overlapping polygons?
> >>>
> >>>  For example, if table "polys2" contains two polygons A1 and B1 
> >>> which  overlap.  I'd like to create table "polys3" with polygons A2, 
> >>> B2, C2,  where C2 is the overlap region of A1 and B1, and A2 = A1 - 
> >>> C2, and B2 =
> >>>  B1 - C2.
> >>>
> >>>  Looking at the overlay operations in the JTS doc it looks like 
> >>> doing an  Intersection (to get only the overlapping area) then 
> >>> adding the  Symmetric Difference (to get the non-overlapping areas)
> might work.
> >>>
> >>>  Am I on the right track or is there an easier way (since all the 
> >>> polygons are in one table)?
> >>>
> >>>  Thanks!
> >>>  Brent Fraser
> >>>  _______________________________________________
> >>>  postgis-users mailing list
> >>>  postgis-users at postgis.refractions.net
> >>>  http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> >> ---------------------------------------------------------------------
> >> ---
> >>
> >> * The substance of this message, including any attachments, may be 
> >> confidential, legally privileged and/or exempt from disclosure 
> >> pursuant to Massachusetts law. It is intended solely for the 
> >> addressee. If you received this in error, please contact the sender 
> >> and delete the material from any computer. *
> >>
> >> ---------------------------------------------------------------------
> >> ---
> >>
> >> * Help make the earth a greener place. If at all possible resist 
> >> printing this email and join us in saving paper. *
> >>
> >> * *
> >>
> >> * *
> >>
> >>
> >> ---------------------------------------------------------------------
> >> ---
> >>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> > 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> 
> 
> ------------------------------
> 
> Message: 16
> Date: Wed, 16 Jul 2008 11:58:07 -0600
> From: Brent Fraser <bfraser at geoanalytic.com>
> Subject: Re: [postgis-users] Transform overlapping polygons to
> 	non-overlapping?
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> Message-ID: <487E36AF.2020801 at geoanalytic.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Regina,
> 
>   I'm not convinced ST_Union is the way to go (using ST_Overlaps OR ST_Intersects as a condition).  Basically I want to iterate over the collection (recursively?) clipping one polygon to another until I'm left with no overlapping (or intersecting) polygons (planar topology).  This is sightly more complicated than the way I originally posed the problem (I wanted to created slivers from the overlapping areas to get planar topology).
> 
>   A little background:
> 
> 	My polygons represent a classification of vegetation of a large area of interest.  In theory any point in the area of interest must fall in one and only one polygon.  Due to an artifact of my image segmentation process, my polygons currently have slight overlap which I need to "dissolve" (and I don't care which polygon the overlap sliver gets dissolved into).
> 
> Thanks!
> Brent. 
> 
> Paragon Corporation wrote:
> > One more question -  you sure you want ST_Overlaps and not ST_Intersects.
> > If one geometry sits completely inside another, it is not considered to
> > overlap, but they do intersect. 
> > 
> > -----Original Message-----
> > From: postgis-users-bounces at postgis.refractions.net
> > [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Paragon
> > Corporation
> > Sent: Wednesday, July 16, 2008 12:41 PM
> > To: 'PostGIS Users Discussion'
> > Subject: RE: [postgis-users] Transform overlapping polygons to
> > non-overlapping?
> > 
> > Brent,
> > 
> >  INSERT INTO temp3_lines (the_geom) 
> > 	SELECT ST_ExteriorRing( ST_GeometryN(the_geom, generate_series(1,
> > ST_NumGeometries(the_geom)))) AS the_geom FROM temp2_polys;
> > 
> > Can be done more efficiently using ST_Dump
> > 
> >  INSERT INTO temp3_lines (the_geom) 
> > 	SELECT ST_ExteriorRing((ST_Dump(the_geom)).geom) AS the_geom FROM
> > temp2_polys;
> > 
> > 
> > Regarding the unioning I mentioned - I thought about more why what I
> > proposed had still overlapping polygons and I realized its because the
> > grouping I proposed needs to be A recursive query (which means you'd need to
> > wrap it in an sql or plpgsql
> > function)  since as it stands it would only find the first root overlaps and
> > not the A overlap B overlap C  (e.g. c would not be in the same grouping and
> > A,B if it doesn't also overlap with A) .
> > 
> > So two ways
> > 1) Write recursive query (using a plpgsql or sql helper function) - which I
> > haven't given much thought to the most efficient way of doing that
> > 
> > Or
> > 
> > 2) Repeat the union thing I mentioned over and over again until you have a
> > set that has no more overlapping polygons.
> > 
> > Then you do a ST_Dump to get back individual polygons.
> > 
> > Hope that helps,
> > Regina
> > 
> > 
> > -----Original Message-----
> > From: postgis-users-bounces at postgis.refractions.net
> > [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Brent
> > Fraser
> > Sent: Wednesday, July 16, 2008 12:13 PM
> > To: PostGIS Users Discussion
> > Subject: Re: [postgis-users] Transform overlapping polygons to
> > non-overlapping?
> > 
> > To all,
> > 
> >   My quest for non-overlapping polygons continues:
> > 
> > I started with a table (temp_polys) of 3253 polygons (with some overlap)
> > with a "class" attribute.
> > 
> > To get rid of overlapping polys with the same class value:
> > 	CREATE TABLE temp2_polys as SELECT class, ST_UNION(the_geom) from
> > temp_polys GROUP BY class;
> > 
> > This created a table of 32 multi-polygons (grouped by class).  I still have
> > to remove the overlap between polygons with different class values, so my
> > plan is to convert to linestrings, node the linestrings, polygonize, and
> > (re)assign the class value using StarSpan. So first:
> > 
> > Convert to linestrings:
> > 	INSERT INTO temp3_lines (the_geom) SELECT ST_ExteriorRing(
> > ST_GeometryN(the_geom, generate_series(1, ST_NumGeometries(the_geom)))) AS
> > the_geom FROM temp2_polys;
> > 
> > This produced 1768 linestring records.  Attempting to node the linestrings:
> > 	INSERT INTO temp4_lines (the_geom) SELECT St_Union(the_geom) AS
> > the_geom FROM temp3_lines;
> > 
> > Yikes!  This query ran for 4.5 hours and crashed Postgres (1.8 gHz Windows
> > XP, Postgres 8.3.3, PostGIS 1.3.3).
> > 
> > I dumped the temp3_lines table into a shapefile and asked OpenJump to node
> > AND polygonize.  That took 24 seconds.
> > 
> > Since the above data is a small sub-set of my 1.2 million polygons, OpenJump
> > is not really a solution for cleaning the data all at once.  Looks like some
> > scripting is in order...
> > 
> > Brent
> > 
> > 
> > Brent Fraser wrote:
> >> Regina,
> >>
> >>  The "SELECT MAX..." query didn't work on my sub-set of 12800 polygons.  
> >> It created 12643 polygons some of which overlap (I expected more, not 
> >> less, than the original).
> >>
> >>  I may try converting to linestrings, creating one "minimum bounding 
> >> rectangle" for the entire dataset, then doing an intersect of the 
> >> lines with the MBR.  In my case this would be ok as there are not 
> >> attributes on the polygons yet.
> >>
> >> Thanks!
> >> Brent
> >>
> >> Obe, Regina wrote:
> >>> Brent,
> >>>  
> >>> I guess it really depends on how exactly you want to achieve 
> >>> non-overlapping.
> >>> If for example you are basing it on some sort of attribute and all 
> >>> your overlapping polygons are valid
> >>>  
> >>> Then a simple
> >>>  
> >>> SELECT ST_Union(the_geom) As newgeom, field1 FROM sometable GROUP BY
> >>> field1
> >>>  
> >>> I think will guarantee non-overlapping polygons because as part of 
> >>> the process of ST_Union - it would irradicate the overlapping regions 
> >>> to just create one.  That is part of the reason why its so much 
> >>> slower than ST_Collect for example.
> >>>  
> >>> For your exact case below - you would union all the overlapping 
> >>> polygons together which could be really slow depending on how many 
> >>> overlap. The query I would write to achieve that would be something 
> >>> like this
> >>>  
> >>> SELECT MAX(a.gid) As newgid, ST_Union(a.the_geom) As the_geom FROM 
> >>> poly a GROUP BY (SELECT MAX(r.gid) FROM poly r
> >>>    WHERE (a.gid = r.gid OR ST_Overlaps(r.the_geom, a.the_geom)));
> >>>  
> >>> Hope that helps,
> >>> Regina
> >>>
> >>> ---------------------------------------------------------------------
> >>> ---
> >>> *From:* postgis-users-bounces at postgis.refractions.net on behalf of 
> >>> Brent Fraser
> >>> *Sent:* Fri 7/11/2008 12:14 PM
> >>> *To:* PostGIS Users Discussion
> >>> *Subject:* Re: [postgis-users] Transform overlapping polygons to 
> >>> non-overlapping?
> >>>
> >>> To All,
> >>>
> >>>   There doesn't seem to be an obvious answer to the problem given 
> >>> below (aka cleaning polygons, creating planar polygons, etc).  I did 
> >>> see a note on the PostGIS wiki wishlist to "Add a geometry cleaner".
> >>> There is also a suggestion to convert to linestrings, node, then 
> >>> polygonize (while that may work for a small set of polygons, I've got
> >>> 1.1 million to clean).  JTS, Geos, etc will likely fail due to the 
> >>> large number of polygons so I'll need a different approach.
> >>>
> >>>   I'm considering writing some code to iterate through my table of 
> >>> polygons, cleaning a small subset at a time.  I think using PostGIS 
> >>> for the geometry storage and spatial query/selection makes sense.
> >>> Any suggestions on which API to use?
> >>>         GDAL's OGR
> >>>         PostgreSQL's libpq
> >>>         other?
> >>>
> >>> Thanks!
> >>> Brent Fraser
> >>>
> >>> Brent Fraser wrote:
> >>>>  PostGIS'ers,
> >>>>
> >>>>  I've got a table of overlapping polygons.  How can I make it a 
> >>>> table of  non-overlapping polygons?
> >>>>
> >>>>  For example, if table "polys2" contains two polygons A1 and B1 
> >>>> which  overlap.  I'd like to create table "polys3" with polygons A2, 
> >>>> B2, C2,  where C2 is the overlap region of A1 and B1, and A2 = A1 - 
> >>>> C2, and B2 =
> >>>>  B1 - C2.
> >>>>
> >>>>  Looking at the overlay operations in the JTS doc it looks like 
> >>>> doing an  Intersection (to get only the overlapping area) then 
> >>>> adding the  Symmetric Difference (to get the non-overlapping areas)
> > might work.
> >>>>  Am I on the right track or is there an easier way (since all the 
> >>>> polygons are in one table)?
> >>>>
> >>>>  Thanks!
> >>>>  Brent Fraser
> >>>>  _______________________________________________
> >>>>  postgis-users mailing list
> >>>>  postgis-users at postgis.refractions.net
> >>>>  http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>>
> >>> _______________________________________________
> >>> postgis-users mailing list
> >>> postgis-users at postgis.refractions.net
> >>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>
> >>> ---------------------------------------------------------------------
> >>> ---
> >>>
> >>> * The substance of this message, including any attachments, may be 
> >>> confidential, legally privileged and/or exempt from disclosure 
> >>> pursuant to Massachusetts law. It is intended solely for the 
> >>> addressee. If you received this in error, please contact the sender 
> >>> and delete the material from any computer. *
> >>>
> >>> ---------------------------------------------------------------------
> >>> ---
> >>>
> >>> * Help make the earth a greener place. If at all possible resist 
> >>> printing this email and join us in saving paper. *
> >>>
> >>> * *
> >>>
> >>> * *
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> ---
> >>>
> >>> _______________________________________________
> >>> postgis-users mailing list
> >>> postgis-users at postgis.refractions.net
> >>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> > 
> > 
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> > 
> > 
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> > 
> 
> 
> ------------------------------
> 
> Message: 17
> Date: Wed, 16 Jul 2008 11:07:09 -0700
> From: Dylan Beaudette <dylan.beaudette at gmail.com>
> Subject: Re: [postgis-users] Transform overlapping polygons to
> 	non-overlapping?
> To: postgis-users at postgis.refractions.net
> Message-ID: <200807161107.09588.dylan.beaudette at gmail.com>
> Content-Type: text/plain;  charset="iso-8859-1"
> 
> On Wednesday 16 July 2008, Brent Fraser wrote:
> > Regina,
> >
> >   I'm not convinced ST_Union is the way to go (using ST_Overlaps OR
> > ST_Intersects as a condition).  Basically I want to iterate over the
> > collection (recursively?) clipping one polygon to another until I'm left
> > with no overlapping (or intersecting) polygons (planar topology).  This is
> > sightly more complicated than the way I originally posed the problem (I
> > wanted to created slivers from the overlapping areas to get planar
> > topology).
> >
> >   A little background:
> >
> > 	My polygons represent a classification of vegetation of a large area of
> > interest.  In theory any point in the area of interest must fall in one and
> > only one polygon.  Due to an artifact of my image segmentation process, my
> > polygons currently have slight overlap which I need to "dissolve" (and I
> > don't care which polygon the overlap sliver gets dissolved into).
> >
> > Thanks!
> > Brent.
> 
> It really sounds like you need to perform some "cleaning" operations in a 
> topologically-aware GIS. Check out the v.clean module in GRASS.
> 
> Cheers,
> 
> Dylan
> 
> 
> > Paragon Corporation wrote:
> > > One more question -  you sure you want ST_Overlaps and not ST_Intersects.
> > > If one geometry sits completely inside another, it is not considered to
> > > overlap, but they do intersect.
> > >
> > > -----Original Message-----
> > > From: postgis-users-bounces at postgis.refractions.net
> > > [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
> > > Paragon Corporation
> > > Sent: Wednesday, July 16, 2008 12:41 PM
> > > To: 'PostGIS Users Discussion'
> > > Subject: RE: [postgis-users] Transform overlapping polygons to
> > > non-overlapping?
> > >
> > > Brent,
> > >
> > >  INSERT INTO temp3_lines (the_geom)
> > > 	SELECT ST_ExteriorRing( ST_GeometryN(the_geom, generate_series(1,
> > > ST_NumGeometries(the_geom)))) AS the_geom FROM temp2_polys;
> > >
> > > Can be done more efficiently using ST_Dump
> > >
> > >  INSERT INTO temp3_lines (the_geom)
> > > 	SELECT ST_ExteriorRing((ST_Dump(the_geom)).geom) AS the_geom FROM
> > > temp2_polys;
> > >
> > >
> > > Regarding the unioning I mentioned - I thought about more why what I
> > > proposed had still overlapping polygons and I realized its because the
> > > grouping I proposed needs to be A recursive query (which means you'd need
> > > to wrap it in an sql or plpgsql
> > > function)  since as it stands it would only find the first root overlaps
> > > and not the A overlap B overlap C  (e.g. c would not be in the same
> > > grouping and A,B if it doesn't also overlap with A) .
> > >
> > > So two ways
> > > 1) Write recursive query (using a plpgsql or sql helper function) - which
> > > I haven't given much thought to the most efficient way of doing that
> > >
> > > Or
> > >
> > > 2) Repeat the union thing I mentioned over and over again until you have
> > > a set that has no more overlapping polygons.
> > >
> > > Then you do a ST_Dump to get back individual polygons.
> > >
> > > Hope that helps,
> > > Regina
> > >
> > >
> > > -----Original Message-----
> > > From: postgis-users-bounces at postgis.refractions.net
> > > [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Brent
> > > Fraser
> > > Sent: Wednesday, July 16, 2008 12:13 PM
> > > To: PostGIS Users Discussion
> > > Subject: Re: [postgis-users] Transform overlapping polygons to
> > > non-overlapping?
> > >
> > > To all,
> > >
> > >   My quest for non-overlapping polygons continues:
> > >
> > > I started with a table (temp_polys) of 3253 polygons (with some overlap)
> > > with a "class" attribute.
> > >
> > > To get rid of overlapping polys with the same class value:
> > > 	CREATE TABLE temp2_polys as SELECT class, ST_UNION(the_geom) from
> > > temp_polys GROUP BY class;
> > >
> > > This created a table of 32 multi-polygons (grouped by class).  I still
> > > have to remove the overlap between polygons with different class values,
> > > so my plan is to convert to linestrings, node the linestrings,
> > > polygonize, and (re)assign the class value using StarSpan. So first:
> > >
> > > Convert to linestrings:
> > > 	INSERT INTO temp3_lines (the_geom) SELECT ST_ExteriorRing(
> > > ST_GeometryN(the_geom, generate_series(1, ST_NumGeometries(the_geom))))
> > > AS the_geom FROM temp2_polys;
> > >
> > > This produced 1768 linestring records.  Attempting to node the
> > > linestrings: INSERT INTO temp4_lines (the_geom) SELECT St_Union(the_geom)
> > > AS the_geom FROM temp3_lines;
> > >
> > > Yikes!  This query ran for 4.5 hours and crashed Postgres (1.8 gHz
> > > Windows XP, Postgres 8.3.3, PostGIS 1.3.3).
> > >
> > > I dumped the temp3_lines table into a shapefile and asked OpenJump to
> > > node AND polygonize.  That took 24 seconds.
> > >
> > > Since the above data is a small sub-set of my 1.2 million polygons,
> > > OpenJump is not really a solution for cleaning the data all at once. 
> > > Looks like some scripting is in order...
> > >
> > > Brent
> > >
> > > Brent Fraser wrote:
> > >> Regina,
> > >>
> > >>  The "SELECT MAX..." query didn't work on my sub-set of 12800 polygons.
> > >> It created 12643 polygons some of which overlap (I expected more, not
> > >> less, than the original).
> > >>
> > >>  I may try converting to linestrings, creating one "minimum bounding
> > >> rectangle" for the entire dataset, then doing an intersect of the
> > >> lines with the MBR.  In my case this would be ok as there are not
> > >> attributes on the polygons yet.
> > >>
> > >> Thanks!
> > >> Brent
> > >>
> > >> Obe, Regina wrote:
> > >>> Brent,
> > >>>
> > >>> I guess it really depends on how exactly you want to achieve
> > >>> non-overlapping.
> > >>> If for example you are basing it on some sort of attribute and all
> > >>> your overlapping polygons are valid
> > >>>
> > >>> Then a simple
> > >>>
> > >>> SELECT ST_Union(the_geom) As newgeom, field1 FROM sometable GROUP BY
> > >>> field1
> > >>>
> > >>> I think will guarantee non-overlapping polygons because as part of
> > >>> the process of ST_Union - it would irradicate the overlapping regions
> > >>> to just create one.  That is part of the reason why its so much
> > >>> slower than ST_Collect for example.
> > >>>
> > >>> For your exact case below - you would union all the overlapping
> > >>> polygons together which could be really slow depending on how many
> > >>> overlap. The query I would write to achieve that would be something
> > >>> like this
> > >>>
> > >>> SELECT MAX(a.gid) As newgid, ST_Union(a.the_geom) As the_geom FROM
> > >>> poly a GROUP BY (SELECT MAX(r.gid) FROM poly r
> > >>>    WHERE (a.gid = r.gid OR ST_Overlaps(r.the_geom, a.the_geom)));
> > >>>
> > >>> Hope that helps,
> > >>> Regina
> > >>>
> > >>> ---------------------------------------------------------------------
> > >>> ---
> > >>> *From:* postgis-users-bounces at postgis.refractions.net on behalf of
> > >>> Brent Fraser
> > >>> *Sent:* Fri 7/11/2008 12:14 PM
> > >>> *To:* PostGIS Users Discussion
> > >>> *Subject:* Re: [postgis-users] Transform overlapping polygons to
> > >>> non-overlapping?
> > >>>
> > >>> To All,
> > >>>
> > >>>   There doesn't seem to be an obvious answer to the problem given
> > >>> below (aka cleaning polygons, creating planar polygons, etc).  I did
> > >>> see a note on the PostGIS wiki wishlist to "Add a geometry cleaner".
> > >>> There is also a suggestion to convert to linestrings, node, then
> > >>> polygonize (while that may work for a small set of polygons, I've got
> > >>> 1.1 million to clean).  JTS, Geos, etc will likely fail due to the
> > >>> large number of polygons so I'll need a different approach.
> > >>>
> > >>>   I'm considering writing some code to iterate through my table of
> > >>> polygons, cleaning a small subset at a time.  I think using PostGIS
> > >>> for the geometry storage and spatial query/selection makes sense.
> > >>> Any suggestions on which API to use?
> > >>>         GDAL's OGR
> > >>>         PostgreSQL's libpq
> > >>>         other?
> > >>>
> > >>> Thanks!
> > >>> Brent Fraser
> > >>>
> > >>> Brent Fraser wrote:
> > >>>>  PostGIS'ers,
> > >>>>
> > >>>>  I've got a table of overlapping polygons.  How can I make it a
> > >>>> table of  non-overlapping polygons?
> > >>>>
> > >>>>  For example, if table "polys2" contains two polygons A1 and B1
> > >>>> which  overlap.  I'd like to create table "polys3" with polygons A2,
> > >>>> B2, C2,  where C2 is the overlap region of A1 and B1, and A2 = A1 -
> > >>>> C2, and B2 =
> > >>>>  B1 - C2.
> > >>>>
> > >>>>  Looking at the overlay operations in the JTS doc it looks like
> > >>>> doing an  Intersection (to get only the overlapping area) then
> > >>>> adding the  Symmetric Difference (to get the non-overlapping areas)
> > >
> > > might work.
> > >
> > >>>>  Am I on the right track or is there an easier way (since all the
> > >>>> polygons are in one table)?
> > >>>>
> > >>>>  Thanks!
> > >>>>  Brent Fraser
> > >>>>  _______________________________________________
> > >>>>  postgis-users mailing list
> > >>>>  postgis-users at postgis.refractions.net
> > >>>>  http://postgis.refractions.net/mailman/listinfo/postgis-users
> > >>>
> > >>> _______________________________________________
> > >>> postgis-users mailing list
> > >>> postgis-users at postgis.refractions.net
> > >>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> > >>>
> > >>> ---------------------------------------------------------------------
> > >>> ---
> > >>>
> > >>> * The substance of this message, including any attachments, may be
> > >>> confidential, legally privileged and/or exempt from disclosure
> > >>> pursuant to Massachusetts law. It is intended solely for the
> > >>> addressee. If you received this in error, please contact the sender
> > >>> and delete the material from any computer. *
> > >>>
> > >>> ---------------------------------------------------------------------
> > >>> ---
> > >>>
> > >>> * Help make the earth a greener place. If at all possible resist
> > >>> printing this email and join us in saving paper. *
> > >>>
> > >>> * *
> > >>>
> > >>> * *
> > >>>
> > >>>
> > >>> ---------------------------------------------------------------------
> > >>> ---
> > >>>
> > >>> _______________________________________________
> > >>> postgis-users mailing list
> > >>> postgis-users at postgis.refractions.net
> > >>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> > >>
> > >> _______________________________________________
> > >> postgis-users mailing list
> > >> postgis-users at postgis.refractions.net
> > >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> > >
> > > _______________________________________________
> > > postgis-users mailing list
> > > postgis-users at postgis.refractions.net
> > > http://postgis.refractions.net/mailman/listinfo/postgis-users
> > >
> > >
> > > _______________________________________________
> > > postgis-users mailing list
> > > postgis-users at postgis.refractions.net
> > > http://postgis.refractions.net/mailman/listinfo/postgis-users
> > >
> > >
> > > _______________________________________________
> > > postgis-users mailing list
> > > postgis-users at postgis.refractions.net
> > > http://postgis.refractions.net/mailman/listinfo/postgis-users
> >
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> 
> -- 
> Dylan Beaudette
> Soil Resource Laboratory
> http://casoilresource.lawr.ucdavis.edu/
> University of California at Davis
> 530.754.7341
> 
> 
> ------------------------------
> 
> Message: 18
> Date: Wed, 16 Jul 2008 12:20:23 -0600
> From: Brent Fraser <bfraser at geoanalytic.com>
> Subject: Re: [postgis-users] Transform overlapping polygons to
> 	non-overlapping?
> To: dylan.beaudette at gmail.com
> Cc: postgis-users at postgis.refractions.net
> Message-ID: <487E3BE7.4030308 at geoanalytic.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Dylan,
> 
>   Yes! Clean polygons!  I gravitated towards PostGIS due to my large number of polygons (1.2 million), and I'd like a solution that is scalable beyond that number.  GRASS may be the/an answer; I'll give it a try.
> 
> Thanks!
> Brent
> 
> Dylan Beaudette wrote:
> > On Wednesday 16 July 2008, Brent Fraser wrote:
> >> Regina,
> >>
> >>   I'm not convinced ST_Union is the way to go (using ST_Overlaps OR
> >> ST_Intersects as a condition).  Basically I want to iterate over the
> >> collection (recursively?) clipping one polygon to another until I'm left
> >> with no overlapping (or intersecting) polygons (planar topology).  This is
> >> sightly more complicated than the way I originally posed the problem (I
> >> wanted to created slivers from the overlapping areas to get planar
> >> topology).
> >>
> >>   A little background:
> >>
> >> 	My polygons represent a classification of vegetation of a large area of
> >> interest.  In theory any point in the area of interest must fall in one and
> >> only one polygon.  Due to an artifact of my image segmentation process, my
> >> polygons currently have slight overlap which I need to "dissolve" (and I
> >> don't care which polygon the overlap sliver gets dissolved into).
> >>
> >> Thanks!
> >> Brent.
> > 
> > It really sounds like you need to perform some "cleaning" operations in a 
> > topologically-aware GIS. Check out the v.clean module in GRASS.
> > 
> > Cheers,
> > 
> > Dylan
> 
> 
> ------------------------------
> 
> Message: 19
> Date: Wed, 16 Jul 2008 11:24:38 -0700
> From: Kevin Neufeld <kneufeld at refractions.net>
> Subject: Re: [postgis-users] Transform overlapping polygons to
> 	non-overlapping?
> To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> Message-ID: <487E3CE6.4040505 at refractions.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Ah, another reason to have topology finished in PostGIS. If only, eh?
> 
> Brent, what if you created a plpgsql script that simply iterated through 
> a table of source polygons and slowly inserted them one at a time into a 
> target table by:
> 
> foreach poly in source table
> 
>    1. move all bounding box overlaps in target table with current poly 
> into a temp table.
>    2. take all polygons from your temp table and union the current poly 
> using the techniques described on the wiki and what Regina suggested.
>    3. insert the individual polygons from the overlay back into the 
> target table using ST_Dump.
> 
> end foreach.
> 
> It might take a while, but in the end, you would have a single 
> topologically correct (non-overlapping) polygonal table.
> 
> You may want to insert the geometries ordered by some x,y grid so that 
> your working area will more likely be cached in memory.
> 
> Also, you may want to perform vacuum once in while on your target table. 
>   It could bloat really quickly.  So don't iterate through all the 
> source polygons all at once.
> 
> Cheers,
> Kevin
> 
> 
> Brent Fraser wrote:
> > Regina,
> > 
> >  I'm not convinced ST_Union is the way to go (using ST_Overlaps OR 
> > ST_Intersects as a condition).  Basically I want to iterate over the 
> > collection (recursively?) clipping one polygon to another until I'm left 
> > with no overlapping (or intersecting) polygons (planar topology).  This 
> > is sightly more complicated than the way I originally posed the problem 
> > (I wanted to created slivers from the overlapping areas to get planar 
> > topology).
> > 
> >  A little background:
> > 
> >     My polygons represent a classification of vegetation of a large area 
> > of interest.  In theory any point in the area of interest must fall in 
> > one and only one polygon.  Due to an artifact of my image segmentation 
> > process, my polygons currently have slight overlap which I need to 
> > "dissolve" (and I don't care which polygon the overlap sliver gets 
> > dissolved into).
> > 
> > Thanks!
> > Brent.
> > Paragon Corporation wrote:
> >> One more question -  you sure you want ST_Overlaps and not ST_Intersects.
> >> If one geometry sits completely inside another, it is not considered to
> >> overlap, but they do intersect.
> >> -----Original Message-----
> >> From: postgis-users-bounces at postgis.refractions.net
> >> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of 
> >> Paragon
> >> Corporation
> >> Sent: Wednesday, July 16, 2008 12:41 PM
> >> To: 'PostGIS Users Discussion'
> >> Subject: RE: [postgis-users] Transform overlapping polygons to
> >> non-overlapping?
> >>
> >> Brent,
> >>
> >>  INSERT INTO temp3_lines (the_geom)     SELECT ST_ExteriorRing( 
> >> ST_GeometryN(the_geom, generate_series(1,
> >> ST_NumGeometries(the_geom)))) AS the_geom FROM temp2_polys;
> >>
> >> Can be done more efficiently using ST_Dump
> >>
> >>  INSERT INTO temp3_lines (the_geom)     SELECT 
> >> ST_ExteriorRing((ST_Dump(the_geom)).geom) AS the_geom FROM
> >> temp2_polys;
> >>
> >>
> >> Regarding the unioning I mentioned - I thought about more why what I
> >> proposed had still overlapping polygons and I realized its because the
> >> grouping I proposed needs to be A recursive query (which means you'd 
> >> need to
> >> wrap it in an sql or plpgsql
> >> function)  since as it stands it would only find the first root 
> >> overlaps and
> >> not the A overlap B overlap C  (e.g. c would not be in the same 
> >> grouping and
> >> A,B if it doesn't also overlap with A) .
> >>
> >> So two ways
> >> 1) Write recursive query (using a plpgsql or sql helper function) - 
> >> which I
> >> haven't given much thought to the most efficient way of doing that
> >>
> >> Or
> >>
> >> 2) Repeat the union thing I mentioned over and over again until you 
> >> have a
> >> set that has no more overlapping polygons.
> >>
> >> Then you do a ST_Dump to get back individual polygons.
> >>
> >> Hope that helps,
> >> Regina
> >>
> >>
> >> -----Original Message-----
> >> From: postgis-users-bounces at postgis.refractions.net
> >> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Brent
> >> Fraser
> >> Sent: Wednesday, July 16, 2008 12:13 PM
> >> To: PostGIS Users Discussion
> >> Subject: Re: [postgis-users] Transform overlapping polygons to
> >> non-overlapping?
> >>
> >> To all,
> >>
> >>   My quest for non-overlapping polygons continues:
> >>
> >> I started with a table (temp_polys) of 3253 polygons (with some overlap)
> >> with a "class" attribute.
> >>
> >> To get rid of overlapping polys with the same class value:
> >>     CREATE TABLE temp2_polys as SELECT class, ST_UNION(the_geom) from
> >> temp_polys GROUP BY class;
> >>
> >> This created a table of 32 multi-polygons (grouped by class).  I still 
> >> have
> >> to remove the overlap between polygons with different class values, so my
> >> plan is to convert to linestrings, node the linestrings, polygonize, and
> >> (re)assign the class value using StarSpan. So first:
> >>
> >> Convert to linestrings:
> >>     INSERT INTO temp3_lines (the_geom) SELECT ST_ExteriorRing(
> >> ST_GeometryN(the_geom, generate_series(1, 
> >> ST_NumGeometries(the_geom)))) AS
> >> the_geom FROM temp2_polys;
> >>
> >> This produced 1768 linestring records.  Attempting to node the 
> >> linestrings:
> >>     INSERT INTO temp4_lines (the_geom) SELECT St_Union(the_geom) AS
> >> the_geom FROM temp3_lines;
> >>
> >> Yikes!  This query ran for 4.5 hours and crashed Postgres (1.8 gHz 
> >> Windows
> >> XP, Postgres 8.3.3, PostGIS 1.3.3).
> >>
> >> I dumped the temp3_lines table into a shapefile and asked OpenJump to 
> >> node
> >> AND polygonize.  That took 24 seconds.
> >>
> >> Since the above data is a small sub-set of my 1.2 million polygons, 
> >> OpenJump
> >> is not really a solution for cleaning the data all at once.  Looks 
> >> like some
> >> scripting is in order...
> >>
> >> Brent
> >>
> >>
> >> Brent Fraser wrote:
> >>> Regina,
> >>>
> >>>  The "SELECT MAX..." query didn't work on my sub-set of 12800 
> >>> polygons.  It created 12643 polygons some of which overlap (I 
> >>> expected more, not less, than the original).
> >>>
> >>>  I may try converting to linestrings, creating one "minimum bounding 
> >>> rectangle" for the entire dataset, then doing an intersect of the 
> >>> lines with the MBR.  In my case this would be ok as there are not 
> >>> attributes on the polygons yet.
> >>>
> >>> Thanks!
> >>> Brent
> >>>
> >>> Obe, Regina wrote:
> >>>> Brent,
> >>>>  
> >>>> I guess it really depends on how exactly you want to achieve 
> >>>> non-overlapping.
> >>>> If for example you are basing it on some sort of attribute and all 
> >>>> your overlapping polygons are valid
> >>>>  
> >>>> Then a simple
> >>>>  
> >>>> SELECT ST_Union(the_geom) As newgeom, field1 FROM sometable GROUP BY
> >>>> field1
> >>>>  
> >>>> I think will guarantee non-overlapping polygons because as part of 
> >>>> the process of ST_Union - it would irradicate the overlapping 
> >>>> regions to just create one.  That is part of the reason why its so 
> >>>> much slower than ST_Collect for example.
> >>>>  
> >>>> For your exact case below - you would union all the overlapping 
> >>>> polygons together which could be really slow depending on how many 
> >>>> overlap. The query I would write to achieve that would be something 
> >>>> like this
> >>>>  
> >>>> SELECT MAX(a.gid) As newgid, ST_Union(a.the_geom) As the_geom FROM 
> >>>> poly a GROUP BY (SELECT MAX(r.gid) FROM poly r
> >>>>    WHERE (a.gid = r.gid OR ST_Overlaps(r.the_geom, a.the_geom)));
> >>>>  
> >>>> Hope that helps,
> >>>> Regina
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> ---
> >>>> *From:* postgis-users-bounces at postgis.refractions.net on behalf of 
> >>>> Brent Fraser
> >>>> *Sent:* Fri 7/11/2008 12:14 PM
> >>>> *To:* PostGIS Users Discussion
> >>>> *Subject:* Re: [postgis-users] Transform overlapping polygons to 
> >>>> non-overlapping?
> >>>>
> >>>> To All,
> >>>>
> >>>>   There doesn't seem to be an obvious answer to the problem given 
> >>>> below (aka cleaning polygons, creating planar polygons, etc).  I did 
> >>>> see a note on the PostGIS wiki wishlist to "Add a geometry cleaner".
> >>>> There is also a suggestion to convert to linestrings, node, then 
> >>>> polygonize (while that may work for a small set of polygons, I've got
> >>>> 1.1 million to clean).  JTS, Geos, etc will likely fail due to the 
> >>>> large number of polygons so I'll need a different approach.
> >>>>
> >>>>   I'm considering writing some code to iterate through my table of 
> >>>> polygons, cleaning a small subset at a time.  I think using PostGIS 
> >>>> for the geometry storage and spatial query/selection makes sense.
> >>>> Any suggestions on which API to use?
> >>>>         GDAL's OGR
> >>>>         PostgreSQL's libpq
> >>>>         other?
> >>>>
> >>>> Thanks!
> >>>> Brent Fraser
> >>>>
> >>>> Brent Fraser wrote:
> >>>>>  PostGIS'ers,
> >>>>>
> >>>>>  I've got a table of overlapping polygons.  How can I make it a 
> >>>>> table of  non-overlapping polygons?
> >>>>>
> >>>>>  For example, if table "polys2" contains two polygons A1 and B1 
> >>>>> which  overlap.  I'd like to create table "polys3" with polygons 
> >>>>> A2, B2, C2,  where C2 is the overlap region of A1 and B1, and A2 = 
> >>>>> A1 - C2, and B2 =
> >>>>>  B1 - C2.
> >>>>>
> >>>>>  Looking at the overlay operations in the JTS doc it looks like 
> >>>>> doing an  Intersection (to get only the overlapping area) then 
> >>>>> adding the  Symmetric Difference (to get the non-overlapping areas)
> >> might work.
> >>>>>  Am I on the right track or is there an easier way (since all the 
> >>>>> polygons are in one table)?
> >>>>>
> >>>>>  Thanks!
> >>>>>  Brent Fraser
> >>>>>  _______________________________________________
> >>>>>  postgis-users mailing list
> >>>>>  postgis-users at postgis.refractions.net
> >>>>>  http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>>>
> >>>> _______________________________________________
> >>>> postgis-users mailing list
> >>>> postgis-users at postgis.refractions.net
> >>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> ---
> >>>>
> >>>> * The substance of this message, including any attachments, may be 
> >>>> confidential, legally privileged and/or exempt from disclosure 
> >>>> pursuant to Massachusetts law. It is intended solely for the 
> >>>> addressee. If you received this in error, please contact the sender 
> >>>> and delete the material from any computer. *
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> ---
> >>>>
> >>>> * Help make the earth a greener place. If at all possible resist 
> >>>> printing this email and join us in saving paper. *
> >>>>
> >>>> * *
> >>>>
> >>>> * *
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> ---
> >>>>
> >>>> _______________________________________________
> >>>> postgis-users mailing list
> >>>> postgis-users at postgis.refractions.net
> >>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>> _______________________________________________
> >>> postgis-users mailing list
> >>> postgis-users at postgis.refractions.net
> >>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> >>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> >>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> ------------------------------
> 
> Message: 20
> Date: Wed, 16 Jul 2008 14:57:15 -0400
> From: "Obe, Regina" <robe.dnd at cityofboston.gov>
> Subject: RE: [postgis-users] Transform overlapping polygons to
> 	non-overlapping?
> To: "PostGIS Users Discussion"
> 	<postgis-users at postgis.refractions.net>,	"PostGIS Users Discussion"
> 	<postgis-users at postgis.refractions.net>
> Message-ID:
> 	<53F9CF533E1AA14EA1F8C5C08ABC08D20197A130 at ZDND.DND.boston.cob>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> Brent,
>  
> This might help reduce your problem set a bit.  You don't care about the ones that don't overlap anything right.  Hopefully there are a lot of those.  So use the old LEFT JOIN trick
>  
> Create new table
>  
> INSERT INTO newtable(gid,the_geom)
> SELECT a.gid, a.the_geom
> FROM oldtable a LEFT JOIN oldtable b ON (a.gid <> b.gid AND ST_Overlaps(a.the_geom, b.the_geom))
> WHERE b.gid IS NULL
>  
> Next step create unique index on gid on new table
>  
> DELETE FROM oldtable
> WHERE gid IN(SELECT gid FROM newtable)
>  
> Now all you are left to work with are your polygons that overlap each other.
>  
> With those follow Kevin's lead by creating  an intermediary workspace table
>  
> Hope that helps,
> Regina
> 
> ________________________________
> 
> From: postgis-users-bounces at postgis.refractions.net on behalf of Kevin Neufeld
> Sent: Wed 7/16/2008 2:24 PM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] Transform overlapping polygons to non-overlapping?
> 
> 
> 
> Ah, another reason to have topology finished in PostGIS. If only, eh?
> 
> Brent, what if you created a plpgsql script that simply iterated through
> a table of source polygons and slowly inserted them one at a time into a
> target table by:
> 
> foreach poly in source table
> 
>    1. move all bounding box overlaps in target table with current poly
> into a temp table.
>    2. take all polygons from your temp table and union the current poly
> using the techniques described on the wiki and what Regina suggested.
>    3. insert the individual polygons from the overlay back into the
> target table using ST_Dump.
> 
> end foreach.
> 
> It might take a while, but in the end, you would have a single
> topologically correct (non-overlapping) polygonal table.
> 
> You may want to insert the geometries ordered by some x,y grid so that
> your working area will more likely be cached in memory.
> 
> Also, you may want to perform vacuum once in while on your target table.
>   It could bloat really quickly.  So don't iterate through all the
> source polygons all at once.
> 
> Cheers,
> Kevin
> 
> 
> Brent Fraser wrote:
> > Regina,
> >
> >  I'm not convinced ST_Union is the way to go (using ST_Overlaps OR
> > ST_Intersects as a condition).  Basically I want to iterate over the
> > collection (recursively?) clipping one polygon to another until I'm left
> > with no overlapping (or intersecting) polygons (planar topology).  This
> > is sightly more complicated than the way I originally posed the problem
> > (I wanted to created slivers from the overlapping areas to get planar
> > topology).
> >
> >  A little background:
> >
> >     My polygons represent a classification of vegetation of a large area
> > of interest.  In theory any point in the area of interest must fall in
> > one and only one polygon.  Due to an artifact of my image segmentation
> > process, my polygons currently have slight overlap which I need to
> > "dissolve" (and I don't care which polygon the overlap sliver gets
> > dissolved into).
> >
> > Thanks!
> > Brent.
> > Paragon Corporation wrote:
> >> One more question -  you sure you want ST_Overlaps and not ST_Intersects.
> >> If one geometry sits completely inside another, it is not considered to
> >> overlap, but they do intersect.
> >> -----Original Message-----
> >> From: postgis-users-bounces at postgis.refractions.net
> >> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
> >> Paragon
> >> Corporation
> >> Sent: Wednesday, July 16, 2008 12:41 PM
> >> To: 'PostGIS Users Discussion'
> >> Subject: RE: [postgis-users] Transform overlapping polygons to
> >> non-overlapping?
> >>
> >> Brent,
> >>
> >>  INSERT INTO temp3_lines (the_geom)     SELECT ST_ExteriorRing(
> >> ST_GeometryN(the_geom, generate_series(1,
> >> ST_NumGeometries(the_geom)))) AS the_geom FROM temp2_polys;
> >>
> >> Can be done more efficiently using ST_Dump
> >>
> >>  INSERT INTO temp3_lines (the_geom)     SELECT
> >> ST_ExteriorRing((ST_Dump(the_geom)).geom) AS the_geom FROM
> >> temp2_polys;
> >>
> >>
> >> Regarding the unioning I mentioned - I thought about more why what I
> >> proposed had still overlapping polygons and I realized its because the
> >> grouping I proposed needs to be A recursive query (which means you'd
> >> need to
> >> wrap it in an sql or plpgsql
> >> function)  since as it stands it would only find the first root
> >> overlaps and
> >> not the A overlap B overlap C  (e.g. c would not be in the same
> >> grouping and
> >> A,B if it doesn't also overlap with A) .
> >>
> >> So two ways
> >> 1) Write recursive query (using a plpgsql or sql helper function) -
> >> which I
> >> haven't given much thought to the most efficient way of doing that
> >>
> >> Or
> >>
> >> 2) Repeat the union thing I mentioned over and over again until you
> >> have a
> >> set that has no more overlapping polygons.
> >>
> >> Then you do a ST_Dump to get back individual polygons.
> >>
> >> Hope that helps,
> >> Regina
> >>
> >>
> >> -----Original Message-----
> >> From: postgis-users-bounces at postgis.refractions.net
> >> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Brent
> >> Fraser
> >> Sent: Wednesday, July 16, 2008 12:13 PM
> >> To: PostGIS Users Discussion
> >> Subject: Re: [postgis-users] Transform overlapping polygons to
> >> non-overlapping?
> >>
> >> To all,
> >>
> >>   My quest for non-overlapping polygons continues:
> >>
> >> I started with a table (temp_polys) of 3253 polygons (with some overlap)
> >> with a "class" attribute.
> >>
> >> To get rid of overlapping polys with the same class value:
> >>     CREATE TABLE temp2_polys as SELECT class, ST_UNION(the_geom) from
> >> temp_polys GROUP BY class;
> >>
> >> This created a table of 32 multi-polygons (grouped by class).  I still
> >> have
> >> to remove the overlap between polygons with different class values, so my
> >> plan is to convert to linestrings, node the linestrings, polygonize, and
> >> (re)assign the class value using StarSpan. So first:
> >>
> >> Convert to linestrings:
> >>     INSERT INTO temp3_lines (the_geom) SELECT ST_ExteriorRing(
> >> ST_GeometryN(the_geom, generate_series(1,
> >> ST_NumGeometries(the_geom)))) AS
> >> the_geom FROM temp2_polys;
> >>
> >> This produced 1768 linestring records.  Attempting to node the
> >> linestrings:
> >>     INSERT INTO temp4_lines (the_geom) SELECT St_Union(the_geom) AS
> >> the_geom FROM temp3_lines;
> >>
> >> Yikes!  This query ran for 4.5 hours and crashed Postgres (1.8 gHz
> >> Windows
> >> XP, Postgres 8.3.3, PostGIS 1.3.3).
> >>
> >> I dumped the temp3_lines table into a shapefile and asked OpenJump to
> >> node
> >> AND polygonize.  That took 24 seconds.
> >>
> >> Since the above data is a small sub-set of my 1.2 million polygons,
> >> OpenJump
> >> is not really a solution for cleaning the data all at once.  Looks
> >> like some
> >> scripting is in order...
> >>
> >> Brent
> >>
> >>
> >> Brent Fraser wrote:
> >>> Regina,
> >>>
> >>>  The "SELECT MAX..." query didn't work on my sub-set of 12800
> >>> polygons.  It created 12643 polygons some of which overlap (I
> >>> expected more, not less, than the original).
> >>>
> >>>  I may try converting to linestrings, creating one "minimum bounding
> >>> rectangle" for the entire dataset, then doing an intersect of the
> >>> lines with the MBR.  In my case this would be ok as there are not
> >>> attributes on the polygons yet.
> >>>
> >>> Thanks!
> >>> Brent
> >>>
> >>> Obe, Regina wrote:
> >>>> Brent,
> >>>> 
> >>>> I guess it really depends on how exactly you want to achieve
> >>>> non-overlapping.
> >>>> If for example you are basing it on some sort of attribute and all
> >>>> your overlapping polygons are valid
> >>>> 
> >>>> Then a simple
> >>>> 
> >>>> SELECT ST_Union(the_geom) As newgeom, field1 FROM sometable GROUP BY
> >>>> field1
> >>>> 
> >>>> I think will guarantee non-overlapping polygons because as part of
> >>>> the process of ST_Union - it would irradicate the overlapping
> >>>> regions to just create one.  That is part of the reason why its so
> >>>> much slower than ST_Collect for example.
> >>>> 
> >>>> For your exact case below - you would union all the overlapping
> >>>> polygons together which could be really slow depending on how many
> >>>> overlap. The query I would write to achieve that would be something
> >>>> like this
> >>>> 
> >>>> SELECT MAX(a.gid) As newgid, ST_Union(a.the_geom) As the_geom FROM
> >>>> poly a GROUP BY (SELECT MAX(r.gid) FROM poly r
> >>>>    WHERE (a.gid = r.gid OR ST_Overlaps(r.the_geom, a.the_geom)));
> >>>> 
> >>>> Hope that helps,
> >>>> Regina
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> ---
> >>>> *From:* postgis-users-bounces at postgis.refractions.net on behalf of
> >>>> Brent Fraser
> >>>> *Sent:* Fri 7/11/2008 12:14 PM
> >>>> *To:* PostGIS Users Discussion
> >>>> *Subject:* Re: [postgis-users] Transform overlapping polygons to
> >>>> non-overlapping?
> >>>>
> >>>> To All,
> >>>>
> >>>>   There doesn't seem to be an obvious answer to the problem given
> >>>> below (aka cleaning polygons, creating planar polygons, etc).  I did
> >>>> see a note on the PostGIS wiki wishlist to "Add a geometry cleaner".
> >>>> There is also a suggestion to convert to linestrings, node, then
> >>>> polygonize (while that may work for a small set of polygons, I've got
> >>>> 1.1 million to clean).  JTS, Geos, etc will likely fail due to the
> >>>> large number of polygons so I'll need a different approach.
> >>>>
> >>>>   I'm considering writing some code to iterate through my table of
> >>>> polygons, cleaning a small subset at a time.  I think using PostGIS
> >>>> for the geometry storage and spatial query/selection makes sense.
> >>>> Any suggestions on which API to use?
> >>>>         GDAL's OGR
> >>>>         PostgreSQL's libpq
> >>>>         other?
> >>>>
> >>>> Thanks!
> >>>> Brent Fraser
> >>>>
> >>>> Brent Fraser wrote:
> >>>>>  PostGIS'ers,
> >>>>>
> >>>>>  I've got a table of overlapping polygons.  How can I make it a
> >>>>> table of  non-overlapping polygons?
> >>>>>
> >>>>>  For example, if table "polys2" contains two polygons A1 and B1
> >>>>> which  overlap.  I'd like to create table "polys3" with polygons
> >>>>> A2, B2, C2,  where C2 is the overlap region of A1 and B1, and A2 =
> >>>>> A1 - C2, and B2 =
> >>>>>  B1 - C2.
> >>>>>
> >>>>>  Looking at the overlay operations in the JTS doc it looks like
> >>>>> doing an  Intersection (to get only the overlapping area) then
> >>>>> adding the  Symmetric Difference (to get the non-overlapping areas)
> >> might work.
> >>>>>  Am I on the right track or is there an easier way (since all the
> >>>>> polygons are in one table)?
> >>>>>
> >>>>>  Thanks!
> >>>>>  Brent Fraser
> >>>>>  _______________________________________________
> >>>>>  postgis-users mailing list
> >>>>>  postgis-users at postgis.refractions.net
> >>>>>  http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>>>
> >>>> _______________________________________________
> >>>> postgis-users mailing list
> >>>> postgis-users at postgis.refractions.net
> >>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> ---
> >>>>
> >>>> * The substance of this message, including any attachments, may be
> >>>> confidential, legally privileged and/or exempt from disclosure
> >>>> pursuant to Massachusetts law. It is intended solely for the
> >>>> addressee. If you received this in error, please contact the sender
> >>>> and delete the material from any computer. *
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> ---
> >>>>
> >>>> * Help make the earth a greener place. If at all possible resist
> >>>> printing this email and join us in saving paper. *
> >>>>
> >>>> * *
> >>>>
> >>>> * *
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> ---
> >>>>
> >>>> _______________________________________________
> >>>> postgis-users mailing list
> >>>> postgis-users at postgis.refractions.net
> >>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>> _______________________________________________
> >>> postgis-users mailing list
> >>> postgis-users at postgis.refractions.net
> >>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> >>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> >>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at postgis.refractions.net
> >> http://postgis.refractions.net/mailman/listinfo/postgis-users
> >>
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.refractions.net/pipermail/postgis-users/attachments/20080716/a94b9d50/attachment-0001.html
> 
> ------------------------------
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> End of postgis-users Digest, Vol 69, Issue 16
> *********************************************

_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080717/315ff96a/attachment.html>


More information about the postgis-users mailing list