Newbie in ArcObjects programming. Using C#. Developing a desktop application.

I need to join 2 tables:

  • POI layer which is a Point layer and
  • a parcel layer which is a Polygon


POI.HouseNo = Parcel.UNIT_ID

and then create a new Shapefile which has only the 4 fields:

  • POIName,
  • POIType,
  • HouseNo (all from POI layer attributes),
  • ParcelName (all from Parcel Layer attributes).

The user selects the POI Layer and the Parcel layer from combo boxes.

Here is the code I have written so far:

IFeatureWorkspace featureWorkspace;
IQueryDef queryDef = featureWorkspace.CreateQueryDef();
queryDef.Tables = cboPOI.Text + "," + cboParcel.Text;
queryDef.SubFields = cboPOI.Text + ".Name," + cboPOI.Text + ".Type," + cboPOI.Text +".HouseNo," + cboParcel.Text + ".ParcelName";
queryDef.WhereClause = cboPOI.Text + ".HouseNo =" + cboParcel.Text+ ".UNIT_ID";

Hope I'm on the right track. Now I need to run this query and get the output to a new Shapefile. How can I do this?

please help.


The AO-API has got an example. This would mean that you would have to extent your code by the following lines:

IFeatureDataset featureDataset = featureWorkspace.OpenFeatureQuery("MyJoin", queryDef);
IFeatureClassContainer featureClassContainer = (IFeatureClassContainer)featureDataset;
IFeatureClass featureClass = featureClassContainer.get_ClassByName("MyJoin");

And just assign that feture class to a feature layer. Assuming you really want to create a new shapefile in the filesystem, you can export the created feature class with a geoprocessor like FeatureClassToShapefile.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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