[OpenLayers-Users] COG and basemap
Jakob Miksch
jakob at meggsimum.de
Fri May 27 03:32:31 PDT 2022
Hi Marc,
If I leave out extent, the COG is displayed on a wrong place. (Should be
Buonos Aires, but is placed in France).
Increasing the extent shows an visual effect, but still causes the OSM
map to be placed on the wrong place.
Meanwhile, I made it work inspired by
https://stackoverflow.com/a/70116989 and
https://codesandbox.io/s/cog-forked-tmswq?file=/main.js
It seems I needed to define the projection using Proj4js and not with OL
directly.
One learning is that apparently COGs cannot be reprojected by OL.
(Please correct me if I am wrong)
Initially I tried to create something similar as here:
https://cholmes.github.io/cog-map/
This app displays COGs in any CRS on WebMercator, BUT it actually uses
the backend service https://tiles.rdnt.io/ for proxying and reprojection.
Best,
Jakob
importGeoTIFFfrom'ol/source/GeoTIFF.js';
importMapfrom'ol/Map.js';
importWebGLTileLayerfrom'ol/layer/WebGLTile.js';
importViewfrom'ol/View.js';
importTileLayerfrom'ol/layer/Tile';
importOSMfrom'ol/source/OSM';
importproj4from"proj4";
import{ register} from"ol/proj/proj4";
import{ fromLonLat} from"ol/proj";
constepsgCode= "EPSG:32721";
proj4.defs(epsgCode,"+proj=utm +zone=21 +south +datum=WGS84 +units=m
+no_defs");
register(proj4);
constcogSource= newGeoTIFF({
sources:[
{
url:'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/21/H/UB/2021/9/S2B_21HUB_20210915_0_L2A/TCI.tif',
},
],
});
constcogLayer= newWebGLTileLayer({
source:cogSource,
});
newMap({
target:'map',
layers:[
newTileLayer({
source:newOSM()
}),
cogLayer
],
view:newView({
projection:epsgCode,
center:fromLonLat([-58.205,-34.833], epsgCode),
zoom:10,
}),
});
Am 27.05.22 um 10:35 schrieb Marc Jansen:
>
> Hi Jakob,
>
> what happens if you change the extent of the view (leave it out,
> configure it to sth. bigger that the extent of the source)?
>
> Just a wild guess.
>
> Best
>
> Marc
>
>
> Am 27.05.22 um 10:18 schrieb Jakob Miksch:
>> Dear list,
>>
>> I am trying to display COGs in OpenLayers. This works well for single
>> images. However, I would like to add more more layers like a basemap.
>> But then the view is blocked to the extent of the COG. See my example
>> below.
>>
>> Is there a way to overlay a COG on a basemap and still be able to
>> zoom and pan wherever I want and not being restricted by the extent
>> of the COG?
>>
>> best regards,
>> Jakob
>>
>> importGeoTIFFfrom'ol/source/GeoTIFF.js';
>> importMapfrom'ol/Map.js';
>> importProjectionfrom'ol/proj/Projection.js';
>> importWebGLTileLayerfrom'ol/layer/WebGLTile.js';
>> importViewfrom'ol/View.js';
>> import{getCenter} from'ol/extent.js';
>> importTileLayerfrom'ol/layer/Tile';
>> importOSMfrom'ol/source/OSM';
>> constprojection= newProjection({
>> code:'EPSG:32721',
>> units:'m',
>> });
>> // metadata from
>> https://s3.us-west-2.amazonaws.com/sentinel-cogs/sentinel-s2-l2a-cogs/21/H/UB/2021/9/S2B_21HUB_20210915_0_L2A/S2B_21HUB_20210915_0_L2A.json
>> constsourceExtent= [300000, 6090260, 409760, 6200020];
>> constcogSource= newGeoTIFF({
>> sources:[
>> {
>> url:'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/21/H/UB/2021/9/S2B_21HUB_20210915_0_L2A/TCI.tif',
>> },
>> ],
>> });
>> constcogLayer= newWebGLTileLayer({
>> source:cogSource,
>> });
>> newMap({
>> target:'map',
>> layers:[
>> newTileLayer({
>> source:newOSM()
>> }),
>> cogLayer
>> ],
>> view:newView({
>> projection:projection,
>> center:getCenter(sourceExtent),
>> extent:sourceExtent,
>> zoom:1,
>> }),
>> });
>> --
>> Jakob Miksch
>> Geoinformatiker
>>
>> meggsimum - Büro für Geoinformatik
>> Christian Mayer
>> Schillerstr. 2a | 67112 Mutterstadt
>> info at meggsimum.de |www.meggsimum.de
>> T 06231 - 6298988 |
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/openlayers-users
> --
> Marc Jansen
> — Geschäftsführer —
>
> terrestris GmbH & Co. KG
> Kölnstraße 99
> 53111 Bonn
>
> Tel: +49 (0)228 / 96 28 99 -53
> Fax: +49 (0)228 / 96 28 99 -57
>
> Email:jansen at terrestris.de
> Web:https://www.terrestris.de
>
> Amtsgericht Bonn, HRA 6835
> Komplementärin: terrestris Verwaltungsgesellschaft mbH
> vertreten durch: Torsten Brassat, Marc Jansen
>
> Informationen über Ihre gespeicherten Daten finden Sie auf unserer Homepage unter folgendem Link:https://www.terrestris.de/datenschutzerklaerung/
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/openlayers-users
--
Jakob Miksch
Geoinformatiker
meggsimum - Büro für Geoinformatik
Christian Mayer
Schillerstr. 2a | 67112 Mutterstadt
info at meggsimum.de |www.meggsimum.de
T 06231 - 6298988 |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20220527/328d77e9/attachment-0001.htm>
More information about the Users
mailing list