Geotiff max/min coordinates question


j.carnes2553@...
 

Alan thanks for your reply, that did the job!! Really appreciate your help


Amine Aboufirass <amine.aboufirass@...>
 

Couldn't you use the .bounds method on your dataset reader object?


On Fri, Aug 9, 2019 at 11:26 PM <j.carnes2553@...> wrote:
Hi everyone,

I am very new to rasterio and gis in general. I really like the rasterio library so far but had a question on how it works similar to a gdal function. I am trying to get the max/min values for a geotiff file in lat/long format so that I can add the png of the geotif files to a map in python.

I found a way to do it in gdal but would rather use rasterio. I checked out the rasterio documentation and thought that maybe I should look into using the transform function but noticed the outputs weren't in lat/long. Any info on how to get the max/mins in lat/long format from a geotiff file using rasterio would be greatly appreciated. 

Thanks in advance for the help!


Alan Snow
 

I am not entirely sure what you are referring to, but I am assuming you want the bounds of the raster in lat/lon?
If so, then `EPSG:4326` is a pretty standard projection for lat/lon coordinates.
So, you would need to transform your bounds to lat/lon or EPSG:4326.

If this is the case, then this should work:

```python
import rasterio
from rasterio.warp import transform_bounds

with rasterio.open("file.tif") as rds:
    wgs84_bounds = transform_bounds(rds.crs, "epsg:4326", *rds.bounds)
```

If not, are you able to share a snipped of the GDAL python code you used?


j.carnes2553@...
 

Hi everyone,

I am very new to rasterio and gis in general. I really like the rasterio library so far but had a question on how it works similar to a gdal function. I am trying to get the max/min values for a geotiff file in lat/long format so that I can add the png of the geotif files to a map in python.

I found a way to do it in gdal but would rather use rasterio. I checked out the rasterio documentation and thought that maybe I should look into using the transform function but noticed the outputs weren't in lat/long. Any info on how to get the max/mins in lat/long format from a geotiff file using rasterio would be greatly appreciated. 

Thanks in advance for the help!