观看传单geojson时的失真

时间:2017-11-02 18:06:05

标签: javascript leaflet gis shapefile

我一直在尝试使用我的浏览器中的传单查看一些gis文件。当我在http://lsi.iiit.ac.in:8095/lsiviewerhttp://mapshaper.org/等其他页面中查看它们时,它们会正确显示。但是,当我在传单中查看它们时,文件不会显示 - 它们会被扭曲。

这是shapefile档案: https://drive.google.com/drive/folders/0BxYlN9E2saSzSnEwMHVoRGhBYTQ?usp=sharing

以下是形状显示的“好”和“坏”方式的2个屏幕截图: https://drive.google.com/drive/folders/1eH89girZ7uGEos87SCY-t26IaWdauSc3?usp=sharing

我的代码:

import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import * as shp from 'shpjs';
import * as L from 'leaflet';

@Component({
  selector: 'page-oportunidaddetalles',
  templateUrl: 'oportunidaddetalles.html',
})
export class OportunidaddetallesPage {

  constructor(public navCtrl: NavController, public navParams: NavParams) {
  }

  ionViewDidLoad() {

    var map = L.map('map', {
        center: [51.505, -0.09],
        zoom: 13
    });


    shp("./assets/my/RETINA").then(function(geojson){
      L.geoJSON(geojson).addTo(map);
  	});


    }

}
#map{
    position: relative !important;
    height: 1200px;
    width: 900px;
  }
<!--this is from the ionic page, so it's just a div-->
<div id="map">

</div>

1 个答案:

答案 0 :(得分:1)

使用https://mygeodata.cloud/converter/shp-to-geojson之类的转换工具检查您的SHP文件,它似乎使用 Belge 1972 / Belgian Lambert 72(EPSG:31370)坐标系。

您使用的库Shapefile.js(即npm包"shpjs")似乎期望*.dbf文件中的此投影信息在您的数据中缺失。

将您的SHP文件转换为 WGS 84(EPSG:4326)后,它在Leaflet中显示正常:

Screenshot correct shapes

您可以使用上面链接的工具将您的文件直接转换为GeoJSON和WGS 84坐标系,这样您就不再需要Shapefile.js。