As documented in https://pypi.org/project/GDAL/ plain "gdal" is deprecated and you should not use that for writing any new code
Additionally, there are five compatibility modules that are included
but provide notices to state that they are deprecated and will be
going away. If you are using GDAL 1.7 bindings, you should update your
imports to ...
Assuming your three rasters have the same dimensions, you can use numpy's boolean indexing to accomplish this. First, you need to create three masks, each one corresponding to one of your conditions:
con1 = (dcl_array == 1) # raster a is 1
con2 = (dcl_array == 0) # raster a is 0
con3 = (tcd_array == 0) # raster c is 0
Then, you just have to index the ...
There is no such create option in GDAL tools but a proper solution would require writing a few lines of Python code. Best workaround that comes into my mind is to select data from any existing data source with point geometries by using SQL that finds nothing.
ogr2ogr -of "ESRI Shapefile" -sql "select geometry from test where 1=2" emptytest.shp test.shp
I would recommend a combination of geopandas and geocube.
Here is some untested set of code that should get you pretty close to what you want to do.
Step 1: Combine the shapefiles
gpd1 = geopandas.read_file("Shapefiles/shp1.shp")
gpd2 = geopandas.read_file("Shapefiles/shp2.shp")
gpd3 = geopandas.read_file("Shapefiles/shp3....
You can create an osr.SpatialReference() object and then use it to set the raster projection using gdal. If you have gdal installed you'll have osr already. Here is an example:
from osgeo import gdal
from osgeo import osr
# create spatial reference object using your EPSG
sr = osr.SpatialReference()
# open your raster and set ...
It's my first time writing here, but hope I might give you some insight. I used the code from your post, with some minor changes it worked… kind of. I checked the correlation matrices that I get by comparing some of my classification data with data rasterized in the QGIS tool and raster generated by this code. Raster generated by your code had kappa ...