Reputation: 967
I have a problem to change my csv
data from Latlong (degree) to UTM coordinates.
this is example data:
Date Time Latitude Longitude
23/08/2018 9:00:00 -5.1661 119.4543
23/08/2018 9:00:01 -5.166 119.4544
23/08/2018 9:00:02 -5.1659 119.4544
23/08/2018 9:00:07 -5.1657 119.4546
23/08/2018 9:00:42 -5.162 119.4567
23/08/2018 9:00:43 -5.1614 119.4567
23/08/2018 9:00:44 -5.16 119.4548
and I tried this way to change the coordinate
df = pd.read_csv("data.csv")
s = gpd.GeoSeries([Point(x,y) for x, y in zip(df['Longitude'], df['Latitude'])])
geo_df = gpd.GeoDataFrame(df[['Date','Time']], geometry=s)
geo_df.crs = {'init': 'epsg:4326'}
geo_df = geo_df.to_crs({'init': 'epsg:32750'})
geo_df
but I got TypeError: must be real number, not str
any idea to solve the problem?
Upvotes: 0
Views: 638
Reputation: 4526
Maybe this helps
geometry = [Point(xy) for xy in zip(df.Latitude, df.Longitude)]
df = df.drop(['Latitude', 'Longitude'], axis=1)
crs = {'init': 'epsg:4326'}
gdf = gpd.GeoDataFrame(df, crs=crs, geometry=geometry)
gdf = gdf.to_crs({'init': 'epsg:32750'})
check here and here for more details
Upvotes: 1