Hi Daniele, a quick follow up. I also tried the code from the testcase directly to create 1/24th of the original grid envelope. But the results are exactly the same. The read coverage has the exact same envelope and gridrange as the original one.
I therefore checked if it is a problem of non supported range request on the minio instance, but with curl: curl --header "Range: bytes=100-107" -I https://myminioinstance.com/mycogtiff.tif I see: content-type: application/octet-stream content-length: 8 accept-ranges: bytes content-range: bytes 100-107/1236142630 so this should be working properly. Is there something else that comes to your mind that I could try to check where the problem lies? Thank you, Andrea On Wed, Sep 7, 2022 at 9:11 AM andrea antonello <andrea.antone...@gmail.com> wrote: > > Hi Daniele, > thanks for chiming in. > > > I think that you can start from this example: > > https://github.com/geotools/geotools/blob/main/modules/plugin/geotiff/src/test/java/org/geotools/gce/geotiff/GeoTiffReaderCogOnlineTest.java#L46 > > ok, that is where I took the code from. > > > Just make sure to define a reduced envelope when setting up the > > requestedGridGeometry parameter so that it will only access the needed > > ranges to populate the requested envelope. > > > > This section was setting same envelope but smaller raster area, to involve > > overviews: > > https://github.com/geotools/geotools/blob/main/modules/plugin/geotiff/src/test/java/org/geotools/gce/geotiff/GeoTiffReaderCogOnlineTest.java#L100 > > > > You can arrange it to actually request a cropped envelope with a fitting > > raster. > > At that point it should only read the ranges involved to get those tiles. > > Ok, I saw that and that is how I usually define GeneralParameters for > reading a given gridgeometry: > > double n = 45.5; > double s = 45.3; > double e = 10.5; > double w = 10.3; > GeneralParameterValue[] readParams = new GeneralParameterValue[1]; > ParameterValue<GridGeometry2D> readGG = > AbstractGridFormat.READ_GRIDGEOMETRY2D.createValue(); > GridEnvelope2D gridEnvelope = new GridEnvelope2D(0, 0, 2000, 2000); > ReferencedEnvelope env = new ReferencedEnvelope(w, e, s, n, > DefaultGeographicCRS.WGS84); > GridGeometry2D gridGeometry = new GridGeometry2D(gridEnvelope, env); > readGG.setValue(gridGeometry); > readParams[0] = readGG; > > GeoTiffReader gtReader = new GeoTiffReader(getInputProvider()); > GridCoverage2D coverage = gtReader.read(readParams); > System.out.println(coverage); > > the print out is: > > GridCoverage2D["eu_dem_v22_itnord4326_cog512", > GeneralEnvelope[(6.247905524, 44.028140992), (13.301164301, > 47.257876053)], DefaultGeographicCRS["WGS 84"]] > │ RenderedSampleDimension("GRAY_INDEX":[-1.7976931348623157E308 ... > -1.7976931348623157E308]) > │ ‣ Category("No data":[-1.7976931348623157E308 ... > -1.7976931348623157E308]) > └ Image=RenderedOp["ImageRead"] > > as you can see the region spans the complete dataset instead of the n,s,e,w. > > I am probably doing something wrong, but I can't spot it. > > Thank you, > Andrea > > > > > > Please, let us know if you still have issues. > > > > Regards, > > > > Daniele Romagnoli > > > > == > > GeoServer Professional Services from the experts! > > > > Visit http://bit.ly/gs-services-us for more information. > > == > > > > Daniele Romagnoli > > Senior Software Engineer > > > > GeoSolutions Group > > phone: +39 0584 962313 > > fax: +39 0584 1660272 > > > > https://www.geosolutionsgroup.com/ > > http://twitter.com/geosolutions_it > > ------------------------------------------------------- > > > > > > Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE > > 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si > > precisa che ogni circostanza inerente alla presente email (il suo > > contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è > > riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il > > messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra > > operazione è illecita. Le sarei comunque grato se potesse darmene notizia. > > > > This email is intended only for the person or entity to which it is > > addressed and may contain information that is privileged, confidential or > > otherwise protected from disclosure. We remind that - as provided by > > European Regulation 2016/679 “GDPR” - copying, dissemination or use of this > > e-mail or the information herein by anyone other than the intended > > recipient is prohibited. If you have received this email by mistake, please > > notify us immediately by telephone or e-mail. > > > > > > On Tue, Sep 6, 2022 at 3:27 PM andrea antonello > > <andrea.antone...@gmail.com> wrote: > >> > >> > > The s3-geotiff module is not doing range reads, it can read any tiff, > >> > > even non cog, and does read blocks of 5MB caching them on disk. > >> > > > >> > > Full COG support is built into the gt-geotiff module... But has > >> > > currently no caching and requires COG layout. You should find an > >> > > example of usage among the tests. > >> > > >> > oh, I see, thank you so much. Will check that out. > >> > >> I am not sure what you mean by COG layout. I couldn't find any > >> reference in the testcases or source code. > >> I am assuming it should be set inside the GeneralParameters part? > >> Right now using "standard" general parameters I again get the coverage > >> of the complete tiff instead of a range of it. > >> > >> Even if setting the source SPI provider to (as seen in the test): > >> > >> String url = > >> "https://minio.myinstance.org/cogs/eu_dem_v22_itnord4326_cog512.tif"; > >> BasicAuthURI cogUri = new BasicAuthURI(url, false); > >> HttpRangeReader rangeReader = new HttpRangeReader(cogUri.getUri(), > >> CogImageReadParam.DEFAULT_HEADER_LENGTH); > >> CogSourceSPIProvider input = new CogSourceSPIProvider(cogUri, new > >> CogImageReaderSpi(), new CogImageInputStreamSpi(), > >> rangeReader.getClass().getName()); > >> > >> Do you happen to have an example that uses COG layout? > >> > >> Thanks a lot, > >> Andrea > >> > >> > >> > >> > >> > > Il Mar 6 Set 2022, 09:46 andrea antonello <andrea.antone...@gmail.com> > >> > > ha scritto: > >> > >> > >> > >> Hello, > >> > >> I wanted to test the s3 geotiff module to read cogs from a minio > >> > >> instance. > >> > >> > >> > >> It was actually quite simple to set up, but I have not been able to do > >> > >> range requests. > >> > >> The whole image seems to be read every time instead. > >> > >> > >> > >> Can anyone with experience tell me what I might be doing wrong? > >> > >> > >> > >> My super simple code is this: > >> > >> > >> > >> System.setProperty("s3.properties.location", > >> > >> "/path/to/s3.properties"); > >> > >> S3GeoTiffReader reader = new S3GeoTiffReader(new > >> > >> S3ImageInputStreamImpl("main://cogs/eu_dem_v22_itnord4326_cog512.tif")); > >> > >> GeneralParameterValue[] generalParameter = // omitting the creation of > >> > >> GP using the bounds values and resolution > >> > >> GridCoverage2D coverage2D = reader.read(generalParameter); > >> > >> > >> > >> Is the use of generalParameter the right way to address this? > >> > >> > >> > >> Thanks for any hint, > >> > >> Andrea > >> > >> > >> > >> > >> > >> _______________________________________________ > >> > >> GeoTools-GT2-Users mailing list > >> > >> GeoTools-GT2-Users@lists.sourceforge.net > >> > >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > >> > >> > >> _______________________________________________ > >> GeoTools-GT2-Users mailing list > >> GeoTools-GT2-Users@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users _______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users