PHP-将xy.shp坐标转换为谷歌地图lat/lng
我正在开发一个web应用程序,其中可以加载.shp文件。其想法是识别该文件,然后在谷歌地图中显示每个多边形。我可以用php读取形状文件。问题是我不知道如何将.shp中使用的坐标系转换为可以识别谷歌地图进行地图操作的坐标系。以下是.shp文件的一些坐标以及该文件中使用的坐标系: 坐标系(.prj文件): 2.上海医药记录:PHP-将xy.shp坐标转换为谷歌地图lat/lng,php,google-maps,coordinates,shapefile,Php,Google Maps,Coordinates,Shapefile,我正在开发一个web应用程序,其中可以加载.shp文件。其想法是识别该文件,然后在谷歌地图中显示每个多边形。我可以用php读取形状文件。问题是我不知道如何将.shp中使用的坐标系转换为可以识别谷歌地图进行地图操作的坐标系。以下是.shp文件的一些坐标以及该文件中使用的坐标系: 坐标系(.prj文件): 2.上海医药记录: Record number: 1 Array ( [bounding_box] => Array ( [xmin] =&g
Record number: 1
Array
(
[bounding_box] => Array
(
[xmin] => 2645165.87317
[xmax] => 2645166.87317
[ymin] => 1132483.62903
[ymax] => 1132484.62903
)
[numparts] => 1
[parts] => Array
(
[0] => Array
(
[numrings] => 1
[rings] => Array
(
[0] => Array
(
[numpoints] => 5
[points] => Array
(
[0] => Array
(
[x] => 2645165.87317
[y] => 1132484.62903
)
[1] => Array
(
[x] => 2645166.87317
[y] => 1132484.62903
)
[2] => Array
(
[x] => 2645166.87317
[y] => 1132483.62903
)
[3] => Array
(
[x] => 2645165.87317
[y] => 1132483.62903
)
[4] => Array
(
[x] => 2645165.87317
[y] => 1132484.62903
)
)
)
)
)
)
[wkt] => POLYGON((2645165.87317 1132484.62903, 2645166.87317 1132484.62903, 2645166.87317 1132483.62903, 2645165.87317 1132483.62903, 2645165.87317 1132484.62903)))
Array
(
[_deleted] =>
[ID] => 1
[red] => 58.818
[Comment] =>
[Rate] => 0.000
)
Record 2 [...]
注意:为了读取.shp文件,我使用gasparesganga/php形状文件库,您可以使用库proj4ppp来重新投影坐标
$proj4 = new Proj4php();
// Your initial projection information from your .prj file
$srcProj = new Proj('LOCAL_CS["CH1903+ / LV95",UNIT["metre",1,AUTHORITY["EPSG","9001"]]]', $proj4);
// WGS84 (for google map)
$dstProj = new Proj('EPSG:4326', $proj4);
// Your original point
$srcPoint = new Point(2645165.87317, 1132484.62903, $srcProj);
// Create your new point in WGS84 projection
$dstPoint = $proj4->transform($dstProj, $srcPoint);
您正在寻找的术语可能是“reproject”,我不确定PHP中有哪些工具。您需要从瑞士坐标系(?)重新投影到投影的WGS84坐标,另请参见
$proj4 = new Proj4php();
// Your initial projection information from your .prj file
$srcProj = new Proj('LOCAL_CS["CH1903+ / LV95",UNIT["metre",1,AUTHORITY["EPSG","9001"]]]', $proj4);
// WGS84 (for google map)
$dstProj = new Proj('EPSG:4326', $proj4);
// Your original point
$srcPoint = new Point(2645165.87317, 1132484.62903, $srcProj);
// Create your new point in WGS84 projection
$dstPoint = $proj4->transform($dstProj, $srcPoint);