Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyproj.exceptions.CRSError Due to Invalid EPSG:None Projection in MODIS-13Q1-061 Dataset #414

Open
simonMadec opened this issue Feb 13, 2025 · 2 comments

Comments

@simonMadec
Copy link

simonMadec commented Feb 13, 2025

I am querying products from the modis-13Q1-061 collection using platform arguments and loading them with odc-stac into xarray.

However, when I try to load the data, I encounter the following error:

File "pyproj/_crs.pyx", line 2364, in pyproj._crs._CRS.__init__
pyproj.exceptions.CRSError: Invalid projection: EPSG:None: (Internal Proj Error: proj_create: crs not found: EPSG:None)

I noticed that MODIS items in the query results do not have a proper projection assigned. The proj:code property for items is set to "EPSG:None", which causes the error

mod_items[1].properties['proj:code'] is "EPSG:None"

Here is the code I am using, which fails when loading the data:

  catalog = pystac_client.Client.open(
      "https://planetarycomputer.microsoft.com/api/stac/v1",
      modifier=planetary_computer.sign_inplace,
  )
  ## Parametre
  time_range = f'{start_date}/{end_date}'
       
  image_select = "MOD" #filtre collection 

  ##search in catalog
  search = catalog.search(
  collections=["modis-13Q1-061"], bbox=bbox, datetime=time_range)
  items = search.get_all_items()

  ## Filter search
  mod_items = list(filter(lambda x: x.id.startswith(image_select), items))
  items = pystac.ItemCollection(mod_items)

  ### dl data
  items_dict = dict()
  for i in range(len(items)):
      items_dict[i] = items[i]

  data = odc.stac.load(
      items_dict.values(),
      crs="EPSG:3857",
      bbox=bbox,
      resolution=250, ## per pixel
      bands=["250m_16_days_NDVI"],#bande to select
      nodata=-3000) 
@ghidalgo3
Copy link

ghidalgo3 commented Feb 13, 2025

Hi @simonMadec, could you please share the output of pip freeze? I was able to run your example successfully like this:

import pystac # Gustavo added added this import

# Set the date time
start_date = "2023-01-01" 
end_date = "2024-01-01"
catalog = pystac_client.Client.open(
    "https://planetarycomputer.microsoft.com/api/stac/v1",
    modifier=planetary_computer.sign_inplace,
)
## Parametre
time_range = f'{start_date}/{end_date}'
    
image_select = "MOD" #filtre collection 

##search in catalog, bbox remained the same as in the example notebook.
search = catalog.search(
collections=["modis-13Q1-061"], bbox=bbox, datetime=time_range)
items = search.get_all_items()

## Filter search
mod_items = list(filter(lambda x: x.id.startswith(image_select), items))
items = pystac.ItemCollection(mod_items)

### dl data
items_dict = dict()
for i in range(len(items)):
    items_dict[i] = items[i]

data = odc.stac.load(
    items_dict.values(),
    crs="EPSG:3857",
    bbox=bbox,
    resolution=250, ## per pixel
    bands=["250m_16_days_NDVI"],#bande to select
    nodata=-3000) 

And this is my pip freeze output:

adlfs==2024.7.0
affine==2.4.0
aiohappyeyeballs==2.4.4
aiohttp==3.11.9
aiosignal==1.3.1
annotated-types==0.7.0
appnope @ file:///home/conda/feedstock_root/build_artifacts/appnope_1733332318622/work
asciitree==0.3.3
asttokens @ file:///home/conda/feedstock_root/build_artifacts/asttokens_1733250440834/work
async-timeout==5.0.1
attrs==24.2.0
azure-core==1.32.0
azure-datalake-store==0.0.53
azure-identity==1.19.0
azure-storage-blob==12.24.0
cachetools==5.5.1
Cartopy==0.24.1
certifi==2024.8.30
cffi==1.17.1
cfgv==3.4.0
cftime==1.6.4.post1
charset-normalizer==3.4.0
click==8.1.7
click-plugins==1.1.1
cligj==0.7.2
cloudpickle==3.1.0
comm @ file:///home/conda/feedstock_root/build_artifacts/comm_1710320294760/work
contextily==1.6.2
contourpy==1.3.1
cryptography==44.0.0
cycler==0.12.1
dask==2024.12.0
debugpy @ file:///private/var/folders/k1/30mswbxs7r1g6zwn8y4fyt500000gp/T/abs_563_nwtkoc/croot/debugpy_1690905063850/work
decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1733236420667/work
distlib==0.3.9
distributed==2024.12.0
exceptiongroup @ file:///home/conda/feedstock_root/build_artifacts/exceptiongroup_1733208806608/work
executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1725214404607/work
fasteners==0.19
filelock==3.16.1
fonttools==4.55.2
frozenlist==1.5.0
fsspec==2024.10.0
geographiclib==2.0
geopy==2.4.1
h5netcdf==1.4.1
h5py==3.12.1
identify==2.6.3
idna==3.10
importlib_metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1733223117029/work
ipykernel @ file:///Users/runner/miniforge3/conda-bld/ipykernel_1719845458456/work
ipython @ file:///home/conda/feedstock_root/build_artifacts/ipython_1732896932739/work
isodate==0.7.2
jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1733300866624/work
Jinja2==3.1.4
joblib==1.4.2
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter_client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1726610684920/work
jupyter_core @ file:///home/conda/feedstock_root/build_artifacts/jupyter_core_1727163409502/work
kiwisolver==1.4.7
locket==1.0.0
markdown-it-py==3.0.0
MarkupSafe==3.0.2
matplotlib==3.9.3
matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1713250518406/work
mdurl==0.1.2
mercantile==1.2.1
msal==1.31.1
msal-extensions==1.2.0
msgpack==1.1.0
multidict==6.1.0
nest_asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1733325553580/work
netCDF4==1.7.2
nodeenv==1.9.1
numcodecs==0.13.1
numpy==2.1.3
odc-geo==0.4.9.post0
odc-stac==0.3.11
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1733203243479/work
pandas==2.2.3
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1733271261340/work
partd==1.4.2
pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1733301927746/work
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1733327343728/work
pillow==11.0.0
planetary-computer==1.0.0
platformdirs @ file:///home/conda/feedstock_root/build_artifacts/platformdirs_1733232627818/work
pooch==1.8.2
portalocker==2.10.1
pre_commit==4.0.1
prompt_toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1733302527033/work
propcache==0.2.1
psutil @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/abs_1310b568-21f4-4cb0-b0e3-2f3d31e39728k9coaga5/croots/recipe/psutil_1656431280844/work
ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1733302279685/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl#sha256=92c32ff62b5fd8cf325bec5ab90d7be3d2a8ca8c8a3813ff487a8d2002630d1f
pure_eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1721585709575/work
pycparser==2.22
pydantic==2.10.3
pydantic_core==2.27.1
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1733221634316/work
PyJWT==2.10.1
pyparsing==3.2.0
pyproj==3.7.0
pyshp==2.3.1
pystac==1.11.0
pystac-client==0.8.5
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1733215673016/work
python-dotenv==1.0.1
pytz==2024.2
PyYAML==6.0.2
pyzmq @ file:///private/var/folders/k1/30mswbxs7r1g6zwn8y4fyt500000gp/T/abs_43pxpbos3z/croot/pyzmq_1705605108344/work
rasterio==1.4.3
referencing==0.35.1
requests==2.32.3
rich==13.9.4
rioxarray==0.18.1
rpds-py==0.22.3
scipy==1.14.1
shapely==2.0.6
six @ file:///home/conda/feedstock_root/build_artifacts/six_1733380938961/work
sortedcontainers==2.4.0
stack-data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1669632077133/work
tblib==3.0.0
toolz==1.0.0
tornado @ file:///private/var/folders/k1/30mswbxs7r1g6zwn8y4fyt500000gp/T/abs_a4w03z48br/croot/tornado_1718740114858/work
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1733367359838/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1733188668063/work
tzdata==2024.2
urllib3==2.2.3
uv==0.5.6
virtualenv==20.28.0
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1733231326287/work
xarray==2024.11.0
xyzservices==2024.9.0
yarl==1.18.3
zarr==2.18.3
zict==3.0.0
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1732827521216/work

None of the MODIS items have a proj:epsg property, so I think something about your environment is the culprit.

@simonMadec
Copy link
Author

Yes, but I was using docker so ...
I will force the items to have the proj:espg on my code ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants