# Calculate the area of intersection between two features

3967
6
02-12-2016 03:46 AM
Occasional Contributor II

Is there a way to derive the area of intersection resulted by the intersection of two features after performing "SHAPE.StIntersects()"?

1 Solution

Accepted Solutions
MVP Esteemed Contributor

It appears you are using SQL Server native spatial types.  That said, it is best to be explicit and not make people guess.

First, STIntersects isn't the method you need.  It is a check of intersection and returns a SqlBoolean.

Below is an example using SQL Server native spatial types to retrieve the intersecting area of 2 polygons:

`Declare @g1 geometry;Declare @g2 geometry;SET @g1 = 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))'SET @g2 = 'POLYGON((5 5, 15 5, 15 15, 5 15, 5 5))'SELECT @g1.STIntersection(@g2).STArea()`
6 Replies
Regular Contributor III

If you perform an Intersect—Help | ArcGIS for Desktop  on two polygon feature classes and store the results in a geodatabase the area will be calculated for you. However you can also use the Add Geometry Attributes—Help | ArcGIS for Desktop  to calculate the areas or calculate geometry on a double field.

MVP Frequent Contributor

You don't say what sort of db you are using here. In sde the geometry function is ST_Intersect (I think).

This can return a query result, you would have to insert it into another feature, then calculate the area of that piece if geometry, as Wes says.

Otherwsie just use the Intersect tool, which creates that other feature as part of its output.

Occasional Contributor II

I am using Microsoft SQL Server

Esri Esteemed Contributor

MIcrosoft documentation or forums might be a better place to research the proper use of Microsoft SQL Server native functions.  The basic process is the same as with the Esri-written ST_Intersects and ST_Area functions used in non-Microsoft databases, but the SQL-Server syntax has it's own quirks (including case sensitivity), so it's best to get your information from the capability provider.

- V

MVP Esteemed Contributor

It appears you are using SQL Server native spatial types.  That said, it is best to be explicit and not make people guess.

First, STIntersects isn't the method you need.  It is a check of intersection and returns a SqlBoolean.

Below is an example using SQL Server native spatial types to retrieve the intersecting area of 2 polygons:

`Declare @g1 geometry;Declare @g2 geometry;SET @g1 = 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))'SET @g2 = 'POLYGON((5 5, 15 5, 15 15, 5 15, 5 5))'SELECT @g1.STIntersection(@g2).STArea()`
Occasional Contributor II

Thats exactly what I'm looking for

Many thanks Joshua!