How to pull crs information from a world file when reading an image using python GDAL or Rasterio?
The images I am reading to not have in built metadata, it is stored in the projection file (.prj) and world files (.tfw or .jpw for tiff and jpg files, respectively). When I read these images using python GDAL or Rasterio, it ignores these metadata files and therefore does not read any coordinate metadata.
How would I go about reading these files?
Edit 1.
Code example:
Using python 2 (Anaconda distribution).
I want to read an image file and get it's bound box.
image1.prj
image1.jgw
image1.jpg
import rasterio
img = rasterio.open('image1.jpg')
bounds = img.bounds
crs = img.crs
transform = img.transform
When the code is run, the following warning appears:
C:\Anaconda2\lib\site-packages\rasterio\__init__.py:193: UserWarning: Dataset has no geotransform set. Default transform will be applied (Affine.identity())
Best Answer
The world file (.jpw) did not have valid data. Therefore I was trying to read coordinate metadata that was not there in the first place. After re-exporting the images with valid world files, I had no problem reading them using Rasterio or GDAL python bindings. I guess you could say user error strikes again.