SDO_GEOM.SDO_DISTANCE()

my sdo_version is showing me the latest one
hi guys is there anyissue for this sdo.geom package?? i need to use SDO_GEOM.SDO_DISTANCE() function alone..
many thanks
Kalinga

my sdo_version is showing me the latest oneIs it easier say this than telling us the version?
hi guys is there any issue for this sdo.geom package??No issue.
i need to use SDO_GEOM.SDO_DISTANCE() function
Not a problem here.

Similar Messages

  • Incorrect output by SDO_GEOM.SDO_DISTANCE

    I am trying to calculate the difference of two points on earth, but is not giving me correct result
    SELECT SDO_GEOM.SDO_DISTANCE(
    SDO_GEOMETRY(2001,8307,SDO_POINT_TYPE(28.66667,77.43333,NULL),NULL,NULL),
    SDO_GEOMETRY(2001,8307,SDO_POINT_TYPE(30.45,77.61667,NULL),NULL,NULL),
    0.0001,'unit=km') AS DISTANCE_BETWEEN_POINTS
    FROM DUALI tested it against http://www.movable-type.co.uk/scripts/latlong.html
    Query is returning me 47.6389006
    but the actual distance is: 199.1
    Please help me out.

    I also tested it by
    sqrt(x * x + y * y) * 1.609344 // for KM
    where x = 69.1 * (lat2 - lat1) and y = 53.0 * (lon2 - lon1)
    There is still a lot of difference.
    SQL> SQL> SQL> SELECT SDO_GEOM.SDO_DISTANCE(
    SDO_GEOMETRY(2001,8307,SDO_POINT_TYPE(28.66667,77.43333,NULL),NULL,NULL),
    SDO_GEOMETRY(2001,8307,SDO_POINT_TYPE(30.45,77.61667,NULL),NULL,NULL),
    0.0001,'unit=km') AS DISTANCE_BETWEEN_POINTS
    FROM DUAL  2    3    4    5  ;
    DISTANCE_BETWEEN_POINTS
                 47.6389006
    SQL> SELECT
    sqrt(69.1 * (30.45 - 28.66667) * 69.1 * (30.45 - 28.66667) + 53.0 * (77.61667 - 77.43333) * 53.0 * (77.61667 - 77.43333))  * 1.609344
    FROM DUAL  2    3  ;
    SQRT(69.1*(30.45-28.66667)*69.1*(30.45-28.66667)+53.0*(77.61667-77.43333)*53.0*(
                                                                          198.932013Please help....

  • ISSUS IN MDSYS.SDO_GEOM.SDO_DISTANCE()

    Hi experts,
    SQL> SELECT * FROM LOC_ZIP;
    COMP ZIPCD
    LOC(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    c1 z1
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(100, 1, NULL), NULL, NULL)
    c1 z2
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(200, 2, NULL), NULL, NULL)
    SQL> SELECT * FROM SUPP_ZIP;
    COMP SUPPI
    LOC(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    c1 s1
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(5, 1, NULL), NULL, NULL)
    c1 s2
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(77, 7, NULL), NULL, NULL)
    SQL> SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(L.LOC,S.LOC,NULL)
    FROM Loc_zip L,Supp_zip S
    WHERE L.compcd = S.compcd;
    SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(L.LOC,S.LOC,NULL)
    ERROR at line 1:
    ORA-22060: argument [2] is an invalid or uninitialized number
    ORA-06512: at "MDSYS.SDO_3GL", line 817
    ORA-06512: at "MDSYS.SDO_GEOM", line 3224
    ORA-06512: at "MDSYS.SDO_GEOM", line 3238
    Many Thanks,
    Kalinga

    You might try specifying a positive tolerance value (as the third argument to SDO_GEOM.SDO_DISTANCE), as in something like:
    SELECT
        MDSYS.SDO_GEOM.SDO_DISTANCE(L.LOC, S.LOC, 0.5)
    FROM
        Loc_zip L,
        Supp_zip S
    WHERE
        L.compcd = S.compcd;Hope this helps.

  • Haversine formula vs. MDSYS.SDO_GEOM.SDO_DISTANCE

    We need to calculate the distance between 2 lat/longs (from GPS unit).
    What is more accurate, the use of MDSYS.SDO_GEOM.SDO_DISTANCE or a hand coded Haversine Formula?
    Thanks,
    JB

    Well, easiest thing to do is to conduct a test.
    I looked at this website: http://www.movable-type.co.uk/scripts/latlong-vincenty.html
    The answer to the default functional demo is 969954.114 meters.
    Testing with SDO_DISTANCE we get (I converted the DMS values to DD):
    select sdo_geom.sdo_distance(
              sdo_geometry(2001,8307,sdo_point_type(-5.71475,      50.0663222222,null),null,null),
              sdo_geometry(2001,8307,sdo_point_type(-3.07009444444,58.6440222222,null),null,null),
              0.05) as dist
      from dual;
    -- Result
    969954.113110585Which is pretty similar!!
    So, don't bother coding your own Haversine (you would have to add extra parameters to pass in the ellisodal params for non-WGS84 SRIDs...), use what comes out of the box.
    Does that answer you question? If so, please award points.
    regards
    Simon

  • How Is sdo_geom.sdo_distance calculated in geodetic space?

    Hi,
    I'm new to oracle spatial -- but very familiar spatial SQL in Manifold GIS. In that package, there are two distance functions, a "distance", which returns the distance in native coordinates, and a "distanceEarth", which is used to return true distance (in meters) rather than degrees when working in lat/lon. When I author a basic distance query in oracle which finds the distances between all the geometries in one table and all the geometries in another table, the sgo_geom.sdo_distance will return the result in meters even when I am working in lat/lon. So when does the oracle distance function convert between degrees and meters? Is it really returning the true distance? In this clear?
    thanks!

    In Oracle Spatial, we always return the true distance based on the coordinate system
    of the geometry.
    If the geometry has lat/long values for coordinates, and appropriate SRID is set,
    we compute the true earth distance.
    If there is no SRID set for the geometry, the distance returned will be computed
    as if the long/lat values are x,y values.
    siva

  • Getting ORA-13000 error using SDO_DISTANCE.

    Hi!
    I am having problem executing query with SDO_DISTANCE function.
    System is Windows XP SP2, Oracle 10g latest version.
    First tables creation codes:
    CREATE TABLE BUILDINGS
    B_NUM NUMBER CONSTRAINT C_PK_BUILDINGS PRIMARY KEY,
    BUILDING MDSYS.SDO_GEOMETRY,
    B_INFO VARCHAR2(20)
    CREATE TABLE TREES
    T_NUM NUMBER CONSTRAINT C_PK_TREES PRIMARY KEY,
    TREE MDSYS.SDO_GEOMETRY,
    T_INFO VARCHAR2(20)
    Now metadata:
    INSERT INTO USER_SDO_GEOM_METADATA
    (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
    VALUES
    'BUILDINGS', 'BUILDING',
    MDSYS.SDO_DIM_ARRAY(
    MDSYS.SDO_DIM_ELEMENT('X', 0, 230, 0.05),
    MDSYS.SDO_DIM_ELEMENT('Y', 0, 120, 0.05)),
    NULL
    INSERT INTO USER_SDO_GEOM_METADATA
    (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
    VALUES
    'TREES', 'TREE',
    MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 0, 230, 0.05),
    MDSYS.SDO_DIM_ELEMENT('Y', 0, 120, 0.05)),
    NULL
    Finaly, the query:
    SELECT SDO_GEOM.SDO_DISTANCE(A.BUILDING, B.TREE, 0.005)
    FROM BUILDINGS A, TREES B
    WHERE A.B_NUM = 2 AND B.T_NUM = 3;
    I must add that I have tried various variants, but always receive the same error: ORA-13000 dimension number is out of range
    The data I've entered was new and entered.manually, so no problems with old data migration or anything like this. Here are input examples:
    INSERT INTO TREES VALUES
         1,
         MDSYS.SDO_GEOMETRY
              3,
              NULL,
              NULL,
              MDSYS.SDO_ELEM_INFO_ARRAY(1, 3, 4),
              MDSYS.SDO_ORDINATE_ARRAY(67, 105, 79, 99, 80, 111)
         'TREE1'
    INSERT INTO BUILDINGS VALUES
    1,
    MDSYS.SDO_GEOMETRY
              3,
              NULL,
              NULL,
              MDSYS.SDO_ELEM_INFO_ARRAY(1, 3, 1),
         MDSYS.SDO_ORDINATE_ARRAY(5, 56, 5, 116, 64, 116, 64,56)
    'Hall');
    Thanks for any info!

    You are using the 8.1.5 format for your geometry data, you've specified your data incorrectly.
    Use the 8.1.6 and higher format for your data:
    MDSYS.SDO_GEOMETRY
    2003,
    NULL,
    NULL,
    MDSYS.SDO_ELEM_INFO_ARRAY(1,1003, 4),
    MDSYS.SDO_ORDINATE_ARRAY(67, 105, 79, 99, 80, 111)
    This assumes the geometry above is an optimized circle.
    MDSYS.SDO_GEOMETRY
    2003,
    NULL,
    NULL,
    MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 1),
    MDSYS.SDO_ORDINATE_ARRAY(5, 56, 5, 116, 64, 116, 64,56, 5,56)
    Note the last ordinate has to match the first for this polygon.

  • SDO_DISTANCE returning incorrect results

    I have a query that uses sdo_distance to find N nearest neighbors (line strings) to a lat/lon (point). The problem is that sdo_distance is giving me geometries which it says are 0 units (in this case meters) from that lat/lon when in fact they are much farther away.
    here is an example:
    SELECT
    vw.reach_geom,
    round(SDO_GEOM.SDO_DISTANCE(vw.REACH_GEOM, sdo_geometry(2001, 8307,
                   sdo_point_type(-88.23579545454545, 44.87982954545455, NULL),
              NULL, NULL), 0.00005, 'unit=M'),4) Dist_In_Meters
    FROM all_geom_vw
    ORDER BY Dist_In_Meters;
    i get two geometries. the first is incorrect:
    GEOM
    SDO_GEOMETRY(2002, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(-86.687042, 45.836369, -86.687042, 45.836369, -86.689133, 45.836567))
    Dist_In_Meters
    0
    The second one is the correct one:
    GEOM
    SDO_GEOMETRY(2002, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(-88.380611, 44.996681, -88.380718, 44.995281, -88.380917, 44.993782,.....several other ordinates)
    Dist_In_Meters
    15.3559
    you can tell that the second one is much closer to the point since that lat/lon coords are pretty much the same.
    Any ideas what's happening here?
    thanks,
    John

    The first two points of the bad result geometry are the same point. "-86.687042, 45.836369, -86.687042, 45.836369," I'm pretty sure this will hose many spatial operations and may not throw an exception. Edit the geometry or do a "migrate to current" and it should work.
    -Ted

  • Is SDO_DISTANCE bug between the line and multipoints?

    SDO_GEOM.SDO_DISTANCE(MDSYS.SDO_GEOMETRY(2002,8307,null,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(113.363258142822,23.133208779985,113.3633,23.13331)),
    MDSYS.SDO_GEOMETRY(2005,8307,null,MDSYS.SDO_ELEM_INFO_ARRAY(1,1,2),MDSYS.SDO_ORDINATE_ARRAY(
    113.363258142822,23.1868700130491,113.365811605804,23.1322024265981))
    ,0.000005)
    the result is 5955.609972214.
    SDO_GEOM.SDO_DISTANCE(MDSYS.SDO_GEOMETRY(2002,8307,null,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(113.363258142822,23.133208779985,113.3633,23.13331)),
    MDSYS.SDO_GEOMETRY(2005,8307,null,MDSYS.SDO_ELEM_INFO_ARRAY(1,1,2),MDSYS.SDO_ORDINATE_ARRAY(
    113.365811605804,23.1322024265981,113.363258142822,23.1868700130491
    ,0.005)
    the result is 284.072193675135.
    In my points the results should be the same. Why are they different?
    If change the Element_Info
    SDO_GEOM.SDO_DISTANCE(MDSYS.SDO_GEOMETRY(2002,8307,null,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(113.363258142822,23.133208779985,113.3633,23.13331)),
    MDSYS.SDO_GEOMETRY(2005,8307,null,MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1,3,1,1),MDSYS.SDO_ORDINATE_ARRAY(
    113.363258142822,23.1868700130491,113.365811605804,23.1322024265981))
    ,0.000005)
    the result will be 284.072193675135.
    Why?Is it a bug of SDO_DISTANCE?

    Have a look here:
    Re: How to use java to store Multipolygon
    this is the javadoc:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14373/oracle/spatial/geometry/JGeometry.html#JGeometry_int__int__int____double___
    public JGeometry(int gtype,
    int srid,
    int[] elemInfo,
    double[] ordinates)
    Constructs a JGeometry instance with given information
    Parameters:
    gtype - the geometry type
    srid - the SRS id; if 0 is used then the MDSYS.SDO_GEOMETRY.SDO_SRID will be set to null when converted into DB format.
    elemInfo - geometry element info array
    ordinates - geometry ordinates array
    Maybe something like:
    JGeometry ps = New JGeometry (2005, 8307, new int[]{1,1, YOUR NUMBER OF POINTS IN YOUR CLUSTER}, new double[]{YOUR ORDINATES})
    Luc

  • Spatial 9.0.1.2  SDO_DISTANCE never returns

    Query:
    select sdo_geom.SDO_DISTANCE      (mdsys.sdo_geometry(2001, 8307, mdsys.sdo_point_type(28,235 -26,NULL), NULL, NULL),
                        mdsys.sdo_geometry(2001, 8307, mdsys.sdo_point_type(28, -26,NULL), NULL, NULL),
                        0.005) as distance from dual
    On oracle 817 returns :235
    on oracle 9012 the query never return a value
    Thanks
    Werner

    Werner,
    Do you mean that the distance comes back as zero ?
    If that is the case, there is a known bug in distance
    that is causing this problem. This is fixed in the
    9.0.1.3 patch set, so applying that patch would help.
    siva

  • SDO_DISTANCE - Tolerance

    If I have 2 point parms (not layers), with lat/longs with decimal places from 5 to 7 long, and I wanted to calculate the distance to within 5 CM, the formula would be:
    SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(
    mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(f_long,f_lat,NULL),NULL,NULL),
    mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(t_long,t_lat,NULL),NULL,NULL),
    .05,'unit=KM' ) AS km_dist2 FROM dual;
    What would be the equivalent (roughly within 5 cm) using a unit=MILE? Would I need to use a Tolerance of .0005?
    SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(
    mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(f_long,f_lat,NULL),NULL,NULL),
    mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(t_long,t_lat,NULL),NULL,NULL),
    .0005,'unit=MILE' ) AS mi_dist2 FROM dual;
    Thanks,
    JB

    It looks like the Tolerance Check is ALWAYS being done against Meters, even though, the Unit is either KM or MILE. It looks like if we were to set the tolerance to 0.05 it will always consider any 2 points as 1 point ONLY IF they are within approx. 5 CM of each other, even if MILE is specified as the UNIT?
    SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(
    mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.514366,43.072118,NULL),NULL,NULL),
    mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.2879915,43.1564514,NULL),NULL,NULL),
    18300,'unit=KM' ) AS km_dist2 FROM dual;
    Result = 20.6698332651529
    SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(
    mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.514366,43.072118,NULL),NULL,NULL),
    mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.2879915,43.1564514,NULL),NULL,NULL),
    18325,'unit=KM' ) AS km_dist2 FROM dual;
    Result = 0.0
    SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(
    mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.514366,43.072118,NULL),NULL,NULL),
    mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.2879915,43.1564514,NULL),NULL,NULL),
    18300,'unit=MILE' ) AS km_dist2 FROM dual;
    Result = 12.843638939315
    SELECT MDSYS.SDO_GEOM.SDO_DISTANCE(
    mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.514366,43.072118,NULL),NULL,NULL),
    mdsys.sdo_geometry(2001,8307,mdsys.sdo_point_type(-89.2879915,43.1564514,NULL),NULL,NULL),
    18325,'unit=MILE' ) AS km_dist2 FROM dual;
    Result = 0.0

  • SDO_DISTANCE - About its performance

    Hi, I'm using SDO_DISTANCE in order to obtain the minimum distance between the geometries (polygons) stored in some table. The results are OK but the performance isn't: it takes up to 3 minutes to compute the minimum distance between two of the geometries... while the equivalent PostGIS function with the same data takes only 3 or 4 seconds.
    This is the query I'm running:
    SELECT
         SDO_GEOM.SDO_DISTANCE(t1.geom, t2.geom, 0.05) as distance
    FROM
         mytable t1,
         mytable t2
    WHERE
         t1.id = 1 AND
         t2.id = 2;Am I doing something wrong? Thanks!

    Dante777,
    I looked at your original posting and decided I wouldn't waste the time trying to respond as there just wasn't anything in your posting that I could use to solve your problem.
    Follow this:
    Hi, I'm using SDO_DISTANCE in order to obtain the minimum distance between the geometries (polygons) stored in some table.You then provide a SQL statement:
    SELECT
         SDO_GEOM.SDO_DISTANCE(t1.geom, t2.geom, 0.05) as distance
    FROM
         mytable t1,
         mytable t2
    WHERE
         t1.id = 1 AND
         t2.id = 2;And then:
    Am I doing something wrong?Well, yes you are but it is not what you think.
    You simply don't supply any decent information to the hard working people who want to try to help you.
    Firstly you forgot to ask:
    ID columns have an index right?To whit you answer:
    That table has only a spatial index,
    How many records do the tables have?To whit you answer:
    with only 17 records I don't think it needs more than that.So, you don't answer a direct question about an attribute index rather we have to infer it from the new fact that it has a spatial index (which most users know is irrelevant to sdo_distance's operation) and only 17 records. That is, if it has only "17 records" why do I need an attribute index?
    Then you give us some good information that should have been provided up front:
    The geometries are quite complex (they have thousands of vertices), but still...OK, so Dante777, "how complex?". This is a potentially critical piece of information. Do you know how to describe that complexity? Perhaps something as easy as:
    SELECT
         t1.ID,
         SDO_UTIL.GETNUMVERTICES(t1.geom) as numVertices
    FROM
         mytable t1;As an "up front piece of information" it would be very helpful.
    Finally, there is an assumption because vital information was not provided up front:
    I assume that your geometries are geodetic.To whit you reply:
    The data is projected, not geodetic.
    I send you an email with the layer in SHP.But could you have provided TWO sdo_geometry objects in the original post obviating the need for emailing shapefiles?
    SELECT
         SDO_GEOM.SDO_DISTANCE(sdo_geometry(.....),sdo_geometry(.....), 0.05) as distance
    FROM
         dual;So, in summary, this is about an appeal for posters asking for help to provide better information so that they will get an answer back much faster than otherwise and those willing to help will not waste hours and days reading between the lines.
    Other forums for other Oracle and non-Oracle products ask for information up front - so should we.
    In your case:
    1. Whether or not the data is geodetic (SRID will do);
    2. Two example geometries in an example SQL statement repliers can run to replicate the problem.
    We can't replicate SQL execution on data - mytable - we don't have!
    3. Information in indexing, number of rows and geometry complexity.
    4. What version of the Oracle database you are running on (not mentioned in this article).
    5. Perhaps what Operating System.
    6. What client tool are you using? TOAD, SQuirreL, SQL Developer, SQLPlus?
    Please everybody who creates a new posting: try and help us to help you.
    Simon

  • Help! SDO_DISTANCE with 999999 SRID

    SELECT SDO_GEOM.SDO_DISTANCE(
    SDO_GEOMETRY(2001, 999999, SDO_POINT_TYPE(683644.093, 7465365.51, NULL), NULL, NULL),
    SDO_GEOMETRY(2001, 999999, SDO_POINT_TYPE(683544.093, 7465355.51, NULL), NULL, NULL),
    0.0000005, 'unit=KM') as Dist from dual
    I cannot get distance, but null. why 999999 not success?
    somebody can help me? thanks in advance
    btw, how to judge a point is in a line? e.g. the moving car (point) in which road (line)?

    hi, sorry for the poor expression here.
    select c2.linename
    from pointtable c1, linetable c2
    where c1.pointid = 108
    and SDO_RELATE(c1.GEOCOLUMN, c2.GEOCOLUMN,
    'MASK=ANYINTERACT')='TRUE';
    but it dosenot work well.
    Could you please explain what you mean by
    this?
    Does it return wrong results?
    I got nothing with this query. Nothing between the point and the line.
    Now, I use the distance, if the distance less than a threshold, I guess it's inside relationship, i.e. the moving car is in a certain road. Any better solutions?
    >>
    I want to use distance, but the point 2 linedistance
    is not reasonable (much larger than I thought)with
    the following sql:
    select c1.pointid, c2.linename,sdo_geom.sdo_distance
    (c1.STOPGEO, m1.diminfo, c2.GEOCOLUMN, m2.diminfo)
    dist
    from pointtable c1, linetable c2,
    user_sdo_geom_metadata m1, user_sdo_geom_metadatam2
    where c1.BESID = 1011
    and m1.table_name ='pointtable' and m1.column_name
    ='GEOCOLUMN'
    and m2.table_name ='linetable' and m2.column_name
    ='GEOCOLUMN'
    and rownum <= 10
    ORDER BY dist asc;
    i wanna use this for getting the top 10 closest roads for this moving point.
    now, i realize the problem it that I cannot use rownum<=10 before but after calculating distance:
    select * from (... order by disc) xx where rownum<=10
    I got the aim (linking point and road), but it's not exciting, very slow.
    I have 827330 points, and 78588 road segments.
    it's really computing expensive.
    Message was edited by:
    user646378

  • SDO_DISTANCE - plsql

    Hi
    I have point geometry with as given below. I am able generate max distance from hs1center and hs1 points.
    Also from hs2center to all hs2 points. SQL is working fine.
    I want to write PLSQL block and avoid hard coding of name values and generate distances for entire table in the same way. How to declare a cursor with same column which will have different values.
    name
    hs1center
    hs1
    hs1
    hs1
    hs1
    hs2center
    hs2
    hs2
    hs2
    hs2
    SQL> select max(sdo_geom.sdo_distance(a.geometry, b.geometry, 0.5, 'unit=FOOT')) from hspoints a, hspoints b where a.name='hs1center' and b.name='hs1';
    MAX(SDO_GEOM.SDO_DISTANCE(A.GEOMETRY,B.GEOMETRY,0.5,'UNIT=FOOT'))
    179.229393
    SQL> select max(sdo_geom.sdo_distance(a.geometry, b.geometry, 0.5, 'unit=FOOT')) from hspoints a, hspoints b where a.name='hs2center' and b.name='hs2';
    MAX(SDO_GEOM.SDO_DISTANCE(A.GEOMETRY,B.GEOMETRY,0.5,'UNIT=FOOT'))
    128.189931
    Any Help, Thanks...

    Hi
    Maybe you can try something like:
    where not(a.name = b.name)
    and
    instr(a.name, b.name) = 1
    Not tested myself.
    Good Luck
    Luc
    Edited by: Luc Van Linden on Mar 28, 2012 4:19 PM

  • Sdo_distance

    Hi, I took following bounds for SRID 32616 from EPSG and trying to compute distance.
    Projected bounds:
    166021.44 0.00
    534994.66 9329005.18
    SELECT   sdo_geom.sdo_distance( sdo_geom.sdo_geometry(2001 ,32616 ,sdo_geom.sdo_point_type(166021.44, 0, NULL) ,NULL ,NULL)
                               ,sdo_geom.sdo_geometry(2001 ,32616 ,sdo_point_type(534994.66, 0, NULL) ,NULL ,NULL) ,0.0001 ,'unit=METER') distance_in_m
                               from DUAL;
    I am getting the result 368973.22 m (368 km), i think the distance should be around 600 km.
    Please help me if i am wrong.
    Thanks

    Hi Don,
    First of all: I would use 4326 if you need WGS84, since it is more recent than 8307. Oracle marks 8307 as Legacy:
    select scrs.SRID, scrs.COORD_REF_SYS_NAME, scrs.COORD_REF_SYS_KIND, scs.COORD_SYS_TYPE,
          scs.DIMENSION, scrs.IS_VALID, scrs.IS_LEGACY, scrs.SUPPORTS_SDO_GEOMETRY, scs.COORD_SYS_NAME
    from SDO_COORD_REF_SYS scrs,
        SDO_COORD_SYS scs
    where scrs.COORD_SYS_ID = scs.COORD_SYS_ID and
          scrs.srid = 8307;
    Secondly: an ellipsoidal coordinate system measures distances along the curve of the earth, where a projected coordinate system measures distances along straight lines. It depends on the projection, but the longer the distance, the more these two distances are different. This is easy to see if you place a ruler on a ball (which is basically what happens, if the ball has been sat on by an elephant). Even in a small country like The Netherlands there is already a distortion at the ends of the country because of that.
    HTH,
    Stefan

  • SDO_DISTANCE for SRID=4156

    Hello, I have problem with distance.
    I created the elementary example:
    select sdo_geom.sdo_distance(
    SDO_GEOMETRY(2001,null,SDO_POINT_TYPE(1, 1, NULL),
    NULL,NULL),
    sdo_geometry(2001,null,SDO_POINT_TYPE(2, 1, NULL),
    NULL,NULL),
    0.5) as dist
    FROM dual;
    Result is 1.
    I created same example, but for SRID 4156 as you can see.
    SELECT SDO_GEOM.SDO_DISTANCE(
    SDO_GEOMETRY(2001,4156,SDO_POINT_TYPE(1, 1, NULL),
    NULL,NULL),
    sdo_geometry(2001,4156,SDO_POINT_TYPE(2, 1, NULL),
    NULL,NULL),
    0.5,
    'unit=M') as dist
    FROM dual;
    Result is 111289,738222679
    How is possible that result is soo different?
    The orientation of axis in the S-JTSK(for Czech Republic) with SRID 4156 are switched, but for this elementary example should be result still one.

    Hi Radan,
    Well, there are some larger issues here beyond measurement. Your first example has a NULL srid, which means this is "pure" cartesian planar coordinate system. You might think of it as an infinitely large sheet of graph paper (or eastern european notebook paper). Its perfectly flat and uniform and thus distance is just a matter of high school geometry reported in a generic unit - if you try to ask for meters or miles or whatever you will get ORA-13293. There is no mapping to the actual earth. Whether you measure the distance between 1 and 2 or 1,000,000 and 1,000,001, its all the same out in to infinity - just one generic unit.
    Now 4156 is a geodetic projection using decimal degrees as its unit of measure intended for usage around the Czech Republic and Slovakia.
    http://spatialreference.org/ref/epsg/4156/
    Neither decimal degrees nor the same in meters is comparable to that generic distance reported above. Now another question is why you are measuring coordinates down in the Gulf of Guinea with a Czech SRID? Still, its works well enough. If we measure the same distance with WGS84 we get 111302.65 meters.
    If you are looking for some kind of "default" SRID for testing or comparison, I guess I would say use WGS84 (4326).
    Cheers,
    Paul

Maybe you are looking for