Categories
Oracle Spatial

Oracle AI Database 26ai – now with Spatial Studio Integrated

Spatial capability is a powerful feature of the Oracle AI Database 26ai allowing us to create analytics to determine things like

  • Which store locations should we show to a potential customer as they are nearest to them?
  • Which suppliers for our building project are within a 20 mile radius of the site?
  • Which school pupils live far enough away to qualify for transport?

Spatial studio has been available as a separate downloadable application for some years and is a great help to visually answering these sorts of questions and creating SQL for us to use in other applications, but being a separate installation is an inhibitor to adoption.

I read recently that from April 14th 2026, Spatial Studio is now available as a component of the Oracle 26ai AI Autonomous Database which makes it much more “immediate” for people to be able to interact with spatial data removing the need to have to manage or install a separate application. More details are in the document that i’ve linked to above.

The tool configuration section of the database sets out the definition of Spatial Studio really concisely.

In this article we will have a look at what we need to setup, use the geo-coding facilities and analyse some data, showing how having Spatial Studio fully integrated into the Autonomous 26ai database really can accelerate adoption but also shows us the code that is generated behind the scenes that can be used in different applications.

Firstly Set Up A User

We need to create a user and give them the requisite privileges.

  • We need the right database roles set up first, so check out the Set Up Spatial Studio Users and Privileges guide to get sorted, but we can quickly create a basic user, give them some quota so they can upload some data and grant them a SPATIAL_ADMIN or SPATIAL_AUTHOR roles. There is a “read-only” SPATIAL_CONSUMER role, but we need the ability to create content.
Connecting to the Autonomous AI Database
  • Sign in to Oracle Cloud and select the Autonomous AI Database Serverless instance
  • Head to the Tool configuration tab on the database details page and note the Public access URL for Spatial Studio
  • Paste that URL into your browser, the login screen will pop up
  • Enter your credentials, hit Sign In, and you’re in.

In this example I just created a new user called “spatial” and gave it some quota and granted the SPATIAL_ADMIN role. This gives us access to the full Spatial Studio application as seamlessly as possible.

Now we can start to upload some data and create a dataset that we can use in projects.

I will upload a spreadsheet called “sales_data” that contains some sales of products in different stores that I have across the UK. There is a latitude and longitude in this dataset for each store location.

We can see the data when we load up the dataset and below we can see some of the Cities and and their locations.

Press “Submit” and the dataset is processed. If there is a lot of data then you can goto the “Jobs Page” to see it in action.

Once loaded, if we get alerted that there’s some additional work we need to do on the dataset.

Clicking on it, we see there are two issues. (1) There is no key column identified on the table and (2) We need to either Geocode the address or identify the columns that are Lat/Long so that a spatial index can be created.

If i’d had some column in the spreadsheet that was unique I could have used that, but we can also get Spatial Studio to generate a key column for us.

The created column then appears, and we can see there’s 699 records.

There is just one issue now.

I have latitude and longitude columns in this dataset, so I will select the lat/long index and identify which are the appropriate columns.

We press “OK” and then get confirmation that the indexing process has been successful.

Returning to the dataset, we now see that it has no warnings and the icon to show that it is ready to be used in spatial analysis.

Clicking on the “…” menu on the right hand side shows us what we can now do with that dataset, and we will select “Create Project” so that we can start to use it immediately.

The project screen appears, with our dataset loaded.

Drag and drop the dataset into the diagram, and we see it populated with the data points.

If we click on “Layers” we can select “Settings” and perform a number of tweaks to how the dataset appears in the map so we can change things like colours, sizes ( even based on metrics ).

I’m going to use the SALES_AMOUNT metric to size the data points.

I can even tweak the relative sizes based on binning, so I can make things “pop” if I want to in order to highlight sales in certain ranges.

There’s other settings, such as rendering the data as a heatmap or clusters. Let’s select clusters.

Load a Second Dataset

I have a second dataset which has 1 record in it, which is just my address. No lat/long columns this time, just an address, but we can Geocode it.

We can see here it’s just an address, so we can press “Submit” and create a new data set.

Here we have a unique column ( my name ) and I can toggle it to identify this as a key column.

The dataset is still showing a warning as the data has not got a spatial index or a geocoded column, so this time we will select Geocoding. We have the ability to specify which columns are mapped to “Address Components”.

Pressing “Apply” and the data is Geocoded and we can see this was successful.

Now we have a key column and a Geocoded address we are good to go.

Add the dataset to the project as we did with the other one. We can add multiple datasets to a single project and get many layers of information that we can analyze together.

Now we can drag the data set into the project, and use the settings to make this item really pop by making it a symbol, sizing it so that it really stands out and making it bright blue. We now have both datasets on the same project so we have the sales data as orange points based on the Sales metric and my address as a big blue star.

We can use these datasets to create some spatial analytics. If we click on “Create Analysis” then we get a menu of options across Filters, Combine, Transform, Measure and a specific group of Analytics.

We will select Return shapes nearest to another which will perform a nearest neighbours spatial calculation.

We give the analysis a name ( SDO_NN_MARK ) and we’re going to be filtering the sales data dataset (i.e. the one containing all the sales data and locations) by the dataset containing my address and just returning 1 record. This will give us the closest sales site to my address.

Note that there is a Preview SQL button which allows us to see the SQL that this template will produce. We can actually take this SQL and run it directly in the Oracle database, and we will do that later in this article to show how this can be used in other tools. Spatial Studio effectively becoming the SQL generator for us.

SELECT 
	"t6"."YEAR", 
	"t6"."UNITS_SOLD", 
	"t6"."TARGET", 
	"t6"."SUB_REGION", 
	"t6"."SALES_AMOUNT", 
	"t6"."SALESPERSON", 
	"t6"."REGION", 
	"t6"."PROFIT_MARGIN", 
	"t6"."PRODUCT_NAME", 
	"t6"."PRODUCT_CATEGORY", 
	"t6"."MONTH_NUM", 
	"t6"."MONTH", 
	"t6"."LONGITUDE", 
	"t6"."LATITUDE", 
	"t6"."CUSTOMER_SEGMENT", 
	"t6"."CUSTOMER_FEEDBACK", 
	"t6"."COUNTRY", 
	"t6"."CITY", 
	"t6"."NEWKEY", 
	SPATIAL.SGTECH_PTF("t6"."LONGITUDE", "t6"."LATITUDE") AS "LATITUDE_LONGITUDE_GEOMETRY" 
FROM 
	"SALES_DATA" "t6" 
WHERE 
	"t6"."NEWKEY" IN 
		(SELECT 
			"t5"."ID1" AS "ID" 
		FROM 
			(SELECT 
				"t4"."ID1", 
				ROW_NUMBER() OVER (PARTITION BY "t4"."ID2" ORDER BY "t4"."DISTANCE") AS "NEIGHBOR_RANK" 
			FROM 
				(SELECT 
					"t2"."NEWKEY" AS "ID1", 
					"t3"."NAME" AS "ID2", 
					SDO_NN_DISTANCE(1) AS "DISTANCE" 
				FROM 
					"SALES_DATA" "t2", 
					(SELECT 
						"t1".* 
					FROM 
						"MARK_ADDRESS" "t1" 
					WHERE 
						"t1"."NAME" IN ('Mark Daynes')
					) "t3" 
				WHERE 
					SDO_NN(SPATIAL.SGTECH_PTF("t2"."LONGITUDE", "t2"."LATITUDE"), "t3"."GC_GEOMETRY", 'sdo_batch_size=10 unit=METER', 1) = 'TRUE'
				) "t4"
			) "t5" 
		WHERE 
			"t5"."NEIGHBOR_RANK" <= 1
		)

