[英]Distortion when viewing leaflet geojson
我一直在嘗試在瀏覽器中使用傳單查看一些gis文件。 當我在其他一些頁面(例如http://lsi.iiit.ac.in:8095/lsiviewer或http://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>
使用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中顯示正常:
您可以使用上述鏈接的工具將文件直接轉換為GeoJSON和WGS 84坐標系,因此您不再需要Shapefile.js。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.