35.17 SDO_UTIL.FROM_GEOJSON
Format
SDO_UTIL.FROM_GEOJSON( geometry IN VARCHAR2, crs IN VARCHAR2 DEFAULT NULL, srid IN VARCHAR2 DEFAULT 4326 ) RETURN SDO_GEOMETRY;
or
SDO_UTIL.FROM_GEOJSON( geometry IN CLOB, crs IN VARCHAR2 DEFAULT NULL, srid IN VARCHAR2 DEFAULT 4326 ) RETURN SDO_GEOMETRY;
or
SDO_UTIL.FROM_GEOJSON( geometry IN JSON, crs IN VARCHAR2 DEFAULT NULL, srid IN VARCHAR2 DEFAULT 4326 ) RETURN SDO_GEOMETRY;
Description
Converts a GeoJSON object (or more specifically a geometry object in GeoJSON format) to a Spatial geometry object.
Parameters
- geometry
-
Geometry in GeoJSON format to be converted to SDO_GEOMETRY format. The JSON object data type can be VARCHAR2, CLOB, or JSON.
- crs
-
(Reserved for future use. The default is null.)
- srid
-
SDO_SRID value to be used in the returned geometry. The default is 4326, which is the EPSG SRID value for the WGS 84 (longitude/latitude) coordinate system.
Usage Notes
The input geometry must be in GeoJSON format. For information about using JSON data that is stored in Oracle Database, see Oracle Database JSON Developer's Guide.
To convert an SDO_GEOMETRY object to GeoJSON format, use the SDO_UTIL.TO_GEOJSON function.
Examples
The following example shows conversion to and from GeoJSON format. (The example uses the definitions and data from Simple Example: Inserting_ Indexing_ and Querying Spatial Data, specifically the cola_b
geometry from the COLA_MARKETS table.) In this example, specifying srid => NULL
causes the returned SDO_GEOMETRY object to have an SDO_SRID value of NULL, as opposed to the default of 4326 if the parameter is not specified.
DECLARE cola_b_geom SDO_GEOMETRY; returned_geom SDO_GEOMETRY; returned_json CLOB; BEGIN -- Populate geometry variable with cola market cols_b shape. SELECT c.shape into cola_b_geom FROM cola_markets c WHERE c.name = 'cola_b'; -- From geometry to JSON returned_json := SDO_UTIL.TO_GEOJSON(cola_b_geom); -- From JSON to geometry returned_geom := SDO_UTIL.FROM_GEOJSON(returned_json, srid => NULL); END; /
Related Topics
Parent topic: SDO_UTIL Package (Utility)