Тёмный

Calculating Zonal Statistics of a Raster using Python 

GeoDelta Labs
Подписаться 132 тыс.
Просмотров 14 тыс.
50% 1

This tutorial explains the basics of calculating the zonal statistics such as average, max, min values corresponding to a defined spatial area of a raster using a polygon vector layer using Python, with the aid of GeoPandas, rasterio and rasterstats libraries. Additionally, you will learn how to plot rasters and vectors on the same layer, how to use matplotlib subplots to plot maps and histograms together in the same canvas, as well as to extract the summary of the data into a Pandas DataFrame using the Pandas library.
Download exercise data - drive.google.c...
⭐NOTE:
‘Kite’ is an excellent tool that can help you boost your productivity when it comes to programming with its free Artificial Intelligence (AI) powered coding assistant. Kite is a plugin which provides smart completions and documentation as you’re typing-in your code, and its compatible with most of the well-known IDEs such as PyCharm, Spyder and VS Code. I absolutely love it, and recommend you guys to try it out as well.
www.kite.com/g...

Опубликовано:

 

19 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 57   
@olssonfilip
@olssonfilip 4 года назад
Just wanted to thank you for these vids, wish I had them during my time at Uni but now as a GIS professional I’m feeling even more inspired by your work! Looking forward to the next one : )
@geodeltalabs
@geodeltalabs 4 года назад
Glad you like them!
@kaustavdas5600
@kaustavdas5600 Год назад
@geodeltalabs: In the same code, if I want to extract the 95th percentile value, what modification in the code do I need to do ?
@muhammadanjum524
@muhammadanjum524 4 года назад
Dear Sir , Thank you soooooooooooooo much . You are sooo nice and kind . You are sooo expert in GIS . I hope you will continue your help .Its really very very helpful for me . I actually want to do that one . Sir, you solved my problem . Once again THANK YOU soo much .
@moisengwa9904
@moisengwa9904 4 года назад
Very Good job GeoDelta Labs. I don't have enough words to thank you. Please please kindly post the part 2 tutorial Calculating Zonal Statistics of a Raster using Python. Looking forward to that:
@jeffz7310
@jeffz7310 Год назад
I didn't need to go to Uni because of these videos, thx
@abramswee
@abramswee 8 месяцев назад
Thank you very much for sharing this with us! much appreciated.
@mulugetaworkuayele6412
@mulugetaworkuayele6412 Год назад
I am too late to learn from this interesting and very useful tutorial. Thank you so much!
@geodeltalabs
@geodeltalabs Год назад
Better late than never :)
@shaileshshrestha9725
@shaileshshrestha9725 4 года назад
good job bro...more geopandas pls.. one thing you have a good voice
@amitblizer4567
@amitblizer4567 Год назад
Thank you. This was very helpful for me in my thesis🙏
@yaarobmohammad1020
@yaarobmohammad1020 4 года назад
You are the best
@gmjakirullahnooruddin1734
@gmjakirullahnooruddin1734 4 года назад
Dear @GeoDelta Labs, Thanks for this great tutorial. Very much appreciable. Waiting for part two with multiple raster data. I have a couple questions. Do I have to project both my vector and raster dataset? If so how could I project multiple raster datasets at once? and the second question is while plotting/showing the raster data how could I show also raster scale right-side on my raster plot? Thanks in advance.
@DileepGuptagoodman
@DileepGuptagoodman 3 года назад
Very nice video . I like sir . 👍👍👍
@geodeltalabs
@geodeltalabs 3 года назад
Thanks!
@hugonicolaubarbosadegusmao7824
@hugonicolaubarbosadegusmao7824 4 года назад
The tutorial was very good, I learned a lot! A question, where did you download this data? I wanted to download to Brazil.
@rafaeltiara9092
@rafaeltiara9092 4 года назад
Great tutorial. Thank you!
@yaarobmohammad1020
@yaarobmohammad1020 4 года назад
Can you please make more videos How to extract and compute volumes from raster How to make hydrogeological analysis And so on
@geodeltalabs
@geodeltalabs 4 года назад
Hi, do you mean to just to do a one time computation of the volume from a raster? If you do not have a specific reason to use scripting to do that, I believe you can do this kind of processes quite easily using qgis
@yaarobmohammad1020
@yaarobmohammad1020 4 года назад
GeoDelta Labs I think that coding always better than do it with software ; because u can use you’re code always with different situations and faster Thank you so much
@manuvideos3979
@manuvideos3979 Год назад
Hello, Thanks for this great tutorial. I have a question, while calculating the average, are taking in account the nodata pixels? If yes, is there a way to exclude nodata pixels while calculating average? Thanks in advance for your answer.
@kaustavdas5600
@kaustavdas5600 Год назад
Thanks a lot for this! ...just one question, if I want to extract the 95th percentile at any of the districts, wherever the raster is present. What modification in the code do I need to do. Anyone's help is really appreciated
@aakashbhatt3303
@aakashbhatt3303 2 года назад
Hi @Geo Data Labs, Great Tutorial thanks for this And please can you make tutorials on the liabrary raterio
@umairrasool9580
@umairrasool9580 3 года назад
Very great and clear work you have done. i have a question please, i am working on my raster dataset for prediction like ANN, RF and CNN, i have converted the rasters into numeric and then train and test the data and got very good accuracy. Now i need to convert my test data into raster again as final prediction map but i don't know how to do this, please guide me thanks.
@sonalisharma3421
@sonalisharma3421 2 года назад
Hello Sir, can you please tell me how to perform zonal statistics on each band of raster stack. Thank you very much for making such useful videos.
@raquelzafrir2752
@raquelzafrir2752 4 года назад
Hi GeoDelta thanks for the video. I have a question. Did you check the values where your raster has no data or zero values? I am getting negative values and I do not know how to correct them. Thanks!
@DileepGuptagoodman
@DileepGuptagoodman 3 года назад
Please make the video for mapping of CSV data in geotiff. CSV have lat lon and values
@mohammadbelalalzoubi8102
@mohammadbelalalzoubi8102 3 года назад
Thank you. It was a great video.
@geodeltalabs
@geodeltalabs 3 года назад
You are welcome :)
@sonukumar-cy1fo
@sonukumar-cy1fo 3 года назад
Sir, I got this error :MemoryError: Unable to allocate 21.4 TiB for an array with shape (2028294, 1449644) and data type float64. please help me
@australoitaliano
@australoitaliano 4 года назад
@GeoDelta Labs, thank you very much for this fantastic tutorial. Just one question: how can I save the "mean" dataset in the shapefile? After I have performed the zonal statistic, I have open the shapefile with QGis but the "mean" column was not present in the attribute table. Thanks
@muhammadanjum524
@muhammadanjum524 4 года назад
Dear Sir, I am also trying to use QGIs and also python , but I could not my results . Can we discuss Please ?
@JesusRomero-zw8yw
@JesusRomero-zw8yw 2 года назад
Thanks for the explanation, but if I want to extract the areal average of each day (that is, the average area of ​​a polygon) from a netcdf file, for example precipitation or temperature, maybe some idea
@geodeltalabs
@geodeltalabs 2 года назад
Hi, for this I suggest you follow the tutorials that I have done on handling netcdf files using python. You might be able to modify the code in such a way that you would be able to extract the values into a separate set based on their geographical position, and perform the statistical operations on those extracted values.
@jitutiwari7813
@jitutiwari7813 3 года назад
Hi, first of all Thank you for this Tutorial. I am a GIS and remote Sensing student and also want to Learn python for geospatial task can you please suggest me how could i learn python. or which books or tutorial can help me. waiting for your response. and please can you tell me how to calculate zonal on bigTiff.
@geodeltalabs
@geodeltalabs 3 года назад
You are welcome :)
@rajuahmmad9923
@rajuahmmad9923 4 года назад
I have converted APHRODITE precipitation data from netcdf to tif file. After that, i followed your tutorial and calculated mean value for each subbasin within my watershed shapefile, But i got NaN value in three of my subbasin. Could you please point out what might be the possible cause of this problem. Thanks in advance.
@slimieboy6264
@slimieboy6264 7 месяцев назад
having the same issue with a tif converted from a netcdf. idk what is wrong tbh
@reshmaa8818
@reshmaa8818 2 года назад
How to install rasterio and rasterstats?? Can you provide your video link below
@muhammadanjum524
@muhammadanjum524 4 года назад
Dear Sir, this is really really an excellent video for zonal statistics . But I followed your method but could not get results . I need to discuss . Sir, Please help me .This is my very very humble request . Please . I need to discuss with you . Please let me know how and where can i discuss with you ? Please my most humble request . Please reply positively as soon as possible . Please
@geodeltalabs
@geodeltalabs 4 года назад
Hi, kindly send your query to our email. Thank you.
@muhammadanjum524
@muhammadanjum524 4 года назад
@@geodeltalabs Sir, I have raster , I did calculate average monthly values by using QGIS raster calculator and now I want to calculate Zonal statistics . How can i send you my raster and shape file . Please help me . Sir, its my humble request that how can i send you ? Please
@andresfiallos7112
@andresfiallos7112 4 года назад
Hello GeoDeltaLabs, thanks a lot for this great video. I have a question and was hoping someone here can help me. When I run this line "avg_rf = rasterstats.zonal_stats(districts, rainfall_array, affine = affine, stats = ['mean'], geojson_out = True)" I get the following error: "MemoryError: Unable to allocate 3.95 TiB for an array with shape (620193, 874319) and data type float64" I have been trying to resolve this issue but I havent been able to do so. I would really appreciate the help!
@daanidev
@daanidev 4 года назад
Hi, Can you please tell me how you prepare tif files? i have tif files and shape file but i am unable to map correctly just as you did in this video. Can you help me with it? Thanks
@geodeltalabs
@geodeltalabs 4 года назад
Hi, did you check whether both the raster and the vector files are having the same coordinate reference?
@daanidev
@daanidev 3 года назад
@@geodeltalabs Hi my shape file and raster file has same crs can you please help me to show shape file over raster in python ?
@daanidev
@daanidev 3 года назад
@@geodeltalabs thanks issue solved (Y)
@malaymondal9953
@malaymondal9953 4 года назад
From which site we can get raster weather data, like wind speed, rainfall, temp etc.
@geodeltalabs
@geodeltalabs 4 года назад
You can try Aphrodite's portal for rainfall and temp in netCDF format. Windspeed, not so sure.
@shakhawathossainshohel5159
@shakhawathossainshohel5159 4 года назад
Thanks a lot for the video, it was great. But I need to learn zonal statistics for multiple netcdf file like daily TRMM. Would you please help me?
@geodeltalabs
@geodeltalabs 4 года назад
Better try to convert to raster first.
@eddisonjose
@eddisonjose 4 года назад
Hola muchas gracias, eso se puede hacer en pycharm? Soy neófito en programación, pero que opinas del programa pycharm? Saludos
@geodeltalabs
@geodeltalabs 4 года назад
Hello Eddison, pycharm is a good IDE too, however I have always worked with Spyder IDE, as the interface is simple, but sufficient enough to get the job done. You can indeed use pycharm to do all what we are doing here
@eddisonjose
@eddisonjose 4 года назад
@@geodeltalabs hola muchas gracias por su respuesta y amabilidad
@eddisonjose
@eddisonjose 4 года назад
GeoDelta Labs Hola una pregunta mas: Que opinas de hacer estos procesos en jupyter notebook? es factible? se pueden hacer allí?🙂
@wonga_masiza
@wonga_masiza 3 года назад
I wish I could do all this in R. ..I can't install some of these packages as I am not administrator. I have to log calls to our service desk every time I need to install a package. When I try installing them on my laptop I get errors that I must provide a path to GDAL.. Last time I had to use anything related to GDAL it gave me hell. Its easier to install all these packages in R... my goodness, I have to migrate to python once. I am going to die
Далее
10 Geoprocessing Applications of GeoPandas Library
51:33
Zonal Operations
11:32
Просмотров 2,8 тыс.
All Rust string types explained
22:13
Просмотров 171 тыс.
FASTEST Way to Learn Modern GIS and ACTUALLY Get a Job
15:12