[gdal-dev] convert shape file to ascii raster

Jonas Malmqvist jonas.malmqvist at fsdynamics.se
Mon Sep 7 05:03:36 EDT 2009


Hi I tried out some different ways an at the end I chose this way, not 
python but you use the same commands I guess.


-Concatenate four shapefiles:
ogr2ogr filemerged.shp mdv07xx1.shp
ogr2ogr -update -append filemerged.shp mdv07xx1.shp -nln filemerged
ogr2ogr -update -append filemerged.shp mdv07xx2.shp -nln filemerged
ogr2ogr -update -append filemerged.shp mdv07xx3.shp -nln filemerged
ogr2ogr -update -append filemerged.shp mdv07xx4.shp -nln filemerged

-Create an ARC/INFO textfile with one pixel representing the 
window/region of intrest:

the text file window.asc contains the following:

ncols         1
nrows         1
xllcorner     1283000
yllcorner     6403000
cellsize      30000
NODATA_value  -9999
0

-Increase the resolution on the ARC/Info window and convert i to Geotif:
gdal_translate window.asc -of GTiff  -outsize 300 300 window_high_res.tif

-Rasterize the shapefile onto the Geotif:
gdal_rasterize -a shapefile_field_name -l _shape_file_layer 
filemerged.shp window_high_resolution.tif

-And last convert the high res Geotif to an ARC/Info ascii file:
gdal_translate -of AAIGrid height_high_res.tif height_high_res.asc


Good luck!

-Jonas

¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Jonas Malmqvist
FS Dynamics AB
Jungmansgatan 31
SE-413 11 Göteborg
Sweden
Phone: +46 (0)31 720 71 45
Fax:   +46 (0)31 761 99 49
E-mail:	jonas.malmqvist at fsdynamics.se



Oz Nahum wrote:
> Hi,
> I've been using gdal-rasterize for quite a while now in my python 
> scripts. It only posses on difficulty to me, since it forces me to use 
> the tiff format I need to create a template before creating the raster.
> Does any one know of a quick way of doing the template? Alternatively, 
> can I use other pathway to create ascii raster from shape files with 
> out the creation of templates ?
>
> Can someone direct me to a python solution ?
>
> Many thanks,
> Oz Nahum
> Graduate Student
> Center for Applied Geosciences
> University of Tuebingen
>
> -- 
> ----
>            Imagine there's no countries
>            It isn't hard to do
>            Nothing to kill or die for
>            And no religion too
>            Imagine all the people
>            Living life in peace
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20090907/2e50ff86/attachment.html


More information about the gdal-dev mailing list