caculating angle of polygon

조회 수: 3 (최근 30일)
Majid Al-Sirafi
Majid Al-Sirafi 2012년 1월 21일
댓글: nick 2025년 4월 14일
Hi, any one can help me for calculating the angles of polygon within ESRI shapefile
  댓글 수: 2
Majid Al-Sirafi
Majid Al-Sirafi 2012년 3월 21일
please help me
i want to calculate the angles of polygon feature within ESRI shapefile
nick
nick 2025년 4월 14일
Hello Majid,
To calculate the angles of a polygon from the shapefile in MATLAB, please follow these steps:
  • Use 'shaperead' function to read the shapefile and extract the polygon data.
  • For each polygon, extract the vertices coordinates and compute the angles at each vertex using arctan function over the vectors obtained using current and previous index as shown :
v1 = [x(prevIdx) - x(currIdx), y(prevIdx) - y(currIdx)];
v2 = [x(nextIdx) - x(currIdx), y(nextIdx) - y(currIdx)];
dotProd = dot(v1, v2);
crossProd = v1(1)*v2(2) - v1(2)*v2(1);
angles(j) = atan2(abs(crossProd), dotProd) * (180/pi)
Kindly refer to the documentation by executing the following command in MATLAB Command Window to know more about the 'shaperead' function:
doc shaperead

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by