Hot answers tagged

13

You can display raster NoDataValue in LayerProperties / Transparency tab by unchecking the "No data value" checkbox and "adding values manually" to the "transparent pixel list" table (green plus sign). After adding a value one need to change the "Percent Transparent" column to zero. After Applying this you can see the padded values as black.


13

beside @R.K. answer, you can use r.null in grass too. r.null - Manages NULL-values of given raster map. EXAMPLES Set specific values of a classified map to NULL: r.null map=landcover.30m setnull=21,22 Set NULL-values of a map to a specific value: r.null map=fields null=99 i hope it helps you...


12

What you want to do is Set Raster Properties in a script or change it manually in ArcCatalog. This will not create a new raster or even take very long. In python it's a bit tricky: import sys, os, arcpy InFolder = sys.argv[1] arcpy.env.workspace = InFolder for Ras in arcpy.ListRasters(): arcpy.AddMessage("Processing " + Ras) arcpy....


11

In QGIS, you can use Raster Calculator with the following calculation: ("your_raster" != -32768) * "your_raster" With this calculation, if the cell value is -32768 you will get a 0 in that cell and if it is different from -32768 the cell will keep the value it had.


11

I found a solution for this. First i convert the image into a vrt layer (gdalbuildvrt) with -srcnodata 0, then i translate it back into a tif file with gdal_translate -a_nodata. Worked fine! :)


9

I think the RasterCalc plugin should be able to solve your problem. Once you've installed it, you can use the following query (assuming that NULL values corresponds to -9999; you can check this value in Transparency tab of the Layer Properties): eq( [your_raster]@1, -9999, 0 ) eq means equal to. This tells RasterCalc that all pixels in your raster with ...


9

The simplest one-step and, IMO, most consistently reliable solution to reclassifying NoData to zero is to use the Reclassify Grid Values tool (SAGA) in the processing toolbox. After selecting the raster to be reclassified, simply scroll to the bottom of the dialog, ensure the box replace no data values box is checked. The default value is zero (but you can ...


9

It is a bug. Something terribly wrong with cell count. Correct mean (9.0452380952381) times correct number of non-empty cells (420) divided by 297 (that is a cell count reported by tool) results in 12.7912457912458. That is a wrong average reported by tool. Results of my own toy size grids test:


9

There is a bug that seems to correspond to what you're experiencing - it's registered as BUG-000084883 - The 'Ignore NoData in calculations' option in Zonal Statistics as Table tool {and Zonal Statistics tool} is not honored when checked off, producing incorrect results. It occurs with 10.3 and 10.2.2 but not 10.1. Did you try the tool with this version?


8

Shapefiles, which use the older dBase specs, do not support null values. If you must maintain null values and you have to keep the file format to shapefile, you'll need to use a representative or 'nodata' value for it. This can be any value you wouldn't normally encounter or expect to encounter in the data, or that even falls within valid data's range, such ...


8

I guess you can do that with the raster calculator. If not with the help of GRASS plugin and r.null you will do it easily. That option means you will have first to create a GRASS mapset to import your raster in.


8

You are incorrect in assuming that "the no data values are assigned -Inf". (I understand that you get that idea from "@ nodatavalue : num -Inf", but that is not how it works when the driver is "gdal".) The canonical way to change cells with NA to another value is y <- reclassify(x, cbind(NA, 10000)) While it is possible to do x[is.na(x)] <- 10000 ...


7

Having the same problem, in the end I used Python directly -- you may have to adjust numpy.where for your specific purpose. In the case below, the pixel values are kept as they are if they are >= 0, all other pixels -- in this case this is only ones with the no-data value -- are set to "0" import gdal, gdalconst, numpy maskfile = gdal.Open('C:\Users\max\...


7

That method ('noDataValue') is in QgsRasterBlock class (not in QgsRasterLayer). To get access to this method you can try out this code: layer = iface.activeLayer() extent = layer.extent() provider = layer.dataProvider() rows = layer.rasterUnitsPerPixelY() cols = layer.rasterUnitsPerPixelX() block = provider.block(1, extent, rows, cols) print block....


6

There is a useful method using Con and IsNull statements in the raster calculator to convert NoData to a different value. HowTo: Convert NoData values to other values for raster data


6

Agree to the comment of @FelixIP, one possible solution is to first create a whole raster using RasterMosaicker transformer, then reproject and re-tile the Raster with RasterTiler transformer. This can be a ressource consuming approach, if you have many input tiles. Another approach is to apply nodata values with the RasterBandNodataSetter (Value = 0) or ...


5

You can use the r.null.to function via GRASS to transform all NULL value cells into a user-defined value, which in your case is 800: Note: You will have to create a GRASS Mapset before you can use r.null.to as it is not available in the Processing Toolbox. Once you created a mapset, use the GRASS option to add a raster layer, select Open GRASS Tools and ...


5

The Euclidean Allocation tool can accept your polygon as input, but you are right you need to set the values inside the polygon to NoData for this tool to work, otherwise it will pick up the values that are already there. First to feature to polygon, this will give values (any value, it doesn't matter, we're only interested in value or NoData) inside the ...


5

My favourite way to deal with this would be to use a Con(IsNull) statement... Basically, using a Con statement allows you to define a condition; if it is true, do this, if it is false, do this - including leaving the values as they were. So in this case, I would be tempted to do something like Con(IsNull(myRaster), myRaster, 1) Which basically states: ...


5

This is potentially a very difficult problem when the borders are ragged. A brute-force search of the optimum could require computational time that is proportional to the square of the number of cells in the image (a value that often will be in the billions, trillions, or greater). One promising approach is to relax the conditions a little bit and actually ...


5

As you have reclassified this raster I'll assume that you have access to the Spatial Analyst extension, so will continue with instructions that require this extension. The tool you want to use is Con, although you can do it with Extract by Attributes Con gives you more control over the 'false' case. Your SQL statement has the potential to be quite long ...


5

When using the Raster Calculator in ArcToolbox (version 10.3.1) the Con function is expressed as follows for a raster that is named "streams": Con(IsNull("streams"), 0, "streams") this returns zero if streams is null else it returns the value of streams. In this example all NoData pixels in the Streams are set to zero, otherwise they contain the pixel ...


5

The method 'setNoDataValue' is in QgsRasterDataProvider. You can use next code to try it out. It worked for me. layer = iface.activeLayer() provider = layer.dataProvider() provider.setNoDataValue(1, 0) #first one is referred to band number layer.triggerRepaint()


4

This is the default NoData value for QGIS. It is the smallest possible value for a signed 32-bit float data type (I think you meant to type a minus in front of the value you quoted). You need not worry about a NoData value appearing especially if non of your data is NoData. QGIS won't suddenly allocate some data cells as NoData. It is just part of the ...


4

One solution may be this batch script: set nodatavalue=-99999 gdalwarp -srcnodata None rasterB_with_NoData.tif rasterB_without_NoData.tif python gdal_calc.py -A rasterB_without_NoData.tif --outfile=rasterB_updated_with_NoData.tif --calc="(A<>%nodatavalue%)*A" gdalwarp -srcnodata None rasterB_updated_with_NoData.tif rasterB_updated_without_NoData.tif ...


4

Sorry, by definition, rasters are square in extent. The best you can do is convert the NoData cells to a value using a Raster Calculator with the map algebra expression: Con(IsNull("myraster"), 0, "myraster") ArcGIS Help 10.2: NoData in Raster Datasets


4

So you want to convert all values to the same constant value and NoData should remain NoData. Instead of Reclassify, use the Con tool with your input raster as 'Input conditional raster', and the constant value as 'Input true raster or constant value'. E.g.: import arcpy cst = 5 # your constant value outCon = Con(r"C:\data\intput.tif", ...


4

In this test raster (20x20), with values between 1 and 50, I replaced 19 value by -32768 value. In the following raster, the -32768 values were replaced by -3.40282e+38 values (see window of Value Tool Plugin): The used expression is in the window of "Raster calculator expression" (below image and code sample): ("null_values@1"=-32768)*(-3.40282e+38)+("...


4

Assuming that you allready read your raster data into a numpy array called raster_stack and stacked all rasters along the z-axis. import numpy as np no_data = -32768 np.sum(raster_stack == no_data, axis=0) This will result in a 2-dimensional array containing the count of no_data values for each x,y location. It will also be as fast as you can get with ...


4

An alternative approach (without altering your input data with gdal_edit) could be using GDAL VRT files as intermediate operands in gdal_calc and -a_nodata none in gdal_translate to skip the NoData values. For instance, if the original NoData value = 0: gdal_translate -of VRT raster1.tif raster1.vrt -a_nodata none gdal_translate -of VRT raster2.tif raster2....


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