Re: No geoKeys generated when writing a geotiff


Sean Gillies
 

Hi,

On Tue, Jul 6, 2021 at 10:23 AM devsantiago <santiago@...> wrote:

Hello,
I'm sorry if this is question is an easy one, I'm a beginner with rasterio. I have a python script that reads in a dataset, calculates an overlay layer and then outputs the calculated layer. This part works as expected. I then need to take this output geotiff and read it in for display inside a web application. Inside my web application, I need to extract data such as the geotiff's coordinate system , resolution and origin. Currently, I have some other geotiffs that were not generated using rasterio  and I'm able to fetch the needed information by extracting the geoKeys with npm's geotiff package : https://www.npmjs.com/package/geotiff. However, when reading my geotifffs generated with rasterio, no geoKeys are found. Below you can find my code used to open the existing dataset and the open and create options I'm using. I'm wondering if there is something that I'm missing to be able to correctly generate these geoKeys. Any help will be greatly appreciated!

 

def layers(directory, gis_data, maptype, mapname):
    h = gis_data.height
    w = gis_data.width
    c = gis_data.crs
    t = gis_data.transform
    output_folder = directory + 'output'
    
    if not os.path.exists(output_folder):
        os.makedirs(output_folder)
    
    mapname = rio.open(
        output_folder + '/' + mapname + '.tiff',
        'w',
        driver = 'GTiff',
        height = h,
        width = w,
        count = 1,
        dtype = np.uint8,
        crs = c,
        transform = t,
profile='GeoTIFF',
geotiff_keys_flavour='STANDARD',
georef_sources='INTERNAL', ) mapname.write(maptype, 1) mapname.close()

Can you try with 

    geotiff_keys_flavor='STANDARD'

and see what happens? According to https://gdal.org/drivers/raster/gtiff.html#creation-options there is no "u" in the option name.

--
Sean Gillies

Join main@rasterio.groups.io to automatically receive all group messages.