<p dir="ltr">Ok thanks a lot for the answer! </p>
<div class="gmail_quote">Le 14 janv. 2015 13:25, "Even Rouault-2 [via OSGeo.org]" <<a href="/user/SendEmail.jtp?type=node&node=5181520&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>> a écrit :<br type="attribution"><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

        Selon mathieu <<a href="http:///user/SendEmail.jtp?type=node&node=5181459&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>>:
<br><br>> Is there a simple way to find one or several pixel value none of the bands
<br>> use ?
<br><br>Analyzing the histograms is the closest way I can think of.
<br><br>With "gdalinfo -hist in.tif" for example (but it is admitedly not completely
<br>trivial to find the index from the output)
<br>Or programatically with GetDefaultHistogram():
<br><a href="http://www.gdal.org/classGDALRasterBand.html#afeffe2ed8bfdc3d84200a57068ad0945" rel="nofollow" link="external" target="_blank">http://www.gdal.org/classGDALRasterBand.html#afeffe2ed8bfdc3d84200a57068ad0945</a><br><div><div class='shrinkable-quote'><br>>
<br>> Mathieu
<br>>
<br>> 2015-01-14 12:06 GMT+01:00 Even Rouault-2 [via OSGeo.org] <
<br>> <a href="http:///user/SendEmail.jtp?type=node&node=5181459&i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a>>:
<br>>
<br>> > Selon mathieu <[hidden email]
<br>> > <<a href="http:///user/SendEmail.jtp?type=node&node=5181443&i=0" rel="nofollow" link="external" target="_blank">http:///user/SendEmail.jtp?type=node&node=5181443&i=0</a>>>:
<br>> >
<br>> > > The problem is that I don't know want an alpha channel because some of
<br>> > my
<br>> > > users work on MapInfo and MapInfo doesn't deal with alpha channels..
<br>> >
<br>> > Really ??? Tell them to use QGIS instead. It does support alpha channel.
<br>> >
<br>> > Otherwise try to find a nodata value that isn't a valid pixel value. But
<br>> > I'd
<br>> > note that the nodata support in TIFF is a GDAL extended TIFF tag, so I
<br>> > wouldn't
<br>> > be surprised if MapInfo doesn't support it either.
<br>> >
<br>> > >
<br>> > > 2015-01-14 11:39 GMT+01:00 Even Rouault-2 [via OSGeo.org] <
<br>> > > [hidden email] <<a href="http:///user/SendEmail.jtp?type=node&node=5181443&i=1" rel="nofollow" link="external" target="_blank">http:///user/SendEmail.jtp?type=node&node=5181443&i=1</a>>>:
<br>> >
<br>> > >
<br>> > > > Mathieu,
<br>> > > >
<br>> > > > If 0 is a valid value at some locations of your raster, then you
<br>> > cannot
<br>> > > > use it
<br>> > > > as the nodata value. Use an alpha band instead for example by using
<br>> > > > -dstalpha
<br>> > > > instead of -dstnodata 0
<br>> > > >
<br>> > > > Even
<br>> > > >
<br>> > > > > Hello,
<br>> > > > >
<br>> > > > > I crop a 3 band raster by a polygon with the following formula :
<br>> > > > > /gdalwarp -of GTiff -cutline polygon.shp -cl polygon input.tif
<br>> > > > output.tif
<br>> > > > > /
<br>> > > > > But pixels outside my polygon are assigned the 0 value. I'd like
<br>> > them to
<br>> > > > > have nodata
<br>> > > > >
<br>> > > > > If I put the -dstnodata 0 option :
<br>> > > > > /gdalwarp -of GTiff -cutline polygon.shp -cl polygon input.tif
<br>> > > > output.tif
<br>> > > > > -dstnodata 0/, all the pixels in each of the 3 bands that contain
<br>> > the 0
<br>> > > > > value will be turned to nodata, even if they are contained in my
<br>> > > > polygon.
<br>> > > > >
<br>> > > > > Hence, 127 0 222 will become 127 nodata 222
<br>> > > > > or 0 127 222 will become nodata 127 222
<br>> > > > >
<br>> > > > > How to put the nodata value only outside my polygon ?
<br>> > > > >
<br>> > > > > Thanks a lot in advance !
<br>> > > > >
<br>> > > > > Mathieu
<br>> > > > >
<br>> > > > >
<br>> > > > >
<br>> > > > > --
<br>> > > > > View this message in context:
<br>> > > > >
<br>> > > >
<br>> > > >
<br>> > >
<br>> >
<br>> >
<br>>
</div><a href="http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426.html" rel="nofollow" link="external" target="_blank">http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426.html</a><div><br>> >
<br>> > > > > Sent from the GDAL - Dev mailing list archive at Nabble.com.
<br>> > > > > _______________________________________________
<br>> > > > > gdal-dev mailing list
<br>> > > > > [hidden email] <
<br>> > <a href="http:///user/SendEmail.jtp?type=node&node=5181432&i=0" rel="nofollow" link="external" target="_blank">http:///user/SendEmail.jtp?type=node&node=5181432&i=0</a>>
<br>> > > > > <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>> > > > >
<br>> > > >
<br>> > > >
<br>> > > > --
<br>> > > > Spatialys - Geospatial professional services
<br>> > > > <a href="http://www.spatialys.com" rel="nofollow" link="external" target="_blank">http://www.spatialys.com</a><br>> > > > _______________________________________________
<br>> > > > gdal-dev mailing list
<br>> > > > [hidden email] <<a href="http:///user/SendEmail.jtp?type=node&node=5181432&i=1" rel="nofollow" link="external" target="_blank">http:///user/SendEmail.jtp?type=node&node=5181432&i=1</a>>
<br>> >
<br>> > > > <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>> > > >
<br>> > > >
<br>> > > > ------------------------------
<br>> > > >  If you reply to this email, your message will be added to the
<br>> > discussion
<br>> > > > below:
<br>> > > >
<br>> > > >
<br>> > >
<br>> >
<br>> >
<br>>
</div><a href="http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426p5181432.html" rel="nofollow" link="external" target="_blank">http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426p5181432.html</a><div><br>> > > >  To unsubscribe from Cropping a raster by a polygon - only nodata
<br>> > outside
<br>> > > > polygon wanted, click here
<br>> > > >
<br>> > >
<br>> > <
<br>> > > > .
<br>> > > > NAML
<br>> > > >
<br>> > >
<br>> > <
<br>> >
<br>>
</div><a href="http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" link="external" target="_blank">http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml</a>>
<div><br>> >
<br>> > > >
<br>> > >
<br>> > >
<br>> > >
<br>> > >
<br>> > > --
<br>> > > View this message in context:
<br>> > >
<br>> >
<br>> >
<br>>
</div><a href="http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426p5181437.html" rel="nofollow" link="external" target="_blank">http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426p5181437.html</a><div><br>> > > Sent from the GDAL - Dev mailing list archive at Nabble.com.
<br>> >
<br>> >
<br>> > --
<br>> > Spatialys - Geospatial professional services
<br>> > <a href="http://www.spatialys.com" rel="nofollow" link="external" target="_blank">http://www.spatialys.com</a><br>> > _______________________________________________
<br>> > gdal-dev mailing list
<br>> > [hidden email] <<a href="http:///user/SendEmail.jtp?type=node&node=5181443&i=2" rel="nofollow" link="external" target="_blank">http:///user/SendEmail.jtp?type=node&node=5181443&i=2</a>>
<br>> > <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>> >
<br>> >
<br>> > ------------------------------
<br>> >  If you reply to this email, your message will be added to the discussion
<br>> > below:
<br>> >
<br>> >
<br>>
</div><a href="http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426p5181443.html" rel="nofollow" link="external" target="_blank">http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426p5181443.html</a><br>> >  To unsubscribe from Cropping a raster by a polygon - only nodata outside
<br>> > polygon wanted, click here
<br>> >
<br>>
</div><<a rel="nofollow" link="external" target="_top">
<br>> > .
<br>> > NAML
<br>> >
<br>>
<br><<a href="http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" link="external" target="_blank">http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml</a>>
<br>> >
<br>>
<br>>
<br>>
<br>>
<br>> --
<br>> View this message in context:
<br>>
<br><a href="http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426p5181453.html" rel="nofollow" link="external" target="_blank">http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426p5181453.html</a><br>> Sent from the GDAL - Dev mailing list archive at Nabble.com.
<br><br><br>-- 
<br>Spatialys - Geospatial professional services
<br><a href="http://www.spatialys.com" rel="nofollow" link="external" target="_blank">http://www.spatialys.com</a><br>_______________________________________________
<br>gdal-dev mailing list
<br><a href="http:///user/SendEmail.jtp?type=node&node=5181459&i=2" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>

        
        
        
        <br>
        <br>
        <hr noshade size="1" color="#cccccc">
        <div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                <a href="http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426p5181459.html" target="_blank" rel="nofollow" link="external">http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426p5181459.html</a>
        </div>
        <div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
                
                To unsubscribe from Cropping a raster by a polygon - only nodata outside polygon wanted, <a href="" target="_blank" rel="nofollow" link="external">click here</a>.<br>
                <a href="http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank" link="external">NAML</a>
        </div></a></blockquote></div>


        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426p5181520.html">Re: Cropping a raster by a polygon - only nodata outside polygon wanted</a><br/>
Sent from the <a href="http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html">GDAL - Dev mailing list archive</a> at Nabble.com.<br/>