无法使用 GeoPandas 正确旋转点
Cant correctly rotate point using GeoPandas
我的Python代码:
from geopandas import GeoSeries
from shapely.geometry import Point
WGS84 = {'init': 'epsg:4326'}
p1 = (41.8121843, 45.2178516,)
p2 = (41.8124878, 45.2177536,)
point2 = Point(p2)
s2 = GeoSeries(point2, crs=WGS84)
rotated = s2.rotate(90, p1) # Try to rotate p2 around p1
print(rotated) # 41.8122823 45.2181551
我的JS代码(Turf.js):
var p1 = [41.8121843, 45.2178516];
var p2 = [41.8124878, 45.2177536];
var l = turf.lineString( [p1, p2] );
L.geoJson(l, {style: {color: '#0000ff', fillOpacity: 1, fillColor: '#0000ff', opacity: 1}}).addTo(map);
// Rotate line around p1
var trufRotated = turf.transformRotate(l, -90, {pivot: p1});
L.geoJson(trufRotated, {style: {color: '#ff0000'}}).addTo(map);
插图。蓝色是原始线。红色是使用 Turf.js 旋转的线(确定)。绿色是使用 GeoPandas 旋转的线(不正确):
使用 geopandas 旋转的绿线有错误的偏移量。可能是投影的问题,但我不知道怎么解决。
我的问题是如何使用 GeoPandas 正确旋转?
已解决。感谢@PaulH。我需要在 Mercator 中进行旋转并在 lon/lat:
中再次进行翻译
WGS84 = {'init': 'epsg:4326'}
MERC = {'init': 'epsg:3857'}
p1 = (41.8121843, 45.2178516,)
p2 = (41.8124878, 45.2177536,)
point1 = Point(p1)
point2 = Point(p2)
s1 = GeoSeries(point1, crs=WGS84)
s2 = GeoSeries(point2, crs=WGS84)
s11 = s1.to_crs(MERC)
s22 = s2.to_crs(MERC)
rotated = s22.rotate(90, s11[0])
rotated = rotated.to_crs(WGS84)
print(rotated)
我的Python代码:
from geopandas import GeoSeries
from shapely.geometry import Point
WGS84 = {'init': 'epsg:4326'}
p1 = (41.8121843, 45.2178516,)
p2 = (41.8124878, 45.2177536,)
point2 = Point(p2)
s2 = GeoSeries(point2, crs=WGS84)
rotated = s2.rotate(90, p1) # Try to rotate p2 around p1
print(rotated) # 41.8122823 45.2181551
我的JS代码(Turf.js):
var p1 = [41.8121843, 45.2178516];
var p2 = [41.8124878, 45.2177536];
var l = turf.lineString( [p1, p2] );
L.geoJson(l, {style: {color: '#0000ff', fillOpacity: 1, fillColor: '#0000ff', opacity: 1}}).addTo(map);
// Rotate line around p1
var trufRotated = turf.transformRotate(l, -90, {pivot: p1});
L.geoJson(trufRotated, {style: {color: '#ff0000'}}).addTo(map);
插图。蓝色是原始线。红色是使用 Turf.js 旋转的线(确定)。绿色是使用 GeoPandas 旋转的线(不正确):
使用 geopandas 旋转的绿线有错误的偏移量。可能是投影的问题,但我不知道怎么解决。
我的问题是如何使用 GeoPandas 正确旋转?
已解决。感谢@PaulH。我需要在 Mercator 中进行旋转并在 lon/lat:
中再次进行翻译WGS84 = {'init': 'epsg:4326'}
MERC = {'init': 'epsg:3857'}
p1 = (41.8121843, 45.2178516,)
p2 = (41.8124878, 45.2177536,)
point1 = Point(p1)
point2 = Point(p2)
s1 = GeoSeries(point1, crs=WGS84)
s2 = GeoSeries(point2, crs=WGS84)
s11 = s1.to_crs(MERC)
s22 = s2.to_crs(MERC)
rotated = s22.rotate(90, s11[0])
rotated = rotated.to_crs(WGS84)
print(rotated)