iGN5117 commented on code in PR #913: URL: https://github.com/apache/sedona/pull/913#discussion_r1272567800
########## core/src/test/resources/Chicago_Crimes.csv: ########## Review Comment: The size of the dataset is 3.1 MB. I wanted to keep a dense dataset so as to render a good scatterplot ########## python/sedona/maps/SedonaPyDeck.py: ########## @@ -0,0 +1,262 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import pydeck as pdk +from sedona.maps.SedonaMapUtils import SedonaMapUtils + + +class SedonaPyDeck: + + # User Facing APIs + @classmethod + def create_choropleth_map(cls, df, fill_color=None, plot_col=None, initial_view_state=None, map_style=None, + map_provider=None, elevation_col=0): + """ + Create a pydeck map with a choropleth layer added + :param elevation_col: Optional elevation for the polygons + :param df: SedonaDataFrame to plot on the choropleth map. + :param fill_color: color scheme to fill the map with. + If no color scheme is given, a default color scheme is created using the 'plot_col' column as the quantizing column + :param plot_col: Column to be used to create a default color scheme. If fill_color is provided, this parameter is ignored. + :param initial_view_state: + :param map_style: + :param map_provider: + :return: A pydeck Map object with choropleth layer added: + """ + + if initial_view_state is None: + gdf = SedonaPyDeck._prepare_df_(df, add_coords=True) + initial_view_state = pdk.data_utils.compute_view(gdf['coordinate_array_sedona']) + else: + gdf = SedonaPyDeck._prepare_df_(df) + + if fill_color is None: + fill_color = SedonaPyDeck._create_default_fill_color_(gdf, plot_col) + + choropleth_layer = pdk.Layer( + 'GeoJsonLayer', # `type` positional argument is here + data=gdf, + auto_highlight=True, + get_fill_color=fill_color, + opacity=1.0, + get_elevation=elevation_col, + stroked=False, + extruded=True, + wireframe=True, + pickable=True + ) + + map_ = pdk.Deck(layers=[choropleth_layer], initial_view_state=initial_view_state) + SedonaPyDeck._set_optional_parameters_(p_map=map_, map_style=map_style, map_provider=map_provider) + return map_ + + @classmethod + def create_geometry_map(cls, df, fill_color="[85, 183, 177, 255]", line_color="[85, 183, 177, 255]", + elevation_col=0, initial_view_state=None, + map_style=None, map_provider=None): + """ + Create a pydeck map with a GeoJsonLayer added for plotting given geometries. + :param line_color: + :param df: SedonaDataFrame with polygons + :param fill_color: Optional color for the plotted polygons + :param elevation_col: Optional column/numeric value to determine elevation for plotted polygons + :param initial_view_state: optional initial view state of the pydeck map + :param map_style: optional map_style of the pydeck map + :param map_provider: optional map_provider of the pydeck map + :return: A pydeck map with a GeoJsonLayer map added + """ + geometry_col = SedonaMapUtils.__get_geometry_col__(df) + gdf = SedonaPyDeck._prepare_df_(df, geometry_col=geometry_col) + geom_type = gdf[geometry_col][0].geom_type + # if SedonaMapUtils.__is_geom_collection__(geom_type): Review Comment: Done ########## python/sedona/maps/SedonaKepler.py: ########## Review Comment: Yes the documentation is already updated. Removed the parameter from the docstring now -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
