Advice needed on psimage and gdal interaction

Added by John 10 months ago

Aloha.
I'm trying to generate an animation with 3 images aligned horizontally and time-synced. I have two problems that I would appreciate advice about. Here they are.

1. I can stack them vertically already but don't know how to get them arranged horizontally. I'm looking at the manuals to see if I can see anything like this.

2. I produce one of the images using this command:
gdal_translate of Gtiff -a_ullr $COORDS \
-a_srs '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' NETCDF:$WORK_DIR/$DATA_FILE_TR:$VARIABLE $OUTPUT_DIR/$DATA_FILE_TR
$VARIABLE.tif
This produces a geotiff of Float32 type. If I take this and subsequently convert it to Byte, which seems to be the only thing psimage can take (although the doc says elsewise), I seem to lose information and end up with only black images. I can try to put it out as byte originally but this requires running a big job. I will do that if nothing else is possible but it seems like I would end up in the same place.

Any suggestions would be much appreciated. i'm probably misunderstanding something about gdal_translate and/or psimage but I'm currently adrift.

J.


Replies (15)

RE: Advice needed on psimage and gdal interaction - Added by Paul 10 months ago

So psimage is only trained to expect a byte image. If you have floating point data in the tif file then don't you want to convert that to color via a CPT? If so then you need grdimage. I mean, your tiff only has one band of 32-bit floating point numbers. What do they represent? Grayscale? Or perhaps I am misunderstanding what you are passing.

RE: Advice needed on psimage and gdal interaction - Added by Joaquim 10 months ago

Regarding point 2. Why don't you use grdimage -A directly to create the image or, for images that require more modules (e.g. pscoast), create your ps fig and use psconvert to get the image?

RE: Advice needed on psimage and gdal interaction - Added by John 10 months ago

Mahalo. That makes sense.

RE: Advice needed on psimage and gdal interaction - Added by John 10 months ago

Looks like grdimage only accepts byte data as well. Is something amiss?

grdimage: Using data type other than byte (unsigned char) is not implemented
grdimage (GMTAPI_Import_Image): Non-unique grid format [/Volumes/Pegasus2R6/WWRF-Output-Visualization-Animation-Input/QPF-D02/QPFhourly_d02_2017-11-09_12-00-00-RAINHR.tif]
[Session gmt (0)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
[Session gmt (0)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
[Session gmt (0)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)

RE: Advice needed on psimage and gdal interaction - Added by Paul 10 months ago

Could you post the grdimage command so we can see what you are doing?

RE: Advice needed on psimage and gdal interaction - Added by John 10 months ago

Of course. I should have done. It's the 3rd gmt command below.

+ gmt psimage WWRFv1_ivt_DTwo-IIIa-2017-11-09_12:00:00-003hr.png -Dx3.75/13+w7 -F+pthin,blue -K
+ gmt psimage WWRFv1_ivt_DTwo-IIIb-2017-11-09_12:00:00-003hr.png -Dx3.75/7+w7 -F+pthin,blue -K -O
+ gmt grdimage QPF-D02/QPFhourly_d02_2017-11-09_12-00-00-RAINHR.tif -Dx3.75/7+w7 -R-123.75/-121.303/37/38.92 -Crain.cpt -K -O
grdimage: Using data type other than byte (unsigned char) is not implemented
grdimage (GMTAPI_Import_Image): Non-unique grid format [/Volumes/Pegasus2R6/WWRF-Output-Visualization-Animation-Input/QPF-D02/QPFhourly_d02_2017-11-09_12-00-00-RAINHR.tif]
[Session gmt (0)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
[Session gmt (0)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
[Session gmt (0)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
+

RE: Advice needed on psimage and gdal interaction - Added by John 10 months ago

Also, I edited out all the path information that you see in the message. I was trying to be more clear but realize that it may be confusing to have done that.

RE: Advice needed on psimage and gdal interaction - Added by Joaquim 10 months ago

- grdimage doesn't have that -D option

- Are you trying to read a tif image? What sort of tif? In first post you have a NETCDF:... so we thought it was floats array

RE: Advice needed on psimage and gdal interaction - Added by Paul 10 months ago

Missing the -J option to grdimage.

RE: Advice needed on psimage and gdal interaction - Added by John 10 months ago

I agree it's confusing. I can go back to a prior output that is NetCDF and that may be the best way to do this.
What I also find puzzling is that the geotiff that I created with gdal has a lot of NetCDF metadata in it. Seems odd but maybe kosher.
I'll try adding the -J to grdimage but why would that bear upon the input datatype message?

I'm including the tif image for your edification.

QPFhourly_d02_2017-11-09_12-00-00-RAINHR.tif - Problematic geotiff (618 KB)

RE: Advice needed on psimage and gdal interaction - Added by John 10 months ago

So, when I remove the -D and add -J, the error message goes away. I'll do some more testing and see if this can be made workable.
J.

RE: Advice needed on psimage and gdal interaction - Added by Joaquim 10 months ago

The tif file has only zeros

RE: Advice needed on psimage and gdal interaction - Added by John 10 months ago

Yes. This one does but there is a time-series such that the values change. I have to give this up for now and will pick it up tomorrow. Thanks for you help.

RE: Advice needed on psimage and gdal interaction - Added by John 10 months ago

Looks like everything is working now thanks to your advice. I've attached a single frame from the animation FYI.
Mahalo.
J.

(1-15/15)