0

I am trying to extract data from .h5 files (SMAP L4 NEE) for buffer around study sites (points in a .geojson files) and save the data as .tiff files. I have h5py, geopandas, and rasterio installed in a conda environment "geo-env".

Each package functions fine on its own and geopandas and rasterio work together fine. However, if I import both h5py, I cannot import geopandas and/or rasterio.

For geopandas:

import h5py
import geopandas

I get this traceback:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_28052/3630653928.py in <module>
      1 import os
      2 import h5py
----> 3 import geopandas
      4 import shutil
      5 import zipfile

~\.conda\envs\geo-env\lib\site-packages\geopandas\__init__.py in <module>
      5 from geopandas.array import points_from_xy  # noqa
      6 
----> 7 from geopandas.io.file import _read_file as read_file  # noqa
      8 from geopandas.io.arrow import _read_parquet as read_parquet  # noqa
      9 from geopandas.io.arrow import _read_feather as read_feather  # noqa

~\.conda\envs\geo-env\lib\site-packages\geopandas\io\file.py in <module>
     18 
     19 try:
---> 20     from fiona import Env as fiona_env
     21 except ImportError:
     22     try:

~\.conda\envs\geo-env\lib\site-packages\fiona\__init__.py in <module>
     83 
     84 import fiona._loading
---> 85 with fiona._loading.add_gdal_dll_directories():
     86     from fiona.collection import BytesCollection, Collection
     87     from fiona.drvsupport import supported_drivers

AttributeError: partially initialized module 'fiona' has no attribute '_loading' (most likely due to a circular import)

For rasterio:

import h5py
import rasterio

I get this traceback:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_28052/2444724308.py in <module>
      1 import os
      2 import h5py
----> 3 import rasterio
      4 import shutil
      5 import zipfile

~\.conda\envs\geo-env\lib\site-packages\rasterio\__init__.py in <module>
      7 from pathlib import Path
      8 
----> 9 from rasterio._base import gdal_version
     10 from rasterio.drivers import driver_from_extension, is_blacklisted
     11 from rasterio.dtypes import (

ImportError: DLL load failed while importing _base: The specified procedure could not be found.

It looks to be related to fiona and/or gdal, but not sure what to do to fix it. I installed geopandas and rasterio first - h5py was done later.

Is there a way to get these packages to play nicely together?

June Skeeter
  • 1,142
  • 2
  • 13
  • 27

0 Answers0