2

I have several shapefile vector layers that I need to query so I can group records and export a subset of fields to go into an excel spreadsheet. I thought I could do this by using the graphical modeler and simply using the 'Execute SQL' algorithm on the input layer and then copying the records into excel. When I try to do this, I get an error that it cannot find the virtual layer ("virtual: Cannot find layer [generated temp file name]").

Can this be done on shapefile layers or do they need to be in a database layer? Is there a better way to do this?

1

My approach would be extracting all features I needed by "extract by attribute" and save the new file as a csv. You could build a graphical model around this, so you only would have to specify which layers/attributes you would like to extract and a location/name to save to.

Also, you would purely be operating on shapefiles.

  • Thanks, but I'm not sure that will work for me - I need all the features, so I'm not selecting by a specific attribute, but the ability to be able to group by attribute is important. – CEL-ma Dec 15 '17 at 19:10
  • Ok, seems I don't get something here. You want to group by an attribute, but on the other hand you don't? Since that group has to have something similar for each member feature, you can also select them by that similarity and export the whole group into the desired excel-file. – Erik Dec 17 '17 at 12:09
  • The tables I'm working with include data for municipal infrastructure (pipes, manholes etc) so each pipe or structure has one record in the table, but when I export I need to have similar data grouped by road segments (ie: I have 3 manholes with the same road segment ID, I want those records grouped together) – CEL-ma Dec 18 '17 at 12:23
  • Do you need all of your data in one file, only sorted first by structure and second by road segment? Or would it suffice to export a file for each type of structure or road segment? Another question is, whether you would like to continue working with SQL or if QGis would work for you too. – Erik Dec 18 '17 at 12:43
  • 1
    I'm looking for a solution that's repeatable - I'll have about half or dozen tables (similar format) for 13-14 projects. Tables are divided by infrastructure type: Sanitary (pipes, manholes), Storm (pipes, manholes) Watermain (pipes, fitting) etc... they're going into a spreadsheet that's setup with worksheets equal to each of the tables, so I need each table exported separately - the structure/pipe IDs are not important for the spreadsheets, I need it grouped by road segment IDs so that I can calculate things such as # of manholes, length of pipes, diameter etc per road segment.. – CEL-ma Dec 18 '17 at 13:15

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.