Topics

DataReader.crs is empty with new environment?


Denise Draper
 

Hi ---

I just got a new (Windows 10) laptop, and recreated my software environment from my old laptop.  Code that had previously worked didn't.  In particular, on opening a file, I find the crs field is empty:

import rasterio
foo = rasterio.open('path_to_file.tif')
foo.crs  # returns nothing

I assume it is some sort of version difference at fault.   However, I have tried upgrading on an old machine and downgrading on the new one, and neither helped.   So far I've only looked at the rasterio version and the gdal version.  What else should I be looking at?    I use miniconda to create the software environment if that matters.

Here's a summary of version combinations that I tried

Old Windows 10 machine
rasterio version 1.0.22   gdal version 2040100 ==> crs is CRS.from_epsg(32629)

Cloud Linux VM
rasterio version 1.0.28  gdal version 3000100 ==> crs is CRS.from_epsg(32629)
rasterio version 1.1.00  gdal version 3000100 ==> crs is CRS.from_epsg(32629)

New Windows 10 machine
rasterio version 1.1.00  gdal version 3000100 ==> crs is NULL
rasterio version 1.0.28  gdal version 3000100 ==> crs is NULL

Also: I've independently verified (with gdalinfo) that the data file does have a proper CRS, which is the same from all machines.


Yann-Sebastien Tremblay-Johnston
 

Is your GDAL_DATA  and/or PROJ_LIB environment variables are set in your new windows 10 environment? Typically these are set for you when you create a new conda environment and install GDAL. Is it possible that they are set but are somehow not readable? Have you tried opening another image and reading the crs? does it happen only with this one specific image?


Denise Draper
 

Yup, that is it: the environment variables are not set.  I may have set them manually before.
I'll have to investigate how conda is supposed to handle this (since the variables should only be set when you are in the right environment), but in the meantime it seems to work to set them manually.

-- 
  Denise Draper
  draperd@...