Calculate the area of intersection between two features

6047
6
Jump to solution
02-12-2016 03:46 AM
HaniDraidi
Occasional Contributor II

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

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
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
WesMiller
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.

0 Kudos
NeilAyres
MVP Alum

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.

0 Kudos
HaniDraidi
Occasional Contributor II

I am using Microsoft SQL Server

0 Kudos
VinceAngelo
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

0 Kudos
JoshuaBixby
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()
HaniDraidi
Occasional Contributor II

Thats exactly what I'm looking for

Many thanks Joshua!

0 Kudos