Created
June 30, 2022 07:09
-
-
Save gerritjandebruin/87ca74346b487b47b23d738c87ee261e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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