简体   繁体   中英

How to convert multiple values from SDO_GEOMETRY to WKT format?

I am aware that I can convert ORACLE SDO_GEOMETRY to WKT format. But, I don't know how to convert it if it contains multiple values. How do I do that?

I have the following table:

ID SDO_GEOMETRY
1234 SDO_GEOMETRY(2001, NULL, MDSYS.SDO_POINT_TYPE(9971, 19188, NULL), NULL, NULL)
1235 SDO_GEOMETRY(2001, NULL, MDSYS.SDO_POINT_TYPE(9972, 18282, NULL), NULL, NULL)
1236 SDO_GEOMETRY(2001, NULL, MDSYS.SDO_POINT_TYPE(9977, 19201, NULL), NULL, NULL)
1237 SDO_GEOMETRY(2001, NULL, MDSYS.SDO_POINT_TYPE(9993, 18225, NULL), NULL, NULL)
1238 SDO_GEOMETRY(2001, NULL, MDSYS.SDO_POINT_TYPE(10035, 18367, NULL), NULL, NULL)

I would like to convert all these values to WKT at once. How do I do that? What I tried so far?

CREATE TABLE new_test ( name varchar2(20), geom SDO_GEOMETRY );

INSERT INTO new_test (name, geom)
VALUES (
  '1234', 
  SDO_GEOMETRY(2001, NULL, MDSYS.SDO_POINT_TYPE(9971, 19188, NULL), NULL, NULL);
  
);

SELECT NAME, SDO_UTIL.TO_WKTGEOMETRY(GEOM) AS point FROM NEW_TEST;

The above script converts only one at a time. How do I implement that for multiple rows?

You describe a CREATE TABLE, then an INSERT that puts only one row in the table and then a SELECT. If your description is verbatim, your last SELECT should - and will return only one row (because the table has only one row). SELECT... sdo_util... from NEW_TEST as is (without a WHERE clause) will (convert and) return all rows of that table.

you could use SDO_UTIL.TO_WKTGEOMETRY("name_of_ur_geometry_column") as GEO_WKT an then save it to an csv,txt or whatever you need

the result is something like this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM