Skip to Main Content


Question and Answer

Connor McDonald

Thanks for the question.

Asked: December 08, 2023 - 8:43 pm UTC

Last updated: May 20, 2024 - 1:17 am UTC


Viewed 1000+ times

You Asked

I have created a map in Oracle APEX where the user can click and get the lat and long and drop a pin there. Now, I want to find which congressional district the pin was dropped in. I have a table with all congressional districts, but that is geojson data that gives polygons for the congressional districts. Is there a way for me to search a congressional district using lat and long?
Your help will be greatly appreciated

and we said...

Yes, you can query for containment using a spatial operator as described here: You can try it with this LiveLabs self-paced workshop: see Lab 4 Task 2 for containment queries.


  (6 ratings)

Is this answer out of date? If it is, please let us know via a Comment


Thanks for your response.

Vatsa, December 11, 2023 - 3:07 pm UTC

I forgot to mention that the polygon data for the congressional districts in the table is ia CLOB and not SDO_GEOMETRY. Given a lat and long I want to find out which congressional district are those coordinates in.
Sorry for not being clear the first time.


convert wkt to sdo_geometry

good luck, December 17, 2023 - 12:07 pm UTC

If you want to do spatial queries, you need to use sdo_geometry objects. You can convert the clob to a polygon dynamically in the query using the function sdo_util.from_wktgeometry


Load geojson as SDO_GEOMETRY

Karin Patenge, January 08, 2024 - 8:49 am UTC

Besides the conversion functions provided by the SDO_UTIL package, you can also load GeoJSON data via Oracle Spatial Studio. It automatically creates SDO_GEOMETRY objects from your GeoJSON.
Then, simply use SDO_RELATE with mask=INSIDE/ANYINTERACT or SDO_INSIDE/SDO_ANYINTERACT get your containment question answered.

Thanks for your response.

Vatsa, April 30, 2024 - 12:23 pm UTC

I converted the BLOB column to SDO_GEOMETRY using the function, but when I tried to plot the polygon using the converted column it does not draw the polygon. So, I am not sure if the conversion has happened correctly or if I am missing something.
Connor McDonald
May 20, 2024 - 1:17 am UTC

If you could build a tiny test case either in APEX on or just in plain SQL, so we can better understanding when you are trying to do.

Converted CLOB to SDO Geometry

Vatsa, May 20, 2024 - 3:01 pm UTC

Here is the table
GEOMETRY CLOB (Contains the polygon data for US congressional districts in GeoJSON format)
PARTY varchar2(1)
STATE varchar2(2)
DISTRICT Varcha2(200)

I converted the geometry column that is clob to SDO_GEOMETRY using the following query.

Select sdo_util.from_wktgeometry(GEOMETRY) as GEOM, ID, DISTRICT, FIRSTNAME, LASTNAME,

When I tried to plot the conversted GEOM column on a map, it does not show on the map.
However, when I just use the CLOB column and use it as GeoJSON column, the polygon is showing up.