<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hi Apostolis,<br>
    <br>
    as Andreas mentioned, I wrote a pl/pgsql function for the arcgis
    union which is still far from being perfect. I attach the sql file
    to this mail and you can try if it works for your data. If you want
    to use the function, then first, execute the create or replace
    function parts (I splitted the function into 6 parts:
    start(pgunion), intersection, no intersection, difference_a,
    difference_b and merge) and then call the functions with<br>
    <br>
    select _pgunion('<i>schema name</i>', '<i>table1</i>', '<i>id table1</i>',
    '<i>table2</i>', '<i>id table2</i>');<br>
    select _pgintersection('<i>schema name</i>', '<i>table1</i>', '<i>id
      table1</i>', '<i>table2</i>', '<i>id table2</i>', '<i>intsec_table1_table2</i>');<br>
    select _pgnointersection('<i>schema name</i>', '<i>table1</i>', '<i>id
      table1</i>', '<i>table2</i>', '<i>id table2</i>', '<i>intsec_table1_table2</i>',
    '<i>nointsec_table1</i>', '<i>nointsec_table2</i>');<br>
    select _pgdifference_a(<i>'schema name</i>', '<i>table1</i>', '<i>id
      table1</i>', '<i>table2</i>', '<i>id table2</i>', '<i>diff_table1</i>');<br>
    select _pgdifference_b('<i>schema name</i>', '<i>table1</i>', '<i>id
      table1</i>', '<i>table2</i>', '<i>id table2</i>', '<i>diff_table2</i>');<br>
    select _pgmerge('<i>schema name</i>', '<i>id table1</i>', '<i>id
      table2</i>', '<i>intsec_table1_table2</i>', '<i>nointsec_table1</i>',
    '<i>nointsec_table2</i>', '<i>diff_table1</i>', '<i>diff_table2</i>',
    '<i>pgunion_table1_table2</i>');<br>
    <br>
    (italic letters mean that you should replace these words by the
    names of your tables and id columns)<br>
    <br>
    Your data should have<br>
    -gid column (column name is required) with data type integer or
    serial and btree index,<br>
    -id column (any name, name is passed with function call) with data
    type integer or serial and btree index,<br>
    -geometry column named the_geom with gist index<br>
    <br>
    Both tables should be in the same schema (Certainly, this is
    changeable, but since you said you are a novice in postgis, I
    suppose you would rather use the functions in their current state).<br>
    <br>
    If you don't want to have problems with polygon duplication, it
    would be wise to first make sure that you data does not contain
    duplicates. But my tests did show me, that it's very unlikely that
    my functions create more duplicates than there were before.<br>
    <br>
    The functions will create a series of tables:<br>
    -intsec_<i>table1</i>_<i>table2</i><br>
    -nointsec_<i>table1</i><br>
    -nointsec_<i>table2</i><br>
    -diff_<i>table1</i><br>
    -<i>table1</i>_<i>table2</i>_diff_exceptions (contains polygons
    where the difference of table1-table2 threw an error)<br>
    -diff_<i>table2</i><br>
    -<i>table2</i>_<i>table1</i>_diff_exceptions (contains polygons
    where the difference of table2-table1 threw an error)<br>
    -pgunion_<i>table1</i>_<i>table2</i> (this is the result table!!)<br>
    <br>
    <br>
    If you need some more explanations, please ask.<br>
    <br>
    I would be happy if somebody else (you??) would test my functions. I
    tested them for instance with tables of about 400.000 rows against
    15.000 rows and it ran for about 1-2 days.<br>
    <br>
    Regards and success,<br>
    <br>
    Birgit.<br>
    <br>
    <br>
    <br>
    On 07.01.2011 22:11, ΑΠΟΣΤΟΛΟΣ ΛΕΛΕΝΤΖΗΣ wrote:
    <blockquote
      cite="mid:AANLkTimn=4eD0QxKNwn7FYx0rRhAi0Fo5i=_rwkLA5S1@mail.gmail.com"
      type="cite">Andreas thank you for your reply!!<br>
      I am novice in postgis, and i would appreciate if you give me some
      useful advice..<br>
      Also, I am really greatful, if you send me the code to union two
      shapefiles!!<br>
      I don't want to use any more the arcgis desktop, and i understand
      that postgis is a very good solution for data collection and
      manipulation with many spatial functio<br>
      <br>
      Apostolis<br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>
</pre>
    </blockquote>
  </body>
</html>