You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Examples in Jupyter-notebook demos linked here fail with "AttributeError: 'DataFrame' object has no attribute 'crs'"
I tested the following examples and they all failed with this exact error:
Macao, China (circle plot)
Barcelona, Spain (square plot with rounded edges)
Barcelona, Spain (vsketch mode for pen plotter)
It outputs the ShapelyDeprecationWarning just like in another issue.
ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0.
Use the `geoms` property to access the constituent parts of a multi-part geometry.
Traceback for Macao, China (circle plot):
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [3], in <cell line: 3>()
1 fig, ax = plt.subplots(figsize = (12, 12), constrained_layout = True)
----> 3 layers = plot(
4 'Praça Ferreira do Amaral, Macau', radius = 1100,
5 ax = ax,
6 layers = {
7 'perimeter': {},
8 'streets': {
9 'custom_filter': '["highway"~"motorway|trunk|primary|secondary|tertiary|residential|service|unclassified|pedestrian|footway"]',
10 'width': {
11 'motorway': 5,
12 'trunk': 5,
13 'primary': 4.5,
14 'secondary': 4,
15 'tertiary': 3.5,
16 'residential': 3,
17 'service': 2,
18 'unclassified': 2,
19 'pedestrian': 2,
20 'footway': 1,
21 }
22 },
23 'building': {'tags': {'building': True, 'landuse': 'construction'}, 'union': False},
24 'water': {'tags': {'natural': ['water', 'bay']}},
25 'green': {'tags': {'landuse': 'grass', 'natural': ['island', 'wood'], 'leisure': 'park'}},
26 'forest': {'tags': {'landuse': 'forest'}},
27 'parking': {'tags': {'amenity': 'parking', 'highway': 'pedestrian', 'man_made': 'pier'}}
28 },
29 drawing_kwargs = {
30 'background': {'fc': '#F2F4CB', 'ec': '#dadbc1', 'hatch': 'ooo...', 'zorder': -1},
31 'perimeter': {'fc': '#F2F4CB', 'ec': '#dadbc1', 'lw': 0, 'hatch': 'ooo...', 'zorder': 0},
32 'green': {'fc': '#D0F1BF', 'ec': '#2F3737', 'lw': 1, 'zorder': 1},
33 'forest': {'fc': '#64B96A', 'ec': '#2F3737', 'lw': 1, 'zorder': 1},
34 'water': {'fc': '#a1e3ff', 'ec': '#2F3737', 'hatch': 'ooo...', 'hatch_c': '#85c9e6', 'lw': 1, 'zorder': 2},
35 'parking': {'fc': '#F2F4CB', 'ec': '#2F3737', 'lw': 1, 'zorder': 3},
36 'streets': {'fc': '#2F3737', 'ec': '#475657', 'alpha': 1, 'lw': 0, 'zorder': 3},
37 'building': {'palette': ['#FFC857', '#E9724C', '#C5283D'], 'ec': '#2F3737', 'lw': .5, 'zorder': 4},
38 },
39
40 osm_credit = {'color': '#2F3737'}
41 )
43 plt.savefig('../prints/macao.png')
44 plt.savefig('../prints/macao.svg')
File ~/.conda/envs/maps/lib/python3.9/site-packages/prettymaps/draw.py:230, in plot(query, backup, postprocessing, radius, layers, drawing_kwargs, osm_credit, figsize, ax, title, vsketch, x, y, scale_x, scale_y, rotation)
223 base_kwargs = {
224 "perimeter": query
225 if query_mode == "polygon"
226 else get_perimeter(query, by_osmid=query_mode == "osmid")
227 }
229 # Fetch layers
--> 230 layers = {
231 layer: get_layer(
232 layer, **base_kwargs, **(kwargs if type(kwargs) == dict else {})
233 )
234 for layer, kwargs in layers.items()
235 }
237 # Apply transformation to layers (translate & scale)
238 layers = transform(layers, x, y, scale_x, scale_y, rotation)
File ~/.conda/envs/maps/lib/python3.9/site-packages/prettymaps/draw.py:231, in <dictcomp>(.0)
223 base_kwargs = {
224 "perimeter": query
225 if query_mode == "polygon"
226 else get_perimeter(query, by_osmid=query_mode == "osmid")
227 }
229 # Fetch layers
230 layers = {
--> 231 layer: get_layer(
232 layer, **base_kwargs, **(kwargs if type(kwargs) == dict else {})
233 )
234 for layer, kwargs in layers.items()
235 }
237 # Apply transformation to layers (translate & scale)
238 layers = transform(layers, x, y, scale_x, scale_y, rotation)
File ~/.conda/envs/maps/lib/python3.9/site-packages/prettymaps/fetch.py:380, in get_layer(layer, **kwargs)
378 # Fetch streets or railway
379 if layer in ["streets", "railway", "waterway"]:
--> 380 return get_streets(**kwargs, layer=layer)
381 # Fetch Coastline
382 elif layer == "coastline":
File ~/.conda/envs/maps/lib/python3.9/site-packages/prettymaps/fetch.py:293, in get_streets(perimeter, point, radius, layer, width, custom_filter, buffer, retain_all, circle, dilate, truncate_by_edge)
285 streets = ox.graph_from_point(
286 point,
287 dist=radius + dilate + buffer,
(...)
290 truncate_by_edge = truncate_by_edge,
291 )
292 crs = ox.graph_to_gdfs(streets, nodes=False).crs
--> 293 streets = ox.project_graph(streets)
294 # Compute perimeter from point & CRS
295 perimeter = get_boundary(point, radius, crs, circle=circle, dilate=dilate)
File ~/.conda/envs/maps/lib/python3.9/site-packages/osmnx/projection.py:144, in project_graph(G, to_crs)
141 if "simplified" in G.graph and G.graph["simplified"]:
142 # if graph has previously been simplified, project the edge geometries
143 gdf_edges = utils_graph.graph_to_gdfs(G, nodes=False, fill_edge_geometry=True)
--> 144 gdf_edges_proj = project_gdf(gdf_edges, to_crs=gdf_nodes_proj.crs)
145 else:
146 # if not, you don't have to project these edges because the nodes
147 # contain all the spatial data in the graph (unsimplified edges have
148 # no geometry attributes)
149 gdf_edges_proj = utils_graph.graph_to_gdfs(G, nodes=False, fill_edge_geometry=False).drop(
150 columns=["geometry"]
151 )
File ~/.conda/envs/maps/lib/python3.9/site-packages/pandas/core/generic.py:5575, in NDFrame.__getattr__(self, name)
5568 if (
5569 name not in self._internal_names_set
5570 and name not in self._metadata
5571 and name not in self._accessors
5572 and self._info_axis._can_hold_identifiers_and_holds_name(name)
5573 ):
5574 return self[name]
-> 5575 return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'crs'
Examples in Jupyter-notebook demos linked here fail with "AttributeError: 'DataFrame' object has no attribute 'crs'"
I tested the following examples and they all failed with this exact error:
It outputs the ShapelyDeprecationWarning just like in another issue.
Traceback for Macao, China (circle plot):
Python version
!python --version
Python dependencies
!pip freeze
Please update the examples
The text was updated successfully, but these errors were encountered: