Reputation: 45
I have two GeoDataFrames. One which is a street map of a City, and the other are coordinates of the NHTSA Crash Data.
I'm having trouble figuring out a method to convert from the LineString Type, which is the StreetMap to the Point Type, which is a geocoordinate.
Ultimately Matplot's scale is just way off, which plots things completely wrong.
So what am I missing to plot these things. Here are some sample Data Frames.
geometry
72 POINT (-88.73746 40.72734)
4093 POINT (-88.95345 40.53861)
7638 POINT (-88.99324 40.47142)
And the other dataframe
0 LINESTRING (903617.335 1487219.494, 903780.564...
1 LINESTRING (913845.303 1489995.746, 914731.553...
2 LINESTRING (909998.735 1489953.767, 911530.535...
I've looked at the shapely documentation, but being new to Geo work, I could use a boost.
UPDATE PLOT CODE. I thought i would also update my plot code, maybe I need to do something with the scale?
fig, ax = plt.subplots(figsize=(15,15))
street_map.plot(ax=ax, alpha=0.4, color='grey')
geo_df[geo_df['work_zone']=='None'].plot(ax=ax,
markersize=20,
color = 'orange',
marker='o',
label='None')
geo_df[geo_df['work_zone']=='Maintenance'].plot(ax=ax,
markersize=20,
color = 'red',
marker='^',
label='Maintenance')
plt.legend(prop={'size': 15});
Upvotes: 2
Views: 7137
Reputation: 7824
You have mixed CRS, so one of your data frames needs to be reprojected to match the other. As you LineString gdf is projected, I would use that CRS.
geo_df = geo_df.to_crs(street_map.crs) # thin line does the trick
fig, ax = plt.subplots(figsize=(15,15))
street_map.plot(ax=ax, alpha=0.4, color='grey')
geo_df[geo_df['work_zone']=='None'].plot(ax=ax,
markersize=20,
color = 'orange',
marker='o',
label='None')
geo_df[geo_df['work_zone']=='Maintenance'].plot(ax=ax,
markersize=20,
color = 'red',
marker='^',
label='Maintenance')
plt.legend(prop={'size': 15});
Upvotes: 1