|
It seems you are raising several questions here,
mixed together. See inline...
On 10/21/2020 11:16 PM, Mauricio Tecles
wrote:
Thank you
for your answer. I agree and realize that. Let me put it
another way to describe
my problem and what I need.
I need
bmp
(32 bits-RGBA, 2048x2048 pixels) and dds images, that
each of them I will call a
patch. These patches are square, created form (UTM,
EPSG:32723) 5760mx5760m size
cuts of a large RGB composed satellite images.
2nd problem is conversion to BMP and DDS format. This can be
handled by gdal_translate, with the -of (output format) flag.
3rd problem is resampling to a lower resolution. Again
gdal_translate can do this using the -outsize flag
Your 1st problem, IIUC was to merge together several RGB images.
That should be done most easily with gdalbuildvrt. Then the colors
will be matched "automatically"
This is
what I used to do to create one patch with QGIS:
- From
the RGB
composed image I extracted (clip) a patch. Correct the
min and max of each band
of the patch to reflect those values of the big RGB
composed image.
- Zoom to
the patch layer (the only one displayed).
- Crtl-P
(print).
- Select
printer – I have no physical printer, so I used to
select Microsoft XPS
Document Writer (the only one I could select the paper
size defined by user).
- Page
setup: select “size defined by user”.
- Add a
new map to layout (the patch).
(Here I
could change the paper size or not. It would lead to the
same good result).
- Item
properties -> Extents: set X min, Y min, X max, Y max
to the exact extents
of the patch.
- Layout:
Resize layout (all margins are set to 0) – the image
(the extents of the patch)
as fit to the entire paper.
- Layout->Export
as Image…, select png and set to 2048x2048 pixels (page
width, page height).
- Open the
png with Paint.net, save as bmp 32 bits (RGBA) and save
as dds.
My
problems:
- I need to cut at least 400 patches,
trimming
each one to the color scale of the big image is hard
work, but possible to do. An
automated (batch file?) to do that would be great!
So what I suggest:
1- Create a VRT file (gdalbuildvrt) from all your original RGB
images.
2- Write a loop in whatever scripting language that you're
comfortable with that scans across the length and height of that
VRT, in steps as big as you choose. The loop iteration will give
you the X-Y corners of each cropping window.
3- For each step run gdal_translate twice: to resample to your
chosen export size, and save to BMP, then a second call to save
also to DDS.
- The
print
layout is not working anymore to fit the paper to the
exact size of the image (the
extents of the patch) (probably after
some Windows update), even
selecting “size defined by user”. Changing the
extents and resizing does not have the same effect as
before. The result is always
the extent in the middle of the paper surrounded by a
white border.
I have
tried to make a
bigger clip (5x5 patches) then export as bmp
(Projet->Import/Export->Export
map to image…) to cut it with Paint.net, but it is
impossible to match the
extent and pixel size precisely. If I set the extent it
turns to 10242x10242
pixels. If I set to 10240x10240 pixels, as it should be,
it reduces the extent.
The same happens trying to export a patch this way.
Is there
a
way to export/transform the tif patches (UTM,
EPSG:32723, size: 5760mx5760m) to
bmp (32 bits, 2048x2048 pixels) and dds?
(gdal_translate, gdal_retile, OSGeo4W
Shell or other)?
I think the above would be way simpler than trying to dance
between QGIS and Paint
Hints are
welcome!
Thank
you,
I don't think your issue is with the clip of the
rasters, it is with how the software you are using sets
the scale for the display of the layer.
When you clip a layer in QGIS or directly with
gdal_translate, the default is to leave the pixel values
exactly as they are, which is generally what you want.
After all, if the software rescaled the max/min to some
fixed value, then when you tried to display these
side-by-side or reassemble them into a single image the
values wouldn't make sense.
The issue you apparently are facing is that by default
on loading a raster the software you are using finds the
min and max value and scales the display to span that
full range, which is what QGIS does by default with
raster layers. (The exact details of the scaling are
determine by settings in the Settings -> Raster tab.)
Without knowing what your display software is I can't
suggest a solution.
_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
|