Skip to content

Instantly share code, notes, and snippets.

@gerritjandebruin
Created June 30, 2022 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerritjandebruin/87ca74346b487b47b23d738c87ee261e to your computer and use it in GitHub Desktop.
Save gerritjandebruin/87ca74346b487b47b23d738c87ee261e to your computer and use it in GitHub Desktop.
from osgeo import ogr
import pandas as pd
import geopandas as gpd
def get_data(file):
ds = ogr.Open(file)
result = list()
for lyr in ds:
for feat in lyr:
geom = feat.GetGeometryRef()
if geom != None:
for i in range(0, geom.GetPointCount()):
lat, lon, att = geom.GetPoint(i)
result.append({'Latitude': lat, 'Longitude': lon, 'Attitude': att})
df = pd.DataFrame(result)
return gpd.GeoDataFrame(df, geometry=gpd.points_from_xy(df.Longitude, df.Latitude))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment