Skip to main content
8 votes
Accepted

Polygonizing a raster yields lots of little squares?

The reason for this is that while you see yellow pixels, or pink pixels, QGIS sees thousands of discrete colours Zoom in really close to scanned map you'll see lots of noise - neighbouring pixels ...
Steven Kay's user avatar
  • 20.6k
7 votes
Accepted

Convert geojson to png

If you chose GeoTools it is a fairly simple process, fetch your geojson from somewhere: URL states = new URL("http://geojson.xyz/naturalearth-3.3.0/ne_110m_admin_1_states_provinces.geojson"); ...
Ian Turton's user avatar
  • 83.2k
7 votes
Accepted

Is it possible to open a raster or raster dataset contained in a file geodatabase with QGIS 3.X?

So I found the answer myself. I opened up the file geodatabase with ArcGIS and saw that it indeed contained raster datasets. So the answer is: Even the new QGIS completely ignores raster datasets when ...
The Dude's user avatar
  • 197
7 votes

Convert sf data frame to raster in R

class(enn2mean) [1] "sf" "data.frame" Your file enn2mean is an sf, and writeRaster works with raster files only. You need to rasterize it, and then export it. This is one ...
HMSP's user avatar
  • 1,667
6 votes

Conversion of OSM building to elevation raster

For flat roofs: You could manually create a height attribute in the shapefile if you're just doing this for one building. Otherwise, you need to import the OSM and then export the Topology and select ...
Julian Rosser's user avatar
6 votes

Excluding extent when polygonizing raster file using Python?

This can be achieved by applying a mask as the second argument in the Polygonize function, as stated in the GDAL documentation. The mask needs to be a separate raster layer, that has 0 where you don't ...
15Step's user avatar
  • 2,480
6 votes
Accepted

How to polygonize raster with range of values?

What you want to do is the re-classify the raster before polygonizing. You can GRASS tool r.recode for that (available in QGIS). For a solution with raster calculator, see below. Using GRASS r.recode ...
Babel's user avatar
  • 74.9k
5 votes

Converting a raster to shapefile for only one value?

If you have SAGA installed under QGIS, you can use Victorising grid classes tool located in Processing Toolbox -> SAGA -> Shapes - Grid -> Victorising grid classes. As you can see in the ...
ahmadhanb's user avatar
  • 41.4k
5 votes

Converting SpatialGridDataFrame into polygon shapefile in R?

Note that package sp now allows conversion of SpatialGridDataFrame into SpatialPolygonsDataFrame, you just need to use: as(., "SpatialPolygonsDataFrame") and this will contain all the attributes of ...
Matifou's user avatar
  • 2,048
5 votes

Flattening multi-band raster to single-band raster in ArcMap?

Suggestion from Stephen Lead is sufficient for grayscaled rasters but not for coloured rasters (e.g. DOF). If you want to preserve the colours (conversion is quite good) then use Copy Raster tool and ...
Damijan's user avatar
  • 51
5 votes
Accepted

Excluding extent when polygonizing raster file using Python?

Normally you don't need a mask for that task, but RGB values of the polygon areas equals 0. So you need to change them into a value (for example 125) and to change others into 0. Since all bands have ...
Kadir Şahbaz's user avatar
5 votes
Accepted

How to write PNG file from a raster using rasterio?

You're trying to write three bands into the first (and only) band of a single band output raster and you need to reshape your rgb array from (rows, cols, bands) to (bands, rows, cols). You probably ...
user2856's user avatar
  • 69.6k
4 votes
Accepted

Importing XYZ ASCII Grid Data Into QGIS: Why does GDAL resize the raster?

This seems to be a bug in QGIS, utilizing some odd behaviour of the gdalwarp utility. If gdalwarp does not like the input raster (in this case due to the y axis positive down), it creates a new raster ...
AndreJ's user avatar
  • 77.1k
4 votes

Combine overlapping rasters and include cells with no data

The above mentioned approach to use Con(IsNull("raster"), 0, "raster") to transform NoData values to zero is indeed very smart. Using this approach, make sure that the extent for every processed ...
Joram Schito's user avatar
4 votes

Convert geojson to png

I read points from a shapefile and burn in a png, also with a color classification. The recipe is in python, you need in java but the structure is the same, only must to learn the image java api: ...
user2232395's user avatar
4 votes
Accepted

Gdal.BuildVRT not creating any output

I encountered the same problem. When the vrt is returned as a dataset, you can use this dataset to invoke FlushCache() which made the problem for me disappear. I can remember that this was not ...
Teije van der Horst's user avatar
4 votes

Using Zonal Statistics to determine percent forest cover in grid cells?

Try reclassifying your raster (Spatial Analyst > Reclass > Reclassify) so that every pixel that used to have a value (forested) gets a value of 1, and everything that didn't becomes 0. Then, you ...
J Kelly's user avatar
  • 1,383
4 votes
Accepted

.tif file conversion to .bil format

Read the tif file into an R object and save it as a .bil file. > library(raster) > r = raster("r.tif") > writeRaster(r,"r.bil") > Note this results in three new files, with the data and ...
Spacedman's user avatar
  • 66.5k
4 votes
Accepted

Burning zeros instead of nodata in GDAL rasterize

You are specifically telling gdal_rasterize to set 0 to nodata with the -a_nodata 0.0 parameter you use. You also specify -init -999999999.0 which doesn't make much sense as your output type is Byte (...
user2856's user avatar
  • 69.6k
4 votes

Converting 5m DTM Raster to 0.5 m resolution in QGIS

The Warp (Reproject) tool will resample for you. You need to set the Output file resolution to 0.5 in your case, and also pick an appropriate Resampling method:
Tom Brennan's user avatar
  • 5,479
4 votes

Converting 5m DTM Raster to 0.5 m resolution in QGIS

Resampling 5 m pixels into 0.5 m pixel size is waste of disk space but it may be necessary. However, with QGIS it should be possible to use the GDAL virtual format (VRT) without resampling. See the ...
user30184's user avatar
  • 69.1k
4 votes
Accepted

Converting float32 format raster in integer type raster

Use the GDAL Translate algorithm, leave all the parameters as default, just change the Output data type parameter (in the lower part of the algorithm dialog) to the desired data type. And the data ...
Mayo's user avatar
  • 4,050
3 votes

Python/GDAL--Handling Big Rasters and avoid MemoryErrors?

You could use the python module RIOS (Raster I/O Simplification). It reads an image into memory in a block of 400 x 400 x nbands and writes the output to a new image. It handles the opening of the ...
GeoMonkey's user avatar
  • 1,439
3 votes

What resampling method is used in the raster 'Save as...' dialog?

If the QGIS library is using GDAL for a backend, my guess (without checking QGIS source!) is that it's using nearest because that's the default for both the gdalwarp and gdal_translate utilities. In ...
SaultDon's user avatar
  • 10.5k
3 votes
Accepted

Preserving nodata values when using gdal_translate -scale

Instead of using NODATA, in this case it is better to use a mask: As the NODATA value is 0, I can easily create the mask with -co NBITS=1 as everything above a value of 1 will be cut to 1. # Create ...
pLumo's user avatar
  • 6,569
3 votes
Accepted

How to display Flow Direction arrows + Burn Stream Netwok in QGIS?

Regarding your first question (it's usually better to focus on one question per post): In GRASS you can display vectors with direction arrows. In the gui there's a checkbox "Display direction of ...
Micha's user avatar
  • 15.8k
3 votes

Converting each cell value of raster into floating-point representation using QGIS?

I was able to achieve this by utilizing the GdalTools plugin. GDAL -> GDAL Conversion -> Translate (convert format). I chose the output raster to have the data type float32, and received a GeoTIFF ...
Alexander B's user avatar
3 votes
Accepted

How do I improve the resolution of a raster layer

You could use the GRASS tool r.resamp.interp which allows you to resample your raster to a finer resolution by specifying the cell size.
Joseph's user avatar
  • 76.3k
3 votes

Normalizing a digital surface model?

If I have interpreted your question correctly, I believe that what you are trying to do is to remove the underlying ground surface from your digital surface model (DSM). I would recommend using a ...
WhiteboxDev's user avatar
  • 11.1k
3 votes

Add layer to RasterBrick R

The addLayer function works by stacking all its arguments - to add a layer to an existing raster or stack make it the first argument. This is shown in the help: file <- system.file("external/test....
Spacedman's user avatar
  • 66.5k

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