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