Hot answers tagged

4

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 ...


3

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 ...


2

In addition to expressions you can use numpy functions in gdal_calc. Sounds like you might be looking for np.where(). Something like: --calc="where((A-B)>0), A, B)"


1

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 ...


1

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 import pandas import geopandas gpd1 = geopandas.read_file("Shapefiles/shp1.shp") gpd2 = geopandas.read_file("Shapefiles/shp2.shp") gpd3 = geopandas.read_file("Shapefiles/shp3....


1

You need to have GDAL installed. Use before_script call to install GDAL: default: before_script: - apt update && apt install libgdal-dev


1

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() sr.ImportFromEPSG(32631) # open your raster and set ...


1

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 ...


Only top voted, non community-wiki answers of a minimum length are eligible