The key here is the SDO_NN call which is getting the closest neighbour. This now creates a new dataset containing the data that was filtered from the sales data to get the nearest sales location to my address. We can then drag this onto the project map. If we then “hide” the original layers ( by clicking on the eye icon to temporarily hide them ) then the single closest location pop out. Note that we have not changed any of the settings so it is just a default of an orange point – if we wanted to, then we could change the look and feel of that point to make it really stand out.

We can then turn all the layers on so we see everything in context.

Let’s create another layer. This time we’ll create a new analytic to Return shapes within a specific distance of another

We will compare the first two datasets, and filter the sales locations that are within a 100 Mile radius of my house.

Here we get a another new layer with the results of that analysis, and if we show my address ( still as the big star ) and the results of the locations within a 100 mile radius, we see the sites in Manchester, Birmingham, Nottingham and Leeds visible.

Finally let’s use one of the Combination templates and create a Rubber Band to envelop a selection of the sites.

Here we will take the results of the analysis to select the sales locations that are in a 100 Mile radius of my house so we can really see them appear.

Let’s look at the code before we run it.

SELECT 
	SDO_AGGR_CONVEXHULL(SDOAGGRTYPE("t5"."GEOMETRY", 0.05)) AS "GEOMETRY", 
	'1' AS "KEY" 
FROM 
	(SELECT 
		SDO_AGGR_CONVEXHULL(SDOAGGRTYPE("t4"."LATITUDE_LONGITUDE_GEOMETRY", 0.05)) AS "GEOMETRY", 
		'1' AS "KEY" 
	FROM 
		(SELECT 
			"t3"."YEAR", 
			"t3"."UNITS_SOLD", 
			"t3"."TARGET", 
			"t3"."SUB_REGION", 
			"t3"."SALES_AMOUNT", 
			"t3"."SALESPERSON", 
			"t3"."REGION", 
			"t3"."PROFIT_MARGIN", 
			"t3"."PRODUCT_NAME", 
			"t3"."PRODUCT_CATEGORY", 
			"t3"."MONTH_NUM", 
			"t3"."MONTH", 
			"t3"."LONGITUDE", 
			"t3"."LATITUDE", 
			"t3"."CUSTOMER_SEGMENT", 
			"t3"."CUSTOMER_FEEDBACK", 
			"t3"."COUNTRY", 
			"t3"."CITY", 
			"t3"."NEWKEY", 
			SPATIAL.SGTECH_PTF("t3"."LONGITUDE", "t3"."LATITUDE") AS "LATITUDE_LONGITUDE_GEOMETRY" 
		FROM 
			"SALES_DATA" "t3" 
		WHERE 
			"t3"."NEWKEY" IN 
				(SELECT 
					"t1"."NEWKEY" AS "key" 
				FROM 
					"SALES_DATA" "t1", 
					"MARK_ADDRESS" "t2" 
				WHERE 
					SDO_WITHIN_DISTANCE(SPATIAL.SGTECH_PTF("t1"."LONGITUDE", "t1"."LATITUDE"), "t2"."GC_GEOMETRY", 'distance=100 unit=MILE') = 'TRUE'
				)
		) "t4"
	) "t5"

SDO_AGGR_CONVEXHULL is the key spatial command being used to create the polygon. We can drag that into the project and this creates a polygon, and we can change the colour and opacity of that, which spans across the points we have selected.

Specifically it creates a convex hull which is the tightest possible convex polygon that encloses all of the selected points, which explains why the shape might look slightly larger than expected.

Use In SQL

We can use that SQL we saw as SQL in our Oracle 26ai AI Database just as a pure query, so we can have agents using it if we wanted. It’s a great way to visually interact with the data and then generate reusable SQL. I show this “in action” using the SQL Developer plugin for VS Code running the SQL we generated above to get the array of locations that meet the criteria we set. Of course, we can then amend this SQL to do anything we want as a separate piece of code independent now of the Spatial Studio that generated it.