• Add-In for ArcGIS 10 Desktop via ArcObjects for .NET
  • The below code returns ALL features for the layer when the map is specified with any Geographic Coordinate System.
  • However, the below code works fine when the map is specified with a Projected Coordinate System. That is, returning a subset of the features within the radius.


IPoint viewPoint = new PointClass() as IPoint;      
// lon, lat here are WGS 84
viewPoint.PutCoords(lon, lat);  

// project input point to coordinate system of map  
ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass();  
IGeographicCoordinateSystem pcs =

pcs.SetFalseOriginAndUnits(0.0, 0.0, 1000);
ISpatialReference srWgs84;
srWgs84 = pcs;
// if not WGS84 project it (omitting subroutine here..)
if (!CompareSpatialRefs(map.SpatialReference, srWgs84))
    //Geometry Interface to do actual project
    IGeometry geometry;
    geometry = viewerPoint;
    geometry.SpatialReference = srWgs84;
    viewPoint = geometry as IPoint;
    viewPoint.SpatialReference = srWgs84;

esriUnits distUnits = map.DistanceUnits;
// convert meters to map dist units (again, omitting subroutine..)
double bufferDist = ConvertToMapUnits(_myQueryRadiusInMeters, distUnits);
// using ITopoOp to generate a buffer
ITopologicalOperator topoOperator = (ITopologicalOperator)viewPoint;
IGeometry viewBuffer = topoOperator.Buffer(bufferDist);
IFeatureClass featureClass = myFeatureLayerInQuestion.FeatureClass;
IFeatureCursor featCursor = PerformSpatialQuery(featureClass, viewBuffer,
                                  esriSpatialRelEnum.esriSpatialRelIntersects, "");


// code straight from the ArcGIS Snippet Finder
public IFeatureCursor PerformSpatialQuery(IFeatureClass featureClass, IGeometry searchGeometry, esriSpatialRelEnum spatialRelation, string whereClause)
    if (featureClass == null)
        return null;
    // create a spatial query filter
    ISpatialFilter spatialFilter = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass();

    // specify the geometry to query with
    spatialFilter.Geometry = searchGeometry;

    // specify what the geometry field is called on the Feature Class 
    // that we will be querying against
    System.String nameOfShapeField = featureClass.ShapeFieldName;
    spatialFilter.GeometryField = nameOfShapeField;

    // specify the type of spatial operation to use
    spatialFilter.SpatialRel = spatialRelation;

    // create the where statement
    spatialFilter.WhereClause = whereClause;

    // perform the query and use a cursor to hold the results
    IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
    queryFilter = (ESRI.ArcGIS.Geodatabase.IQueryFilter)spatialFilter;
    IFeatureCursor featureCursor = featureClass.Search(queryFilter, false);

    return featureCursor;

At this point, I iterate over the features in the featureCursor, calling featCursor.NextFeature(). Again any Projected Coordinate System, good. It appears for any Geographic Coordinate System, the cursor contains all the features for the layer.

Many thanks for any help!

EDIT: I believe I've figured out the issue. Please see my posted answer below.

  • Could it have something to do with your false origin?
    – Jim B
    Commented Oct 20, 2010 at 4:10
  • Quite possibly... Also playing with calling CreateProjectedCoordinateSystem() and projecting in that direction
    – Josh
    Commented Oct 20, 2010 at 16:53

1 Answer 1


It appears my omitted subroutine, ConvertToMapUnits, held the answer, as well as problematically using map.DistanceUnits as opposed to map.MapUnits.

Specifically, if the map is specified with a Geographic Coordinate System, convert selection radius in meters to decimal degrees:

// convert meters to map units - including a meters to decimal degrees conversion
// for the given latitude... 
esriUnits mapUnits = map.MapUnits;
// in this case 'buffDist' is now in dd
double buffDist = ConvertToMapUnits(myQueryRadiusInMeters, mapUnits, inputLat);
// using ITopoOp to generate a buffer
ITopologicalOperator topoOperator = (ITopologicalOperator)viewPoint;
IGeometry viewBuffer = topoOperator.Buffer(buffDist);


This seems like a classic mistake, but I hope it will prove helpful to others.

Your Answer

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

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