[postgis-users] Trying to remove duplicate polygons with some restrictions

Stephen Woodbridge woodbri at swoodbridge.com
Wed Sep 17 09:11:58 PDT 2008


Teodora Vuscan wrote:
> I am new to postgis and I would appreciate your help.
> I have a shape file where some polygons are duplicated (or almost the same)
> and I would like to remove the duplicate ones. I cannot apply the distinct
> on geometry because that would delete some of the duplicates I need. 

You can use:
   ... distinct the_geom, attr1, attr2, ...

> Here is what I need:
> 1. 2 polygons have same geometry but different attributes - I need both; 2.
> 2 polygons have same geometry but one has data attached to it, one does not.
> In this case I want to remove the one that has no data.

Assume you mean one has attributes and the other has NULLs. Oyhers might 
have some tricks to deal with this case.

> 3. 2 polygons have same geometry but none have data - I want to keep one.

I think the distinct case above will get this

> In the same file I also have a different scenario: the areas of the
> "duplicated" polygons are slightly different.

So is the area a value in an attribute column? Then I would just ignore 
this column as the area of two duplicate geometries has to be the same 
and the error is in the process that added the area to the attribute 
column. You can also do something like:

update mytable set area = ST_Area(the_geom);

You might need to deal with some additional projections if you need the 
area to be in some specific units other than you source geometry.


Hope this helps,
   -Steve W.


> I appreciate your help.
> 
> Teo
> 
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Gustavo
> Ces
> Sent: Wednesday, September 17, 2008 9:01 AM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] ArcGIS Mobile slightly off-topic question
> 
> Hi Regina,
> 
>     easiest way is to create your model in Model Builder and then export it,
> 
> as someone has mentionated. Then you can export it as script and modify it.
>     There isn´t a lot of info about this topic. Arcgis help is not very 
> useful ( sometimes the help examples doesn´t work). You have to be careful 
> with python versions supported by your arcgis version ( there is info in 
> ESRI forums about how to change your python version, and wich are suported).
> 
> There is a geoprocessor model pdf, but no info about toolboxes methods... 
> It´s a try-error process to understand each toolboxes' methods... And as you
> 
> can find  in ESRI forums, sometimes it doesn´t work...
>     I´ve got some docs recopilated about this topic. If you´re interested 
> send me a mail.
> 
> Gus
> 
> 
>  
> 
> _______________________________________________
> 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




More information about the postgis-users mailing list