Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Newbie in arcobject 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) where POI.HouseNo=Parcel.UNIT_ID and then create a new shape file 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 shape file. How can I do this?

please help.

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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