简体   繁体   English

如何从方位角等距重新投影图像雷达,以显示在 openlayers 地图上

[英]How to reprojection image radar from Azimuthal Equidistant, to show on openlayers map

I am in the process of creating a weather map with atmospheric discharges and rainfall.我正在创建带有大气排放和降雨量的天气图。 I have access to places of atmospheric discharges and on the basis of this data generates a picture with mercator projection and display it on the mapbox map.我可以访问大气排放的地方,并根据这些数据生成带有墨卡托投影的图片并将其显示在 mapbox 地图上。 I have a problem with rainfall because I already have a picture in Azimuthal Equidistant projection and I can not display it on the mapbox, because mapbox does not support other projections than mercator我有降雨的问题,因为我已经有一张Azimuthal Equidistant projection的图片,我无法在mapbox上显示它,因为mapbox不支持除墨卡托以外的其他投影

So I changed the mapbox to openlayers and I have a code problem because nothing is displayed.所以我将地图框更改为 openlayers 并且我有一个代码问题,因为没有显示任何内容。 I do not know if I am doing well and asking for help.我不知道我是否做得很好并寻求帮助。 Even before switching to openlayers I wanted to convert this image to mercator projection in some way, but I failed because there is not much information on the internet and the picture was not in the right position.甚至在切换到 openlayers 之前,我想以某种方式将此图像转换为墨卡托投影,但我失败了,因为互联网上的信息不多,而且图片位置不正确。

My code:我的代码:

Image projection data:图像投影数据:

<projection lat_lr="48.000000" lat_ul="56.300000" type="aeqd" lon_lr="25.300000" size_x="800" size_y="800" lon_ul="11.600000">
    <lon_0>19.092600</lon_0>
    <lat_0>52.346900</lat_0>
    <ellps>+ellps=sphere</ellps>
</projection>

My javascript code in the website:我在网站上的 javascript 代码:

var centerLat = 52.346900;
var centerLon = 19.092600;
var source = "http://localhost/ol/2018120900400000dBR.sri_echoOnly.png";
var lat1 = 11.6;
var lon1 = 48.0;
var lat2 = 25.3;
var lon2 = 56.3;

proj4.defs("ESRI:54032","+proj=aeqd +lat_0=52.346900 +lon_0=19.092600 +x_0=800 +y_0=800 +ellps=sphere +datum=WGS84 +units=m +no_defs");
ol.proj.proj4.register(proj4);

var transformFrom = "ESRI:54032";
var transformTo = "EPSG:3857";

var center = ol.proj.transform([centerLat, centerLon], transformFrom, transformTo);


mapVar = new ol.Map({
    target: 'map',
    layers: [new ol.layer.Tile({source: new ol.source.OSM()})],
    view: new ol.View({
        center: ol.proj.fromLonLat([centerLon, centerLat]),
        zoom: 4
    })
});

var leftUp = ol.proj.transform([lat1, lon1], transformFrom, transformTo);
var downRight = ol.proj.transform([lat2, lon2], transformFrom, transformTo);

var extent =[leftUp[0],leftUp[1],downRight[0],downRight[1]];

var layer =new ol.layer.Image({
    source: new ol.source.ImageStatic({
        attributions: '',
        url: source,
        projection: transformTo,
        imageExtent: extent,
        imageSize: [800, 800]
    })
});
mapVar.addLayer(layer);

Please help.请帮忙。 I'd like to force the mapbox to work, but using openlayers will also be ok.我想强制 mapbox 工作,但使用 openlayers 也可以。 I'm sorry if I forgot something writing yet.如果我忘了写点什么,我很抱歉。

You had a combination of Lon and Lat values swapped and wrong projections for the transforms and the layer.您交换了 Lon 和 Lat 值的组合,并且变换和图层的投影错误。 Using a random png for a static image I got this setup to output the image in the expected position.对静态图像使用随机 png 我得到了这个设置以在预期位置输出图像。

    var lon1 = 11.6;
    var lat1 = 48.0;
    var lon2 = 25.3;
    var lat2 = 56.3;

    proj4.defs("ESRI:54032","+proj=aeqd +lat_0=52.346900 +lon_0=19.092600 +x_0=800 +y_0=800 +ellps=sphere +datum=WGS84 +units=m +no_defs");
    ol.proj.proj4.register(proj4);

    mapVar = new ol.Map({
        target: 'map',
        layers: [new ol.layer.Tile({source: new ol.source.OSM()})],
        view: new ol.View({
            center: ol.proj.fromLonLat([centerLon, centerLat]),
            zoom: 4
        })
    });

    var leftUp = ol.proj.fromLonLat([lon1, lat2], "ESRI:54032");
    var downRight = ol.proj.fromLonLat([lon2, lat1], "ESRI:54032");

    var extent = [leftUp[0], downRight[1], downRight[0], leftUp[1]]; 

    var layer =new ol.layer.Image({
        source: new ol.source.ImageStatic({
            attributions: '',
            url: source,
            projection: "ESRI:54032",
            imageExtent: extent
        })
    });
    mapVar.addLayer(layer);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM