Hi Nikhil!

I remember having a correspondence with you about imdlib last year.

I am fetching the rainfall data - but in the raster formal.

data = imd.get_data(
        var_type='rain',
        start_yr=year,
        end_yr=year,
        fn_format='yearwise',
        file_dir=DATA_FOLDER
    )

This downloads the rainfall data in .grd format. Later I convert it into
.tif
data.to_geotiff(
        '{}.tif'.format(year),
        TIFF_DATA_FOLDER
    )

Faced issues with the affine transformation of this raster. Solved it for
my need. But curious to know if there is a standard or not in defining
affine transformation. Never faced this issue with other raster images.

Best,
Dammalapati Sai Krishna
https://d-saikrishna.github.io/

On Thu, Sep 7, 2023 at 8:05 PM Nikhil VJ <[email protected]> wrote:

> Hi Dammalapati,
>
> I had used imdlib python package a year back, but the data fetched using
> it was vector data, not raster. It had latitude, longitude, date and value
> of either rainfall in mm or temperature in degrees celsius. If you're
> fetching a dataset what is different from rainfall or temperature data,
> then pls specify.
>
> Here's a few lines of code that fetches the yearly data of 1 year,
> converts it to a simpler flat table in pandas dataframe and saves to CSV
> file:
>
> imdlib.get_data('rain', 2000, 2000, 'yearwise')
> rain1 = imdlib.open_data('rain', 2000, 2000,
> 'yearwise').get_xarray().to_dataframe()
> rain1.to_csv('rain1.csv')
>
> Have shared my script here:
> https://github.com/answerquest/IMD-grid-data-work/blob/main/imd_grid_import/imd_import.py
>
> Note: there were junk data placeholders for indicating null value (ie, no
> value available for that location and year). Temperature: >99, Rainfall: <
> -100 .
>
> --
> Cheers,
> Nikhil VJ
> https://nikhilvj.co.in
>
>
> On Thu, Sep 7, 2023 at 4:28 PM Dammalapati Sai Krishna <
> [email protected]> wrote:
>
>> Hi,
>>
>> This question is for people who have worked on Python's imdlib package.
>>
>> The rasters downloaded using imdlib has the following affine
>> transformation:
>> | 0.25, 0.00, 66.38|
>> | 0.00, *0.25*, *6.38*|
>> | 0.00, 0.00, 1.00|
>>
>> If I'm not wrong, the general standard is to define the pixel height in
>> negative with top-left bounding box coordinates as X,Y. At least, the
>> images downloaded from GEE follow that format.
>>
>> But in the array above you can see (in bold blue) that the pixel height
>> is specified in the positive. And the bottom-left bounding box coordinates
>> are specified (bold red).
>>
>> The issue I faced with this is that when I try to calculate zonal
>> statistics using *rasterstats*, the positive height becomes a problem
>> (negative dimensions error). I changed the transformation matrix and
>> flipped the array to be able to run zonal stats.
>>
>> Want to know if there is a standard in defining affine transformation
>> matrix and if imdlib is not using that.
>>
>> Thanks!
>>
>> --
>> Datameet is a community of Data Science enthusiasts in India. Know more
>> about us by visiting http://datameet.org
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "datameet" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/datameet/98c9162b-e45e-4bba-9095-be37683b7e41n%40googlegroups.com
>> <https://groups.google.com/d/msgid/datameet/98c9162b-e45e-4bba-9095-be37683b7e41n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> Datameet is a community of Data Science enthusiasts in India. Know more
> about us by visiting http://datameet.org
> ---
> You received this message because you are subscribed to the Google Groups
> "datameet" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/datameet/CAH7jeuNx31Bsaa1xkuUQ0eFC3tr-8CBJ1atwJU4%3DL6hi1A%2Bpdg%40mail.gmail.com
> <https://groups.google.com/d/msgid/datameet/CAH7jeuNx31Bsaa1xkuUQ0eFC3tr-8CBJ1atwJU4%3DL6hi1A%2Bpdg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
Datameet is a community of Data Science enthusiasts in India. Know more about 
us by visiting http://datameet.org
--- 
You received this message because you are subscribed to the Google Groups 
"datameet" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/datameet/CAK0JssZiDEwgZPukhSB732eSY%2Bs5ienTU0QkzM%3DA4Lw9s7W%2B8w%40mail.gmail.com.

Reply via email to