Fiona 没有将 .shp 文件视为可识别的格式

问题描述 投票:0回答:1

我的所有单元测试都在本地计算机上通过,但是当我每次创建拉取请求时尝试使用 .yml 文件来测试它们时,都会出现几次失败。下面显示了其中一条错误消息的示例:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   fiona._err.CPLE_OpenFailedError: 'static_data/england_wa_2011_clipped.shp' not recognized as a supported file format.

fiona/_err.pyx:291: CPLE_OpenFailedError

我的 Linux .yml 文件如下,我已经尝试更改工作目录,它似乎是正确的。该文件没有损坏,并且由于两个虚拟机上的文件相同,我认为这是 Fiona 的问题。该文件还有一个用于在 Windows VM 上进行测试的相应文件,但是它们会发出相同的错误消息并导致相同的测试失败。

name: Python Linux application

on:
  pull_request:
    branches: [ '**' ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Set up Python 3.8
        uses: actions/setup-python@v2
        with:
          python-version: 3.8
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          sudo apt-get install libproj-dev proj-data proj-bin
          sudo apt-get install libgeos-dev
          sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable
          sudo apt-get update
          sudo apt-get install gdal-bin libgdal-dev
          pip install GDAL==3.2.3
          pip install flake8 pytest Cython numpy pyproj pygeos
          if [ -f requirements-linux.txt ]; then pip install -r requirements-linux.txt; fi
      - name: Lint with flake8
        run: |
          # stop the build if there are Python syntax errors or undefined names
          flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
          # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
          flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
      - name: Test with pytest
        run: |
          pytest

GitHub 存储库:https://github.com/Zach10a/seedpod_ground_risk 分支是CI。

python github-actions shapefile geopandas fiona
1个回答
1
投票

您的问题是,默认情况下,

actions/checkout@v2
操作不会检出使用LFS存储的文件。因此,虽然您的存储库中存在名为
static_data/england_wa_2011_clipped.shp
的文件,但其内容将如下所示:

version https://git-lfs.github.com/spec/v1
oid sha256:c60f74e3b8ed753d771378f0b03b7c8e8a84406f413a37f9f5242ac9235a2e6c
size 114084720

所以菲奥娜给了你一个准确的错误:

E   fiona._err.CPLE_OpenFailedError: 'static_data/england_wa_2011_clipped.shp' not recognized as a supported file format.

您需要指示

checkout
操作来下载 LFS 中存储的文件:

    steps:
      - uses: actions/checkout@v2
        with:
          lfs: true
© www.soinside.com 2019 - 2024. All rights reserved.