TransWikia.com

Extract longitude and latitude coordinates into separate columns with GeoPandas geometry

Geographic Information Systems Asked by graphboy on October 14, 2020

I am currently working on an Exploratory Data Analysis for the NYC taxi dataset. Since the new datasets had location ID’s instead of long and lat coordinates.

sf = gpd.read_file(r"shape/taxi_zones.shp")
zone = pd.read_csv(r"Datasets/taxi+_zone_lookup.csv")

# Convert geometry to long/lat 
sf['geometry'] = sf['geometry'].to_crs("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")

gdf = gpd.GeoDataFrame(pd.merge(yellowtaxidf, sf, left_on='PULocationID', right_on='LocationID')).drop('PULocationID',axis=1)

attributes showing WKT polygon

As you can see, there is two pairs of coordinates in the geometry feature.

I am wondering if there is a way to extract each pair into a separate column for pick up long/lat and drop off long/lat so that I can perform several geospatial data visualizations.

Also is my understanding that the first pair of coordinates represent pick up and the second represents drop off coordinates correct?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP