Skip to content

Instantly share code, notes, and snippets.

View mapcloud's full-sized avatar

Aquabiota Solutions AB mapcloud

View GitHub Profile
@nygeog
nygeog / csv-to-shapefile-geopandas.py
Last active November 25, 2023 09:47
Read a CSV with Pandas and set as GeoDataFrame with geopandas and save as Shapefile with fiona
import pandas as pd
from geopandas import GeoDataFrame
from shapely.geometry import Point
import fiona
df = pd.read_csv('data.csv')
geometry = [Point(xy) for xy in zip(df.x, df.y)]
crs = {'init': 'epsg:2263'} #http://www.spatialreference.org/ref/epsg/2263/
geo_df = GeoDataFrame(df, crs=crs, geometry=geometry)
@aculich
aculich / remove-empty-columns.csv
Last active May 16, 2024 06:18
remove-empty-columns
foo bar baz
a 1
b 2
c
4
e 5
@jeromer
jeromer / compassbearing.py
Last active February 21, 2024 13:31
compass bearing between two points in Python
# LICENSE: public domain
def calculate_initial_compass_bearing(pointA, pointB):
"""
Calculates the bearing between two points.
The formulae used is the following:
θ = atan2(sin(Δlong).cos(lat2),
cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong))