3

I have a .gdb file with >17,000 features. Simplified example of attributes table:

ID      NAME    DATE    ETC
0001    london  2012    12
0002    london  2012    23
0003    thame   2012    45
0004    thame   2012    56
0005    kent    2012    67
0006    london  2011    78
...

I have an Excel file with a list of ~250 names:

NAME
kent
essex
sussex
london
...

I want to extract only the features with attributes that match the names in the Excel file and save them as shapefiles. Multiple features share the same attributes. How to do this using FOSS? I think there is a function in ArcGIS called FeatureClassToShapefile that does this.

I found this code to run GDAL directly from the terminal to convert the .gdb to a shapefile:

ogr2ogr -f "ESRI Shapefile" /test/extraction /test/test.gdb 

I can select a subset of layers by appending these to the above code:

ogr2ogr -f "ESRI Shapefile" /test/extraction /test/test.gdb example_layer

If I try to use the same formatting to select a subset of features I get the error:

FAILURE: Couldn't fetch requested layer 'example_feature'!

Is this possible using this method? I've looked at the GDAL documentation here but couldn't find an answer.

I'm open to other solutions, using GDAL, R pr QGIS preferably.

3
  • There are several join methods you may do with ogr, see: > OGR SQL supports a limited form of one to one JOIN. This allows > records from a secondary table to be looked up based on a shared key > between it and the primary table being queried. gdal.org/ogr_sql.html gis.stackexchange.com/questions/95746/…
    – artwork21
    Commented Feb 6, 2019 at 13:48
  • Any chance you could give an example?
    – Thomas
    Commented Feb 7, 2019 at 6:24
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review Commented Feb 8, 2019 at 15:36

1 Answer 1

0

The solution to this was quite simple - I was able to open the .gdb file in QGIS and use the 'Select by Expression' function to select the fields I wanted. The formula I used was based on this post:

SCINAME IN (
'kent', 
'essex', 
'sussex', 
'london'
)

I was then able to save the selection as a shapefile.

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.