I try to add a buffer on a set of lines via the buffer
attribute of geopandas.
But by testing on a simple case (see code below) I realize that the size of the buffer is not kept according to the points latitude.
The buffer build at point A is well 2° but at point B is only 0.35° (checked via QGIS).
Could someone please explain to me how this buffer works under geopandas?
And if you have a solution to generate a buffer that is robust to the change of latitude I'm interested!
import geopandas as gpd
from shapely.geometry import LineString, Point
# 2 points creation
A = Point(0.0, 0.0)
B = Point(0.0, 80.0)
# Linestring creation
lines_geom = LineString([A, B])
crs = {'init': 'epsg:4326'} # WGS84 CRS
lines = gpd.GeoDataFrame(index=[0], crs=crs, geometry=[lines_geom])
# Buffer generation
lines_buffer_1deg = lines.buffer(1.0, resolution=1)
print(lines_buffer_1deg)
lines_buffer_1deg.to_file("test.shp")
As proposed in the comment I also tried with a projected CRS, EPSG:3395 world mercator with the same result (see code below and caption from QGIS).
import geopandas as gpd
from shapely.geometry import mapping, Polygon, LineString, Point
# 2 points creation
A = Point(0.0,0.0)
B = Point(0.0,9000000.0)
# Linestring creation
lines_geom = LineString([A,B])
crs = {'init': 'epsg:3395'}
lines = gpd.GeoDataFrame(index=[0], crs=crs, geometry=[lines_geom])
# Buffer generation
lines_buffer_100km = lines.buffer(100000.0,resolution=1)
print(lines_buffer_100km)
lines_buffer_100km.to_file("test.shp")