How to create a polygon that covers a set of geometries?

Hi people,

I have a spatial table with the parcel data. Some are polygons and lines.
What I have to do is to create a single polygon that covers all these plots.
I tried some spatial functions, but the result is not perfect.
Could you guys give some advice on how to do it using the Oracle Spatial functions?

Thank you
Luis

Luis etc.,

Delicate using the ST_PolygonBuilder (JTS) that implements my code SC4O Java-in-the-database and some coding, I managed to product a polygon that covers the data correctly.

Note that I use only external linestrings which provides some Luis.

-- First create a table holding only the outer lines.
--
create table outerLines as
  SELECT SDO_GEOMETRY(2002, 8292, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(-49.6878936628642, -18.4995538840232, -49.6875224063873, -18.4994400734344, -49.6882811644211, -18.4960292763006, -49.6886251490431, -18.4958803030445, -49.6906307026931, -18.4950115281619)) as geom from dual union all
  SELECT SDO_GEOMETRY(2002, 8292, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(-49.6884083531774, -18.4917625230274, -49.6886528151554, -18.4922451253898, -49.6898503241639, -18.4946091658756, -49.690098431643, -18.4950991112698, -49.6902068702432, -18.4950498009285, -49.6905958643821, -18.4948724904445)) as geom from dual union all
  SELECT SDO_GEOMETRY(2002, 8292, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(-49.6883413960309, -18.4918992292229, -49.6885491287687, -18.4923048595269, -49.6849860033691, -18.4934740072225, -49.6855427926656, -18.4945793006294, -49.6857982402423, -18.4950861997106, -49.6860079716291, -18.4955025995491, -49.6836133980005, -18.4962994912622, -49.6834396716227, -18.4957578264012)) as geom from dual union all
  SELECT SDO_GEOMETRY(2002, 8292, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(-49.6792385551751, -18.5000418095053, -49.6797119992317, -18.4998345697814, -49.6783397446724, -18.4980535328215, -49.6810365599698, -18.4971609552001, -49.6810385833744, -18.4971564511947, -49.6835051531636, -18.4963355157698, -49.6833312619652, -18.4958030666281)) as geom from dual union all
  SELECT SDO_GEOMETRY(2002, 8292, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(-49.6878678853177, -18.4996181336176, -49.6861731626715, -18.4991017919552, -49.6834080082784, -18.4982775371379, -49.6833583465082, -18.4983066497055, -49.6832975737928, -18.4983520405102, -49.6831594052426, -18.4984987309426, -49.6830586383606, -18.4986094463067, -49.6829994956301, -18.4986769870823, -49.6829194669485, -18.4987385992949, -49.6828337343539, -18.4987905933782, -49.6827167582476, -18.4988411048671, -49.6825978712605, -18.4988566328165, -49.6824876108137, -18.4988587567866, -49.6824343436196, -18.4988638980162, -49.6823495710101, -18.498901802054, -49.6820036074112, -18.4990727977958, -49.6815739264209, -18.4993045655044, -49.6815394467332, -18.4993194542279, -49.6815037571481, -18.4993313944568, -49.681467095582, -18.4993402576461, -49.6814297528519, -18.4993459734892, -49.6813920251781, -18.4993484966453, -49.6813542118344, -18.4993478070996, -49.6813166127745, -18.4993439103221, -49.6812795262518, -18.4993368372241, -49.6812432464542, -18.4993266439127, -49.6812080820875, -18.4993134018902, -49.6793284309429, -18.5001537628556)) as geom from dual;

