【发布时间】:2013-06-29 21:35:39
【问题描述】:
我试图仅包含位于给定边界框内的 shapefile 中的地理特征。我找不到类似于 Matlab 的 shaperead 函数和 BoundingBox 选项 [1] 的函数,所以我试图从图层的线串中删除不相关的点,但是我不确定如何做到这一点(我有点期待那里将与 addPoint [2] 相反)。我到目前为止的代码是:
OGRLineString *poLineString = (OGRLineString *) poGeometry;
int numPoints = poLineString->getNumPoints();
cout << "num points" << poLineString->getNumPoints() << endl;
//for each feature check if its in the bounding box
for (int i=0; i<numPoints; i++)
{
// start off assuming we are including everything
bool xInclude, yInclude = 1;
OGRPoint* poPoint;
poLineString->getPoint(i, poPoint);
double ptX = poPoint->getX();
double ptY = poPoint->getY();
cout << "ptX " << ptX << " ptY " << ptY <<endl;
//tlE, tlN, maxE, maxN are eastings/northings coordinates
if((ptX<tlE)||(ptX>maxE))
xInclude=0;
if((ptY<minN)||(ptY>tlN))
yInclude=0;
if(!(xInclude && yInclude))
//poLineString->setPoint(i,0,0);
REMOVE POINT HERE
}
有什么想法吗?
【问题讨论】: