stud/II/Referatas/sinewave.py

30 lines
739 B
Python
Raw Normal View History

2020-05-26 11:39:05 +03:00
#!/usr/bin/python
2020-05-26 11:56:58 +03:00
from math import pi
2020-05-26 11:39:05 +03:00
from pyproj import CRS
import numpy as np
import geopandas as gpd
2020-05-26 12:28:32 +03:00
from shapely.geometry import LineString, MultiLineString
2020-05-26 11:39:05 +03:00
2020-05-26 11:56:58 +03:00
INTERVAL = 0.1
2020-05-26 11:39:05 +03:00
TAIL_LEN = 4
SINE_LEN = 7
2020-05-26 11:56:58 +03:00
TAILS = np.zeros(int(TAIL_LEN / INTERVAL))
2020-05-26 11:39:05 +03:00
def main():
2020-05-26 11:56:58 +03:00
sin_range = np.arange(-pi/4, SINE_LEN, INTERVAL)
2020-05-26 12:11:41 +03:00
amplitude = (np.sin(sin_range * pi / 2) + 1)*2
2020-05-26 11:56:58 +03:00
y = np.concatenate([TAILS, amplitude, TAILS])
x = np.arange(-TAIL_LEN - pi/4, SINE_LEN + TAIL_LEN, INTERVAL)
2020-05-26 12:28:32 +03:00
lines = LineString(zip(x, y))
geom = MultiLineString([lines])
2020-05-26 11:39:05 +03:00
df = gpd.GeoDataFrame(crs=CRS(3346))
df['geometry'] = None
df.loc[0, 'geometry'] = geom
2020-05-26 12:28:32 +03:00
df.to_file("sinewave.gpkg", driver='GPKG')
2020-05-26 11:39:05 +03:00
if __name__ == '__main__':
main()