-- Firstly, fill in the gaps between all the outer lines by generating small 2 point linestrings....
-- This is what the CTE, connected_lines, produces
--
with connected_lines as (
select row_number() over (order by 1) as rid,
       f.geom
  from (select sdo_geometry(2002,8292,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(sx,sy,ex,ey)) as geom
          from (select distinct sx,sy,ex,ey,dist,
                       min(dist) over (partition by sx,sy) as mdist
                  from (select a.x as sx,a.y as sy,b.x as ex,b.y as ey,
                               sdo_geom.sdo_distance(sdo_geometry(2001,8292,sdo_point_type(a.x,a.y,null),null,null),
                                                     sdo_geometry(2001,8292,sdo_point_type(b.x,b.y,null),null,null),
                                                     0.005) as dist
                          from (select p.x as x, p.y as y
                                  from outerLines g,
                                       table(geom.getVector(g.geom)) v,
                                       table(geom.getPointSet(v.AsSdoGeometry(8292))) p
                                group by p.x, p.y
                                having count(*) = 1
                               ) a,
                               (select p.x as x, p.y as y
                                  from outerLines g,
                                       table(geom.getVector(g.geom)) v,
                                       table(geom.getPointSet(v.AsSdoGeometry(8292))) p
                                group by p.x, p.y
                                having count(*) = 1
                               ) b
                          where a.x != b.x and a.y != b.y
                        )
                )
                where dist = mdist
        UNION ALL
        select g.geom
          from outerLines g
      ) f
)
/* Now ask SC4O's ST_PolygonBuilder to try and create a polygon from the set of lines */
select sc4o.ST_PolygonBuilder(CAST(COLLECT(f.geom) as mdsys.sdo_geometry_array),8) as polygon
  from ( /* Now, the WITH connected_lines produces 2 copies of each linestring with the coordinates reversed.
                These have to be removed/de-duped before being passed into the ST_PolygonBuilder */
        select sdo_geometry(2002,8292,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(sum(x1),sum(y1),sum(x2),sum(y2))) as geom
          from (SELECT rid,
                       case when rid=NVL((lag(rid,1) over (partition by rid order by x)),rid)
                            then case when vertexId = 1 then x else null end
                        end as x1,
                       case when rid=NVL((lag(rid,1) over (partition by rid order by x)),rid)
                            then case when vertexId = 1 then y else null end
                        end as y1,
                       case when rid=NVL((lag(rid,1) over (partition by rid order by x)),rid)
                            then case when vertexId = 2 then x else null end
                        end as x2,
                       case when rid=NVL((lag(rid,1) over (partition by rid order by x)),rid)
                            then case when vertexId = 2 then y else null end
                        end as y2
                FROM   (select rid,
                               row_number() over (partition by rid order by x) as vertexId,
                               x, y
                          from (select min(m.rid) rid,
                                       t.x, t.y
                                  from connected_lines m,
                                       table(sdo_util.getVertices(m.geom)) t
                                 where sdo_util.GetNumVertices(m.geom) = 2
                                 group by t.x,t.y
                                 order by t.x )
                       )
                  )
                group by rid
    union all
    /* Select and pass into ST_PolygonBuilder the original outer lines */
    select m.geom as geom
      from connected_lines m
     where sdo_util.GetNumVertices(m.geom) > 2
    ) f;
-- Result
--
POLYGON
-----------------------
MDSYS.SDO_GEOMETRY(2003,8292,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),MDSYS.SDO_ORDINATE_ARRAY(-49.6906307026931,-18.4950115281619,-49.6886251490431,-18.4958803030445,-49.6882811644211,-18.4960292763006,-49.6875224063873,-18.4994400734344,-49.6878936628642,-18.4995538840232,-49.6878678853177,-18.4996181336176,-49.6861731626715,-18.4991017919552,-49.6834080082784,-18.4982775371379,-49.6833583465082,-18.4983066497055,-49.6832975737928,-18.4983520405102,-49.6831594052426,-18.4984987309426,-49.6830586383606,-18.4986094463067,-49.6829994956301,-18.4986769870823,-49.6829194669485,-18.4987385992949,-49.6828337343539,-18.4987905933782,-49.6827167582476,-18.4988411048671,-49.6825978712605,-18.4988566328165,-49.6824876108137,-18.4988587567866,-49.6824343436196,-18.4988638980162,-49.6823495710101,-18.498901802054,-49.6820036074112,-18.4990727977958,-49.6815739264209,-18.4993045655044,-49.6815394467332,-18.4993194542279,-49.6815037571481,-18.4993313944568,-49.681467095582,-18.4993402576461,-49.6814297528519,-18.4993459734892,-49.6813920251781,-18.4993484966453,-49.6813542118344,-18.4993478070996,-49.6813166127745,-18.4993439103221,-49.6812795262518,-18.4993368372241,-49.6812432464542,-18.4993266439127,-49.6812080820875,-18.4993134018902,-49.6793284309429,-18.5001537628556,-49.6792385551751,-18.5000418095053,-49.6797119992317,-18.4998345697814,-49.6783397446724,-18.4980535328215,-49.6810365599698,-18.4971609552001,-49.6810385833744,-18.4971564511947,-49.6835051531636,-18.4963355157698,-49.6833312619652,-18.4958030666281,-49.6834396716227,-18.4957578264012,-49.6836133980005,-18.4962994912622,-49.6860079716291,-18.4955025995491,-49.6857982402423,-18.4950861997106,-49.6855427926656,-18.4945793006294,-49.6849860033691,-18.4934740072225,-49.6885491287687,-18.4923048595269,-49.6883413960309,-18.4918992292229,-49.6884083531774,-18.4917625230274,-49.6886528151554,-18.4922451253898,-49.6898503241639,-18.4946091658756,-49.690098431643,-18.4950991112698,-49.6902068702432,-18.4950498009285,-49.6905958643821,-18.4948724904445,-49.6906307026931,-18.4950115281619))

The result is a nice clean polygon.

http://www.spatialdbadvisor.com/files/PolygonCoveringGeometrySet.PNG

This, more than my last post is the best I can do. It took me many, many hours to implement. Please allow points since it is a correct result. Also, consider making a PayPal donation on my Web site for the hours I spent.

NOTE: The package space companion 4 Oracle (SC4O) is available for download FREE on my site. Again, donations accepted if the code made what you want.

concerning
Simon

Published by: Simon Greener on April 11, 2013 09:53 Changed where a.x, b.x and b.y-a.y etc. to where a.x! = b.x and a.y! b.y =

Tags: Database

Similar Questions

  • How to create a folder that is NOT a SMART FOLDER?

    (1) how can I create a folder that is NOT a smart folder?

    (2) how can I get a folder to display the NUMBER of items it contains?

    https://support.Apple.com/kb/PH22185?viewlocale=en_US & local = en_US click the blue details.   It's Apple records guide.

  • How to create a task that runs once a day, immediately after the opening of session?

    Hello, I'm wondering how to create a task using the Task Scheduler that runs once a day, immediately after I have logon.

    The reason is I want to use Bing Desktop to change my wallpaper every day. However, I just want to run the first time I start my computer every day, so it will change the wallpaper. By default, it starts whenever I have to logon. It's annoying, because I just want it to start once a day to change the wallpaper. However, using the Task Scheduler, I put only a trigger to start "at the opening of session' or"once a day." If I choose once per day, it runs about 5-10 min after I login, instead of logon immediately after. If I choose the two triggers, then it starts after each session.

    Basically, I just want the Task Scheduler to launch the program after the connection the first time I connect to the computer on any given day. How can I do this?

    Hello Jeffrey,.

    You can refer to the links below and see if that helps.

    Create a task

    http://TechNet.Microsoft.com/en-us/library/cc720110 (v = WS.10) .aspx

    Modify a scheduled task

    http://TechNet.Microsoft.com/en-us/library/cc778308 (v = WS.10) .aspx

    Change an existing task

    http://TechNet.Microsoft.com/en-us/library/cc766442.aspx

    Please write back to us for assistance and we will be happy to help you come.

    Thank you

  • Windows Live Mail 2011 - how to create a Signature that contains a hyperlink to the address of my website?

    In Windows Live Mail 2011, I am trying to create a Signature that contains a hyperlink to my website address.

    I click on Options - Mail - Signatures - new.

    If I choose 'text' - there is no way to add a hyperlink.

    If I choose "files, browse" do I look for? I'm supposed to be creating an HTML document to the address of the site? and if yes, how do I do that?

    You'll get better help at Windows Live Mail Solution Center - Forum

    [See also

    Windows Live Help Center, Windows Live Mail, Windows Live Hotmail]

  • How to create a project that connects in a static library?

    I am trying to create an OpenGL project that depends on a static library which I create in the same workspace in the NDK.  I created two projects (static library and OpenGL app) connects them in the NDK and tried, but I must be missing something because my OpenGL project is not able to see the functions in my static library, even if it is able to find my static library?

    Is there documentation describing step by step how to create two projects and how to relate?

    I found a similar post on the forums and I have solved my problem.

    I used project > add library > library of the project in the workspace but something is broken with this command, because it did not work.

    If you use project > add library > external library, then everything works fine.

  • How to create a job that e-mail with csv attached.

    Hello

    Could all help with that.

    I have a trigger that inserts (after changing the DLL) on the diagram at track_t, (table).

    Now, I put a job to convert track_t (table) to CSV data, daily...

    Then, I need to define a job to send the mail on a daily basis with the attached csv.

    set - trigger, procedue to send mail. But how to create a job to send a mail with csv generated

    8ff4363d-844d-49fd-87D1-2125143d11a8 wrote:

    Hello

    Could all help with that.

    I have a trigger that inserts (after changing the DLL) on the diagram at track_t, (table).

    Now, I put a job to convert track_t (table) to CSV data, daily...

    Then, I need to define a job to send the mail on a daily basis with the attached csv.

    set - trigger, procedue to send mail. But how to create a job to send a mail with csv generated

    DBMS_SCHEDULER

    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25788/d_sched.htm#ARPLS72235

  • How to create a button that is persistent on the top of the Gallery HTML page

    Hello

    My InDesign folio, I have an article with photo gallery full HTML page. The photo grid occupies the full screen. I want to create a button that is persistent on top of this gallery, which the user can type to go to the main Menu page. This button is always visible in one place, even as the user scrolls up and down the gallery. I tried to create it on the top layer and the upper layer of the page master, but the button disapperas loading the HTML gallery.
    If the user does not see any button to navigate through the Gallery to another article.

    Any ideas how to create persistent button?

    Thanks in advance.

    -MP

    Why not do things just like an HTML article? You do it in the Muse.

  • EBS 11i - how to create a responsibility that can only reset the passwords

    Hello

    I need to create a responsibility of helpdesk team reset user passwords, but do not do. I created a menu and I tried "UMX_FORGOT_PWD", "UMX_OBJ_PASSWD_MGMT", "UMX_RESET_PWD" works but without hope. What should I do or how can I add more effort to make it work?

    user13014069 wrote:
    Yes, I meant this one. But it has everything, it can create, edit, close a user so I don't want to use this menu. I want to create a responsibility that questionable users and reset their passwords, that is, not can change anything else.

    For this you must use the customization to restrict who has access to this responsibility / to make all actions other than resetting the passwords.

    How to customize the forms [ID 468657.1]
    Information about the ability to customize the form of Oracle Applications 11i [ID 279034.1]
    Sample unit test for the use of form customization in Oracle Applications [ID 744069.1]
    Limits of customization of forms [ID 420518.1]

    Document personalization of forms
    Document personalization of forms

    Thank you
    Hussein

  • How to create a button that scrolls down with page automatically?

    Hello

    I wanted to create a button that brings u to the top of the page when you press on, but I was wondering how to do scroll down with the page on the right side automatically when the some1 scrolls to the bottom of the page.

    An example I saw was on tumblr.com

    PS I'm a newbie, so please explain clearly. d.

    Thank you.

    This solution uses jQuery. When you scroll to halfway to the bottom of the page, an arrow appears on the right.  View source to see the code.

    http://ALT-Web.com/demos/jQueryBack-to-top.html

    Nancy O.

  • How to create a form that requires thousands of boxes?

    Hello forum members

    I have Adobe Acrobat 8 Professional.  I searched the internet and forums for the last few hours and I can't seem to find information on how to create a form with multiple check boxes.  I don't want to give individual names to thousands of boxes.  I am hoping there is a simple solution to my problem.  Maybe don't even need to use checkboxes.

    Here it is...

    I'm a DJ and the wedding season is coming.  For every wedding that I do, I usually give the bride and groom a list of my songs and they choose a bunch of songs they would like to have at their reception.  In the past, I've just been sent word to Web page with songs and they would send me their selections in another document or directly in the email response.  I want to make this process easy for them (and me) in a pdf document where they can simply place a check mark next to the songs they want and then send it to me.  Premium (if possible) I would like to be able to export the songs they have selected in a separate document so that I don't have to go through the full pdf (with thousands and thousands of songs) when they send it to me.

    I would be forever grateful if someone help me or direct me to a link with additional information.

    Thanks in advance,

    Mike

    Probably the best thing to do is to have Acrobat automatically adds checkboxes for you. It would take to add a box character by using a font such as Wingdings next to each song title. When you select "forms > run form field recognition", it detects each box on every page and add the checkbox fields.

    You need to activate the reader of the document (Advanced > user rights enable in Adobe Reader) so that users can save the completed form.

    Once you receive it back, you can run a script to create a list of selected songs. Exactly how do you it depends on indications of the final form that you create.

  • How to create Radio button that works like a Menu of rerouting

    Hi all

    Thanks in advanced for any help you can offer!

    I need assistance with Javascript that will dynamically created radio buttons act like the Menu for rerouting.

    Help, please. I need it as soon as POSSIBLE.

    I currently use several shortcuts menu (in Dreamweaver) to refresh the screen and additional Jump Menu on the screen. So that a user selects in the menu dropdown will refresh the page and update the content by following Menu go. I use Coldfusion for popular information. I use the URL to see the VARIABLES each refresh of the screen.

    Example URL: http://www.haysfluidcontrols.com/haysfluidcontrols/onlinecat/HoseKits.cfm

    ALSO, if any buddy knows how to create a Coldfusion page like this which are NOT REFRESHED when each choice, I'd LOVE to hear about it. I know of AJAX, but have not found anything made since then and have not been able to understand how incorperate it into my code.

    Thanks again,
    Matt

    Thanks for the comments everyone. I came up with a great solution. Thanks to Phil Hegedusich Direction. I am including my solution in this post. I also noticed that this code works with checkboxes.

    Thanks again for the help. I hope this helps others.

  • How to create a form that fills a page of review before being submitted?

    Anyone used Eloqua to create a form that fills a review page that the bidder has to address in order for the form to fill out?

    The sequence would be:

    1. landing page/form
    2. landing page with the data in the form of review
      • The second page with the form data will have to be approved before the presentation or the person could go back and change the data

    Thank you

    Jennifer Rash

    Hi Jennifer,.

    The way to do is to create a form with a field, mapping on a contact field you can set a value from us Let's say 1. and then on the second form, if the user access, he or she cannot present until whoever the approver is changes the value 0 (zero). Once the approval is made (assuming that anyone who needs to do this) the flag should be set to zero.

    Your form 2 form processing step can guide them in appropriate redirection, or javascript on the form page 2 can promot the user to wait for approval.

    Hope this helps... I would like to know if that's what you're looking for.

    Thank you

    Amit

  • How to create a button that opens the attachment (file power point attached to the pdf document)

    Hello world!

    The question is in the title.

    How to create a button in Acrobat Pro to open a file attached to PDF?

    I have moved your question to one of the forums of Acrobat, first.

    If the target file is not a PDF file you need to use a script to do it. The structure of the script would be something like this:

    this.exportDataObject ({cName: "Name of the attachment.ppt file", nLaunch: 2});

  • How to create a page that emits a sound when you click on an image or a button?

    I am trying to create a page that will be a lot of rectangular images on it. I want that these images make a sound when they are clicked on. I wish that for image power be clicked on as many times as the user needs. the page will be about 58 different images, and each will have its own. Perhaps the images should be buttons. I'm not really sure. Adobe Muse is even the application to create this? I need advice and would be very happy. Thanks in advance.

    You must find a suitable Gallery widget that supports click - sounds. Initially there is no way to do it with the options that Muse comes with a default.

    Mylenium

  • How to create a sequence that generates in the form of intellectual property?

    Hello

    I want to create a sequence that can generate an IP numbers. as

    224.0.0.1
    224.0.0.2
    .
    .
    .
    224.255.255.255

    Is this possible?


    Thank you very much

    KinsaKaUy? wrote:

    Then, just the format of address IP (exercise left to you)

    Hint please :)

    Enter the socket interface ntoa - simple enough to reproduce in the SQL and PL/SQL.

    PS. Look in the section "+ dotted IP number +"-it should run to the top of implementation details.

Maybe you are looking for

  • Satellite L - how to adjust the parameters of the webcam?

    Howdy, How can I adjust the settings of my web cam to take a photo of delayed? Thank you

  • How to make a user-defined structure and creat a pointer for the same thing

    Function The prototype of the dll function is long unsigned PassThruIoctl (unsigned long A, long B unsigned, void * pvar1, void * pvar2); ' void * pvar1 ' and ' Sub * pvar2 ' are pointers to different Structures. The value of "unsigned" long B will d

  • problem with the Luxor game

    Purchased the game via MSN games a year ago and finally made it through all the stages/levels. How to return to the starting point-first stage/level?

  • cRIO; FIFO FIFO or not?

    That is my question. My project is to use a cRIO-9073 there are three modules of analog inputs.  Two modules of outputs analog and a relay output module.  All are running in Scan Mode. Currently I have the chassis with modules installed on my desktop

  • Photo Gallery will not open the zip file

    Hi all Someone sent me an email with 5 photos inside zip file.  I downloaded the attachment and open the file with photo gallery.  I watched all 5 images successfully.  When I tried to turn one of the pictures I noticed the button to rotate the image