0

I have a set of vector based shape files, representing different types of ground coverage in a city (for ex: roads, buildings, open field,...).

For the algorithm that I want to run on it, I need just one raster file with these different ground coverages represented by different bands.

The final file needs to be from IMG file type.

1
  • Could you provide details on the algorithm please? What is the purpose of your analysis? The usual approach would be to use a thematic raster layer where pixel values representing roads = 1, buildings = 2, etc... – Aaron Apr 9 '14 at 13:02
0

I believe you can do it rather simply with gdal_rasterize http://www.gdal.org/gdal_rasterize.html

  1. Create a new IMG file to be used as painting canvas. Draw a big rectangle that covers all your vector files and save it as "background.shp". Burn this polygon into a new IMG file as black. You must tell the target resolution of the new raster file. Let's assume your data are in EPSG:4326, you want the raster resolution to be 0.1 degrees and in your final IMG file you want to have 6 bands. The command to run is

gdal_rasterize -of hfa -burn 0 0 0 0 0 0 -tr 0.1 0.1 -l background background.shp burn.img

  1. You have created a 6 band IMG file where the big rectangle is burned into each band with value 0. Now you can start burning the vector layers on top of the existing layers. Next commands will be like
gdal_rasterize -b 1 -burn 100 -l first first.shp burn.img
gdal_rasterize -b 2 -burn 100 -l second second.shp burn.img
...

First command will burn vectors from first.shp into band 1 with value 100, second command burns vectors from second.shp into band 2.

0

Sorry, missed the information that you want separate bands for classes. Answer eddited:

You can possibly try this steps:

1) create grid for each class from vector (for example in GRASS) (class features = single value, others nodata,

2) export the result to IMG with gdal_merge.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.