I want to interpolate the point data using IDW with GDAL osgeo.gdal.Grid.
IDW_gdal = gdal.Grid(Output, input, zfield="rs",
algorithm = "invdist",
outputBounds = [ulx,
uly,
lrx,
lry],
width = width, height = height)
It works when I am passing the shapefile in 2nd argument but it does not work when I pass the geopandas GeoDataFrame and it throws the error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-23-a7776d5dffb0> in <module>
18 lower_right_x_coordinate,
19 lower_right_y_coordinate],
---> 20 width = raster_width, height = raster_height)
C:\ProgramData\Anaconda3\lib\site-packages\osgeo\gdal.py in Grid(destName, srcDS, **kwargs)
986 srcDS = OpenEx(srcDS, OF_VECTOR)
987
--> 988 return GridInternal(destName, srcDS, opts, callback, callback_data)
989
990 def RasterizeOptions(options = [], format = None,
C:\ProgramData\Anaconda3\lib\site-packages\osgeo\gdal.py in GridInternal(*args)
3295 def GridInternal(*args):
3296 """GridInternal(char const * dest, Dataset dataset, GDALGridOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
-> 3297 return _gdal.GridInternal(*args)
3298 class GDALRasterizeOptions(_object):
3299 """Proxy of C++ GDALRasterizeOptions class."""
TypeError: in method 'GridInternal', argument 2 of type 'GDALDatasetShadow *'
Alternately, I have passed the GeoDataFrame into ogr as GeoJson as given here
df_to_pass_in_ogr = ogr.Open(df_new.to_json())
print(df_to_pass_in_ogr)
output is
<osgeo.ogr.DataSource; proxy of <Swig Object of type 'OGRDataSourceShadow *' at 0x0000000BCDA48A80> >
but it did not work too and throws the same error.
Is there any way to use geopandas GeoDataFrame in the 2nd argument where you have passed the point feature shapefile like input_shape_file_name here?