Calculate the area of intersection between two features

3892
6
Jump to solution
02-12-2016 03:46 AM
Highlighted
Occasional Contributor II

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

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
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()

View solution in original post

6 Replies
Highlighted
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.

Reply
0 Kudos
Highlighted
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.

Reply
0 Kudos
Highlighted
Occasional Contributor II

I am using Microsoft SQL Server

Reply
0 Kudos
Highlighted
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

Reply
0 Kudos
Highlighted
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()

View solution in original post

Highlighted
Occasional Contributor II

Thats exactly what I'm looking for

Many thanks Joshua!

Reply
0 Kudos