I suggested the -where option because your shapefile had only two features that are (almost)inverse of each other. You can select only one of them. You might want to use the -at option with this.<br><br>What do you mean by 'most representative value'?<br>
<br><div class="gmail_quote">On Fri, Aug 5, 2011 at 5:40 PM, Etienne <span dir="ltr"><<a href="mailto:etiennesky@yahoo.com">etiennesky@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: times new roman,new york,times,serif; font-size: 12pt;"><div><span>Hi and thanks!</span></div><div><br><span></span></div><div><span>I set the init value to 255, and the overlapping pixels are set to that value (instead of the default of 0). <br>
</span></div><div><span><br></span></div><div><span>Unfortunately, using -where resulted in the same gaps not being filled, and a combination of -where and -at selects too many pixels (the borders all overlap).</span></div>
<div><br></div><div><span>Looking more closely, it seems that the problem is almost exclusively where there are tiny gaps between the polygons.</span></div><div><br><span></span></div><div><span>It seems that -at doesn't leave any gaps, although it favors the higher-index values (as they are processed later, presumably).</span></div>
<div><span>I would prefer to have the most representative value, any
hints?<br></span></div><div><br><span></span></div><div><span>many thanks, Etienne</span></div><div><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">
<div class="hm"><font face="Arial" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Chaitanya kumar CH <<a href="mailto:chaitanya.ch@gmail.com" target="_blank">chaitanya.ch@gmail.com</a>><br>
<b><span style="font-weight: bold;">To:</span></b> Etienne <<a href="mailto:etiennesky@yahoo.com" target="_blank">etiennesky@yahoo.com</a>><br><b><span style="font-weight: bold;">Cc:</span></b> "<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>" <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>><br>
<b><span style="font-weight: bold;">Sent:</span></b> Friday, August 5, 2011 4:22:10 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [gdal-dev] problem rasterizing categorical data from shapefile - 0 values at some intersections<br>
</font></div><div><div></div><div class="h5"><br><div>Etienne,<br><br>Rasters of type Byte cannot hold
values below 0. So, the nodata value of -1 is not practical. It's better to choose 0 or 255 depending on your data or choose a different data type.<br><br>Your problem arises because the two geometries in the shapefile overlap in some places and leave some gaps between them in other places.<br>
Consider selecting only one feature using the -where option in gdal_rasterize. You can also use the -at option but it may not work at all resolutions.<br><br><div>On Fri, Aug 5, 2011 at 7:40 AM, Etienne <span dir="ltr"><<a rel="nofollow" href="mailto:etiennesky@yahoo.com" target="_blank">etiennesky@yahoo.com</a>></span> wrote:<br>
<blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi all,<br>
<br>
I am trying to create a raster file with categorical data (land vegetation/cover positive indices) from a shapefile containing 1 layer of polygons. <br>
<br>
I use the following command: <br>
gdal_rasterize -tr 0.0005 0.0005 -a_nodata -1 -of GTiff -a_srs EPSG:4618 -a "CLASSE_ID" -ot Byte -init -1 -l region1 region1.shp region1-3.tif<br>
<br>
This creates a map which looks good, but there are some holes in the data, (individual pixels with a value of 0) at the intersection of 2 polygons. It looks like the<br>
intersections pass through the exact center of these pixels. These pixels are not set to missing(-1). Depending on the output resolution, different pixels get set to a value of 0.<br>
<br>
Has anyone ran into this problem? Any idea how to fix this? <br>
Those interested will find 2 small shapefiles here: <a rel="nofollow" href="http://db.tt/3X4hI45" target="_blank">http://db.tt/3X4hI45</a> and <a rel="nofollow" href="http://db.tt/phqnGci" target="_blank">http://db.tt/phqnGci</a><br>
<br>
<br>
I tried using gdal_grid, but it doesn't seem to support a shapefile with POLYGONs.<br>
<br>
many thanks!<br>
Etienne<br>
<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a rel="nofollow" href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a rel="nofollow" href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br><br><a href="tel:%2B91-9494447584" value="+919494447584" target="_blank">+91-9494447584</a><br>17.2416N 80.1426E<br>
</div><br><br></div></div></div></div></div></div></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br><br>+91-9494447584<br>17.2416N 80.1426E<br>