0

I am trying to build a model to input table data, make xy event layer and then select features by an SQL expression and make that a shapefile. What tool should I use for the SQL expression to select the features?

  • I think you can do it with "selectLayerByAttribute" – radouxju Feb 20 '14 at 20:06
  • When I use that I get this error: ERROR 000339: Input C:\Users\cbriglia\Desktop\GIS\Shapefiles\test does not have OIDs Item not found in this collection. Failed to execute (Select Layer By Attribute). I tried using 'Copy Features' tool and then Select Layer by Attribute but my only input options are 'Environments' and 'Preconditions' – Chris Feb 20 '14 at 20:14
  • Would you be able to edit your Question to include these additional important details that will assist answerers to know what you have already tried without success, please? Additional information usually helps shed additional light on any problem. – PolyGeo Feb 20 '14 at 22:14
2

If you are taking a non-arcgis table and making the XY Event Layer directly from it, you can't run a select by anything because ArcGIS does not allow selections on tables without an ObjectID field. Therefore, there are a couple of solutions I can think of.

You could import the CSV or whatever your source table is to a temp/scratch workspace as a FileGDB table (or a DBF table). Then run the make xy event layer on that. Finally, use the Feature Class to Feature Class tool on the event layer and add your SQL query directly to the "Expression" field in the Feature Class to Feature Class GP Tool. This should allow you to save it out as a GDB feature class or shapefile.

Or, you could use the make xy event layer directly on your source table, then use feature class to feature class on the event layer to save it as a shapefile/feature class (Note: You can NOT use a SQL expression at this point this way since your source data won't be from a standard arcgis source with OID field). Then, once you have a feature class, you could use the Make Feature Layer GP tool on that, adding a SQL expression in the expression parameter of the tool for the features you don't want (ex: if you want all the ones where the Type field is 1, you would do an expression like Type <> 1). Then, you would run the delete features tool on the resulting feature layer and that should delete those selected records.

Hope those help; like I said initially though, the important thing to remember is if it doesn't have an ObjectID field, you won't be able to run any attribute queries against it (whether it's a table, event layer, etc...).

  • You helped me so much. I ended up going with the first option, loading the table into a FileGDB first and then running the Feature Class to Feature Class tool. Thank you! – Chris Feb 21 '14 at 15:46
  • If your question is answered and problem solved, then you may want to either mark my answer as accepted or post your own answer detailing what you did and mark it as accepted. But either way, if you mark an answer as accepted, it will remove it from the unanswered questions section of this site, so people can more quickly sort through questions still in need of help answering. PS: glad it helped. – John Feb 21 '14 at 15:51

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.