ThinkGeo.com    |     Documentation    |     Premium Support

Intersection returning no result

Hi, I am new to this topic and don’t have much understanding on the subject. I am trying to find out the county details from the PLSS layer. for which I am intersecting PLSS layer with County Layer using query tool.

below is the code to get county which has a geography column in SQL table:

SELECT[id] AS Id,[geom].STAsText() as GeomBinary,[FIPS] Fips,[NAME] Name,[STATE_NAME] StateName,[STATE_FIPS] StateFips,[CNTY_FIPS] CountyFips FROM [dbo].[Map_County] WHERE [STATE_FIPS] + [CNTY_FIPS] =’" + stateCounty + “’”

var columnValues = new Dictionary<string, string>();
columnValues.Add(“id”, mapCounty.Id.ToString());
columnValues.Add(“FIPS”, mapCounty.Fips);
columnValues.Add(“NAME”, mapCounty.Name);
columnValues.Add(“STATE_NAME”, mapCounty.StateName);
columnValues.Add(“STATE_FIPS”, mapCounty.StateFips);
columnValues.Add(“CNTY_FIPS”, mapCounty.CountyFips);
var countyFeature= new Feature(mapCounty.GeomBinary, mapCounty.Id.ToString(), columnValues);

Below is the code to get the PLSS layer and intersecting it with county layer:

string strProj = “269” + countyZone;
var proj4 = new Proj4Projection
{
InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(Convert.ToInt32(strProj)),
ExternalProjectionParametersString = Proj4Projection.GetBingMapParametersString()
};
var plssLayer = new MsSqlFeatureLayer(_plssImportConfiguration.PLSSDataBaseConnectionString, “plss_table”, “id”);
plssLayer.WhereClause = “where STATEABBR in (’” + STATEABBR + “’)”;
plssLayer.FeatureSource.Projection = proj4;
PolygonShape poly;

        var proj4C = new Proj4Projection
            {
                InternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString(),
                ExternalProjectionParametersString = Proj4Projection.GetBingMapParametersString()
            };
        plssLayer.Open();


                proj4C.Open();
                poly = (PolygonShape)proj4C.ConvertToExternalProjection(countyFeature.GetShape());
                proj4C.Close();

        qt = new QueryTools(plssLayer.FeatureSource);
  features = qt.GetFeaturesIntersecting(poly, new string[] { "Objectid" });

Here the feature is always returned as zero, note that above entire code is iterated for each county in that state, the PLSS table has geometry in it and is imported from GDB file.
Please help me identifying what I am missing over here.

Hi Soham,

Can you do plssLayer. GetBoundingBox() and poly.GetBoundingBox() and find out if plssLayer does intersects with poly?

If not that might because either plssLayer’s projection or poly’s projection is not correct (I suppose plssLayer’s projection is wrong). You can display them on top of a background map (OSM for example) to make sure.

If the boundingboxes look good, you can also display both plssLayer and poly on the map, and see visually if there are any interacting features. I think you can see the issues there.

BTW, you can do plssLayer.QueryTools.GetFeaturesIntersecting() instead of creating q new QueryTools object.

Thanks,
Ben