I have to build a grid of points and remove the points that falls inside a polygon. Polygons are defined in a ESRI shapefile, points are in a list.

This is how I make the test:

OGRLayer *layer = mShapefile->GetLayer(lr);
layer->SetSpatialFilter(&point); //getting only the feature intercepting the point
OGRFeature *ftr;
while (( ftr = layer->GetNextFeature()) != 0) {
    if (point.Within(ftr->GetGeometryRef())) {
         n.good = false;

This code works perfectly on Linux (Ubuntu 14.10, GDAL 1.11).

I had to recompile the library under MinGW64, first I forgot to compile with GEOS and the Within() call always returned false (as defined in the API).

If I compile with GEOS, the result is apparently a random response - some point outside the polygon set is filtered out, other inside are accepted.

Is there any known issue, or workaround, or maybe did I forget some other required library for gdal to work properly?

In a previous version I was only testing for results of GetNextFeature(), and it worked perfectly under linux. Under MinGW I found the same strange result.

  • It seems the build is broken. I am not sure why it happened, I suspect some dependency is badly screwed. Nov 27, 2014 at 12:29

1 Answer 1


The build is broken. After a long debugging, I found out that if PROJ4 isn't compiled before gdal, the resulting library will NOT work correctly with different reference spaces.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.