Тёмный

Python GIS - Clip Raster to a Polygon Extent using gdal.Warp 

Geospatial School
Подписаться 26 тыс.
Просмотров 12 тыс.
50% 1

Use Python to clip a raster layer with a vector layer using GDAL. The gdal.Warp function is often used to project a raster from one projection to another. It can also be used to clip a raster with a polygon shapefile. The simple clipping process is described in this video.
Visit opensourceoptions.com for more content and courses

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

 

8 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 20   
@badalmohanty6919
@badalmohanty6919 3 года назад
I think the problem is because you have not set result to None after the cut operation.
@daveronrs8948
@daveronrs8948 3 года назад
That'll be it
@clouDndsky
@clouDndsky 3 года назад
@@daveronrs8948 great tutorial :D import numpy as np and then gdal.Warp(raster_out, raster_in, cutlineDSName=shape_in, cropToCutline = True, dstNodata = np.nan)
@pervaiziqbaljames3654
@pervaiziqbaljames3654 4 года назад
how can we apply this on multiple files for example if i have 10 images i want to clip. instead of clipping single can we clip them in a short way
@geospatialschool
@geospatialschool 4 года назад
This video will give an example of how you can do this: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-InSSEPZo3Jw.html Basically, you just loop through all the files in a directory or list and perform the desired operation on each one.
@EV4UTube
@EV4UTube 4 года назад
Would be cool if you provided (links to) the file assets you used in this video so that we might practice ourselves.
@aswinkrishna204
@aswinkrishna204 2 года назад
Hi, I have a doubt if I have a shapefile that is not a boundary as in your case, my shape file is a rectangle and that part I want to clip from my Landsat then which parameter we should use as in gdal.Wrap you have used cutlineDSName=shpin, can you please help me.
@kassandrac5230
@kassandrac5230 4 года назад
This this separate from arcpy?.. I I know veryy little and I need to crop a raster to shape file and we have been using arcpy throughout the course
@geospatialschool
@geospatialschool 4 года назад
This is not arcpy. You may still be able to use gdal with arcpy but I'm not sure.
@surajshah4317
@surajshah4317 4 года назад
i can give your answer for arcpy
@max477
@max477 2 года назад
how to input multiple cutline subzone in geojson format
@isabelbrandao6096
@isabelbrandao6096 3 года назад
Hi, great tutorial! How about if we want to clip the inside of geometries, in this case, the inside of the clips will be removed.
@geospatialschool
@geospatialschool 3 года назад
You'll need to create a vector layer that represents the areas you want to keep. You could do that by creating a rectangular layer the same size as the raster, then erasing the shape from the rectangle.
@isabelbrandao6096
@isabelbrandao6096 3 года назад
@@geospatialschool indeed, I did something similar. I inverted my polygon in qgis
@Arnauf6
@Arnauf6 4 года назад
Hi, thanks for all this videos! I'm having a lot of trouble trying to not saving the clip as a new .tif file but as a new dataset in memo. Do you know if this is possible. Thank you very much!
@geospatialschool
@geospatialschool 4 года назад
I think you can do that. You just need to specify that the output file is a memory location. I don't know how to do it off the top of my head. Maybe check the gdal docs or see if you can find a stack overflow post.
@user-rw5oj5jb9r
@user-rw5oj5jb9r 4 года назад
blog.csdn.net/modabao/article/details/107023534 focus on the `MEM` parts, and the empty strings.
@byander
@byander 2 года назад
How I could use a layer from geopackage instead shapefile?
@byander
@byander 2 года назад
I found. If someone has the same doubt, the code is like this: res = gdal.Warp(out_raster, in_raster, cutlineDSName=geofile, cutlineLayer=polygon_layer_name, cropToCutline=True)
@geospatialschool
@geospatialschool 2 года назад
You should be able to use a geopackage in place of a shapefile, you'll just need to to specify the file name and layer name.
Далее
Python GIS - Automate Raster Batch Processing
14:21
Просмотров 4,5 тыс.
Bike Challenge
00:20
Просмотров 23 млн
Read and write vector files with GDAL/OGR in Python
16:50
Introducing: the AI Georeferencer for QGIS
5:58
How do we add LIDAR to a ROS robot?
22:45
Просмотров 143 тыс.
Tutorial Flooding Analysis revised
13:48
Просмотров 10 тыс.
How Ray Tracing Works - Computerphile
20:23
Просмотров 88 тыс.