Re: [gdal-dev] GDAL 3.4.2: gdalbuildvrt band selection bug
Thanks for the fix Even. > On 30 Mar 2022, at 14:21, Even Rouault wrote: > > Pete, > > ouch, confirmed, and fix queued in https://github.com/OSGeo/gdal/pull/5547 . > And the commit you mention was indeed the culprit. > > Potential workarounds (besides generating the VRT on GDAL <= 3.4.0) > > - if using gdalbuildvrt on a single source, you could just use > "gdal_translate sen2_20210527_aber_subset.kea test.vrt -b 2", that will do > the job equally well > > - if using multiple sources, you could also use gdal_translate with band > selection on the VRT generated by gdalbuildvrt (without band selection) to > extract only the band(s) you're interested in, but obviously that creates one > more file > > (do not hesitate to file an issue in github for obvious regressions like > that. emails tend to be easily forgotten) > > Even > > Le 30/03/2022 à 12:59, Pete Bunting via gdal-dev a écrit : >> Hi, >> >> With the release of gdal 3.4.2, gdalbuildvrt seems to have a bug when >> selecting image bands. It works OK when band 1 is specified but if other >> band(s) in the image are used without band 1 then it seg faults. I noticed >> there were some changes around checking bands in the release notes "change >> logic to check homogenous number of bands” and I had a quick look at the >> commits but cannot see where this is occurring. >> >> # Works: >> gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 1 >> >> # Seg Faults: >> gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 2 >> >> ERROR 5: sen2_20210527_aber_subset.kea: GDALDataset::GetRasterBand(2) - >> Illegal band # >> Segmentation fault (core dumped) >> >> >> # Works: >> gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 1 -b 2 -b 3 >> >> # Seg Faults: >> gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 2 -b 3 -b 4 >> >> ERROR 5: sen2_20210527_aber_subset.kea: GDALDataset::GetRasterBand(4) - >> Illegal band # >> Segmentation fault (core dumped) >> >> Note, the input image I was using has 10 bands and these commands work with >> 3.4.1. I get the same seg fault on Mac, Linux and Windows ("Windows fatal >> exception: access violation"). >> >> Many thanks, >> >> Pete >> ___ >> gdal-dev mailing list >> gdal-dev@lists.osgeo.org >> https://lists.osgeo.org/mailman/listinfo/gdal-dev > > -- > http://www.spatialys.com > My software is free, but my time generally not. > ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Trouble reprojecting feature that crosses antimeridian
Thank you everyone for the responses, and Even for the bug fix. Best regards, Robin On 29 March 2022 at 22:33:49, Even Rouault (even.roua...@spatialys.com) wrote: Was a bug. Fix queued in https://github.com/OSGeo/gdal/pull/5543 Le 29/03/2022 à 22:30, Robin Wilson a écrit : Hi, I’ve been running into problems creating STAC items for images that cross the antimeridian. The geometries for the images are coming out as spanning the width of the whole world (from -180 to +180 degrees). With the help of the author of the tool I was using to create the STAC items (rio-stac), I’ve narrowed it down to a simple test case of reprojecting geometries (which is what the tool is doing internally). If you put the following GeoJSON for an antimeridian-crossing polygon in WGS 84 / UTM zone 1N in a file called test_32601.geojson: ``` {"type":"Polygon","coordinates":[[[377120,7577600],[418080,7577600],[418080,7618560],[377120,7618560],[377120,7577600]]]} ``` and then run the following: ``` ogr2ogr -f GeoJSON -s_srs epsg:32601 -t_srs epsg:4326 out_4326.geojson test_32601.geojson ``` The contents of the output file will be: ``` { "type": "Polygon", "coordinates": [ [ [ -179.018099960087909, 68.666857319910392 ], [ -178.985579869598382, 68.299719485120988 ], [ -179.976982644969041, 68.284942315413858 ], [ 179.974309855567753, 68.651801088224246 ], [ 180.0, 68.652259945574556 ], [ 180.0, 68.652259945541758 ], [ 180.0, 68.652259944541754 ], [ -180.0, 68.652259944541754 ], [ -180.0, 68.652259945541758 ], [ -180.0, 68.652259945610126 ], [ -179.018099960087909, 68.666857319910392 ] ] ] } ``` In that output geometry there are longitudes of 180 and -180, so when plotted on a map it spans the whole width of the world. The author of the rio-stac library did a PR to try and fix this problem (https://github.com/developmentseed/rio-stac/pull/30), but it doesn’t seem to have fixed it for this example, as the underlying GDAL code used by his library (through rasterio, I believe) is giving this result. I find this result unexpected, but I have no knowledge of how GDAL deals with the antimeridian. Is this to be expected, or is this potentially a bug? If it isn’t a bug, is there any way around this? Best regards, Robin Dr Robin Wilson www.rtwilson.com ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev -- http://www.spatialys.com My software is free, but my time generally not.___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] GDAL 3.4.2: gdalbuildvrt band selection bug
Pete, ouch, confirmed, and fix queued in https://github.com/OSGeo/gdal/pull/5547 . And the commit you mention was indeed the culprit. Potential workarounds (besides generating the VRT on GDAL <= 3.4.0) - if using gdalbuildvrt on a single source, you could just use "gdal_translate sen2_20210527_aber_subset.kea test.vrt -b 2", that will do the job equally well - if using multiple sources, you could also use gdal_translate with band selection on the VRT generated by gdalbuildvrt (without band selection) to extract only the band(s) you're interested in, but obviously that creates one more file (do not hesitate to file an issue in github for obvious regressions like that. emails tend to be easily forgotten) Even Le 30/03/2022 à 12:59, Pete Bunting via gdal-dev a écrit : Hi, With the release of gdal 3.4.2, gdalbuildvrt seems to have a bug when selecting image bands. It works OK when band 1 is specified but if other band(s) in the image are used without band 1 then it seg faults. I noticed there were some changes around checking bands in the release notes "change logic to check homogenous number of bands” and I had a quick look at the commits but cannot see where this is occurring. # Works: gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 1 # Seg Faults: gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 2 ERROR 5: sen2_20210527_aber_subset.kea: GDALDataset::GetRasterBand(2) - Illegal band # Segmentation fault (core dumped) # Works: gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 1 -b 2 -b 3 # Seg Faults: gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 2 -b 3 -b 4 ERROR 5: sen2_20210527_aber_subset.kea: GDALDataset::GetRasterBand(4) - Illegal band # Segmentation fault (core dumped) Note, the input image I was using has 10 bands and these commands work with 3.4.1. I get the same seg fault on Mac, Linux and Windows ("Windows fatal exception: access violation"). Many thanks, Pete ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev -- http://www.spatialys.com My software is free, but my time generally not. ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] GDAL 3.4.2: gdalbuildvrt band selection bug
Hi, I can confirm with GDAL 3.5.0dev from gisinternals and with a normal RGB ortoimage. gdalbuildvrt test.vrt p4433h.tif -b 2 0...10...20...30...40...50...60...70...80...90...100 - done. ERROR 5: p4433h.tif: GDALDataset::GetRasterBand(2) - Illegal band # With -b 1 -b 2 the command runs fine. -Jukka Rahkonen- -Alkuperäinen viesti- Lähettäjä: gdal-dev Puolesta Pete Bunting via gdal-dev Lähetetty: keskiviikko 30. maaliskuuta 2022 13.59 Vastaanottaja: gdal-dev@lists.osgeo.org Aihe: [gdal-dev] GDAL 3.4.2: gdalbuildvrt band selection bug Hi, With the release of gdal 3.4.2, gdalbuildvrt seems to have a bug when selecting image bands. It works OK when band 1 is specified but if other band(s) in the image are used without band 1 then it seg faults. I noticed there were some changes around checking bands in the release notes "change logic to check homogenous number of bands” and I had a quick look at the commits but cannot see where this is occurring. # Works: gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 1 # Seg Faults: gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 2 ERROR 5: sen2_20210527_aber_subset.kea: GDALDataset::GetRasterBand(2) - Illegal band # Segmentation fault (core dumped) # Works: gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 1 -b 2 -b 3 # Seg Faults: gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 2 -b 3 -b 4 ERROR 5: sen2_20210527_aber_subset.kea: GDALDataset::GetRasterBand(4) - Illegal band # Segmentation fault (core dumped) Note, the input image I was using has 10 bands and these commands work with 3.4.1. I get the same seg fault on Mac, Linux and Windows ("Windows fatal exception: access violation"). Many thanks, Pete ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
[gdal-dev] GDAL 3.4.2: gdalbuildvrt band selection bug
Hi, With the release of gdal 3.4.2, gdalbuildvrt seems to have a bug when selecting image bands. It works OK when band 1 is specified but if other band(s) in the image are used without band 1 then it seg faults. I noticed there were some changes around checking bands in the release notes "change logic to check homogenous number of bands” and I had a quick look at the commits but cannot see where this is occurring. # Works: gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 1 # Seg Faults: gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 2 ERROR 5: sen2_20210527_aber_subset.kea: GDALDataset::GetRasterBand(2) - Illegal band # Segmentation fault (core dumped) # Works: gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 1 -b 2 -b 3 # Seg Faults: gdalbuildvrt test.vrt sen2_20210527_aber_subset.kea -b 2 -b 3 -b 4 ERROR 5: sen2_20210527_aber_subset.kea: GDALDataset::GetRasterBand(4) - Illegal band # Segmentation fault (core dumped) Note, the input image I was using has 10 bands and these commands work with 3.4.1. I get the same seg fault on Mac, Linux and Windows ("Windows fatal exception: access violation"). Many thanks, Pete ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev