I have a global dataset of earthquakes, I want to do some buffering around them. Having the earthquake dataset in the layer "query" and having a polygonlayer called "jordskjelvbuffer", I ran the following script:
quakelayer = 'query'
bufferlayer = 'jordskjelvbuffer'
bufferdist=100
quakes = QgsProject.instance().mapLayersByName(quakelayer)[0]
layer = QgsProject.instance().mapLayersByName(bufferlayer)[0]
feature = QgsFeature()
pnt=QgsGeometry.fromPointXY(QgsPointXY(0,0))
provider = layer.dataProvider()
layer.startEditing()
outcrs=QgsCoordinateReferenceSystem("EPSG:4326")
for quake in quakes.getFeatures():
buffer=pnt.buffer(bufferdist*1000,5)
geom = quake.geometry()
point = geom.asPoint()
lat = point.y()
lon = point.x()
projstring = f"PROJ:+proj=aeqd +lat_0={lat} +lon_0={lon}"
crs = QgsCoordinateReferenceSystem(projstring)
xform = QgsCoordinateTransform(crs,outcrs,QgsProject.instance())
buffer.transform(xform)
feature.setGeometry(buffer)
provider.addFeatures( [feature] )
layer.commitChanges()
This is making a circle bufferdist * 1000 meters at 0,0 in a orthographic projection centered at each point and then reprojecting that circle into WGS84 before adding it to my buffer data set. (https://gis.stackexchange.com/a/49390/10123 suggested the projection to use)
This works well, except for those points in which the buffer is crossing the antimeridian at 180 degrees. In which case the buffers will "wrap around" over my map. How can I avoid this?
Is it possible to tell the visualisation to do what I want or is there some way of splitting the buffers along the antimeridian?