Saturday 21 December 2019

qgis - "Invalid Data Source" When trying to open many w001001.adf files


I have a folder with more than 9,000 subfolders, each with ESRI GRID files. Here's the setup of the directories and subdirectories.


Data-folder
- be_rasters
-- 692500_725000
--- dblbnd.adf
--- hdr.adf
--- metadata.xml
--- prj.adf
--- sta.adf

--- w001001.adf
--- w001001x.adf
-- (thousands more folders with this naming convention format and files within them named the same thing)

I'm trying to work in QGIS 3.8 to open the 9000+ w001001.adf files in the folders in be_rasters directory. In QGIS, I go to Layers >> Add Vector Layer, then choose "Directory" as a Source Type and "Arc/Binary Coverage" in the "Source" section. Then under "Vector Dataset(s)" I select be_rasters.


But when I click "Add," I get this error.


Invalid Data Source: path/to/Data-folder/be_rasters  is not a valid or recognized data source.

How do I load all the w001001.adf files into QGIS?



Answer




"Layers >> Add Vector Layer" only works with vector data. However, you have Arc/INFO binary GRIDs, which are rasters not vectors.


An Arc/INFO binary GRID is a directory of related files stored in a parent directory (workspace) with an INFO database directory:


enter image description here


GDAL can read Arc/INFO binary GRIDs either by using the GRID directory name or GRID/hdr.adf (or w001001.adf)


You can create a virtual mosaic by creating a list of all the GRID directories (excluding the INFO directory) and using the gdalbuildvrt command.


For absolute paths:


ls -d /path/to/Data-folder/be_rasters/* | grep -i -v info > gridlist.txt

Or to use relative paths:


cd /path/to/Data-folder/be_rasters

ls -d * |grep -i -v info > gridlist.txt

Then:


gdalbuildvrt -input_file_list gridlist.txt your_new_mosaic.vrt

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...