[gdal-dev] '-mask' option of gdal_translate doesn't work

2012-09-11 Thread Peter Zhang
Hello,

I tried command line below that is copied from 
http://www.gdal.org/gdal_translate.html:

gdal_translate rgba.tif withmask.tif -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG 
-co PHOTOMETRIC=YCBCR --config GDAL_TIFF_INTERNAL_MASK YES
It doesn’t generate transparency channel in output. But if I removed options 
“-b 1 –b 2 –b 3”, the output image ‘withmask.tif’ would contain transparency 
channel, that could be observed by opening the image in the Photoshop. But if I 
remove all options to modify command line like this:

gdal_translate rgba.tif withmask.tif 
The transparency channel is still generated in output even the option ‘-mask’ 
is not specified at all. And the last alpha channel in the source image is 
always picked up as transparency channel to the output no matter what band 
number is given to the ‘-mask’ option. Then I tried the same command line on a 
new RGB tiff that has more than 4 channels and output image doesn’t contains 
any transparency channel even ‘-mask band’ option is explicitly specified. 

It seems that the option ‘-mask’ doesn’t work and generating the transparency 
channel is only depends on the colorspace (RGBA or Greyscale + alpha). Please 
let me know how to correctly use this option.

Thanks!

Peter Z___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] How to cut a Raster map with a KML file

2012-09-11 Thread Eli Adam
Luis,
On Tue, Sep 11, 2012 at 11:14 AM, Luis Lisboa luislisboa1...@gmail.com wrote:
 Hi Eli
 Probably I was not clear: When I use this it outputs a geotiff with two
 bands: 1 with the real data and another one with the mask of the pixels that
 fall inside each polygon. I just want to have an output file with one band
 (band 1) and without the mask. Is it possible?

Sometime images can clean up just be running them through
gdal_translate.  -ot or -b or -mask or some combination may
additionally be needed.  http://gdal.org/gdal_translate.html  Does
gdal_translate on your file collapse the mask band into a single band
with no data values?

rgb2pct.py can be used to convert RGB/RGBA to single band with a color
table.  I'm not sure if it would work with a two band image, one being
the mask but you can try it and see what it does.

HTH, Eli


 Thanks
 Luis



 On Thu, Sep 6, 2012 at 4:50 AM, Eli Adam ea...@co.lincoln.or.us wrote:

 Luis,

 On Wed, Sep 5, 2012 at 3:00 AM, Luis Lisboa luislisboa1...@gmail.com
 wrote:
  Thank you Chitanya.
  But it created an output file with two layers (one with the values from
  original file and another with a 255 for the pixels thar are inside KMZ
  file: How can I have produce one layer?

 I may be thinking of something else based on your description.  If you
 got an output that has the original values in the area of the kmz and
 an alpha mask band over the other areas I think that would be
 expected.  You can also use -crop_to_cutline to remove that 'extra'
 data.

 If that isn't what you are talking about, you may want to use ogr2ogr
 to convert your kmz to a shapefile in the same projection as your
 input raster and see if it gives you a better result.

 Bests, Eli


  Thanks
  Luis
  On Mon, Sep 3, 2012 at 5:10 PM, Chaitanya kumar CH
  chaitanya...@gmail.com
  wrote:
 
  Luis,
 
  gdalwarp has some options for this exact purpose.
  The cutline can be from any of the OGR readable datasource.
 
  http://www.gdal.org/gdalwarp.html
 
  On Mon, Sep 3, 2012 at 9:34 PM, Luis Lisboa luislisboa1...@gmail.com
  wrote:
 
  Greetings
  I have a raster file (Geotiff) and I have a KML file with a polygon
  and I
  want to cut raster map to only have valid values inside the polygon.
  How can
  I do this using just GDAL?
 
  Usually I used to cut geotiff file with gdalwarp and but in those
  cases I
  was cutting a square (xmin xmax ymin ymax) and in this case is a more
  complex polygon
 
  Thanks
  Regards,
  Luis
 
  ___
  gdal-dev mailing list
  gdal-dev@lists.osgeo.org
  http://lists.osgeo.org/mailman/listinfo/gdal-dev
 
 
 
 
  --
  Best regards,
  Chaitanya kumar CH.
 
  +91-9494447584
  17.2416N 80.1426E
 
 
 
  ___
  gdal-dev mailing list
  gdal-dev@lists.osgeo.org
  http://lists.osgeo.org/mailman/listinfo/gdal-dev


___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


[gdal-dev] MUTEX_NONE question

2012-09-11 Thread Martin Chapman
If I don't want to use GDAL in thread safe mode on Windows can just define
MUTEX_NONE in the nmake.opt file?  If not, is there a way I can do it.
Also, I want to avoid caching.  Can I just define the env var
GDAL_FORCE_CACHING and set it to NO?  Will that also avoid any thread
synchronization? 

 

Best regards,

 

 

Martin Chapman
Software Developer
Pixia Corp.
45615 Willow Pond Plaza
Sterling, VA 20164
Main - 571.203.9665
Cell - 303.324.1065

chapm...@pixia.com

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited.  If you received
this in error, please contact the sender and delete the material from any
computer.

 

 

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] MUTEX_NONE question

2012-09-11 Thread Frank Warmerdam
On Tue, Sep 11, 2012 at 1:08 PM, Martin Chapman chapm...@pixia.com wrote:
 If I don’t want to use GDAL in thread safe mode on Windows can just define
 MUTEX_NONE in the nmake.opt file?  If not, is there a way I can do it.

Martin,

I believe so, yes.

 Also, I want to avoid caching.  Can I just define the env var
 GDAL_FORCE_CACHING and set it to NO?

No, I don't believe that will help much.  This configuration
options just exists (I think) to force use of caching for
drivers or situations where the native driver would normally
avoid it.

I am not aware of a build or configuration option you can
set to avoid caching.

If you really really want to avoid caching you can try
to directly call GDALRasterBand::ReadBlock() which
will completely avoid the block cache.  I haven't done
anything like that for a long time so it may cause
problems for some drivers.

Will that also avoid any thread synchronization?

The MUTEX_NONE should stop essentially all thread
synchronization.  But if you are using multiple threads
you may encounter serious bugs with mutexes disabled.
Doing this makes the most case in single threaded apps
that want to avoid the operating system mutex overhead.

Best regards,
-- 
---+--
I set the clouds in motion - turn up   | Frank Warmerdam, warmer...@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush| Geospatial Software Developer
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev