Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13891

Python Geopandas unable to convert latitude longitude to points

$
0
0

I have a dataframe from a CSV file with fields for latitude and longitude. I want to convert the df to a geodataframe of points with the lat and lon fields. When I map the points, the points show up in the wrong place (i.e., middle of the ocean).

I checked my gdf against another version of the gdf and confirmed that the lat/long fields and geometry fields are the same for observations with the same ID (this correct gdf is missing observations so I can't use it.) What am I missing? Thanks

Here is my code:

geometry = [Point(xy) for xy in zip(df['lon'], df['lat'])]new_gdf = gpd.GeoDataFrame(df,crs='EPSG:4326',geometry=geometry)new_gdf.to_crs('EPSG:2229',inplace=True) # convert to projection that I want to map innew_gdf.plot()

Viewing all articles
Browse latest Browse all 13891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>