Is there a way to derive the area of intersection resulted by the intersection of two features after performing "SHAPE.StIntersects()"?
Solved! Go to Solution.
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()
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.
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.
I am using Microsoft SQL Server
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
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()
Thats exactly what I'm looking for
Many thanks Joshua!