jiayuasu commented on code in PR #913:
URL: https://github.com/apache/sedona/pull/913#discussion_r1271862405


##########
core/src/test/resources/813_buildings_test.csv:
##########


Review Comment:
   What is the license of this data file? Please show me the url to its license.



##########
docs/tutorial/sql.md:
##########
@@ -509,26 +509,104 @@ There are lots of other functions can be combined with 
these queries. Please rea
 
 ==Sedona >= 1.5.0==

Review Comment:
   No need to add Sedona >= 1.5.0 here. Sedona website has a version selector 
that shows docs for a specific version.



##########
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:
   Please remove commented code unless really needed



##########
core/src/test/resources/Chicago_Crimes.csv:
##########


Review Comment:
   What is the size of this test data? We usually only include a very small 
chunk of data to the source code repo.



##########
core/src/test/resources/Chicago_Crimes.csv:
##########


Review Comment:
   What is the license of this data file? Please show me the url to its license.



##########
python/sedona/maps/SedonaKepler.py:
##########


Review Comment:
   Since you also updated the implementation of SedonaKepler here, do you need 
to update its doc?



##########
docs/tutorial/sql.md:
##########
@@ -509,26 +509,104 @@ There are lots of other functions can be combined with 
these queries. Please rea
 
 ==Sedona >= 1.5.0==
 
+### SedonaPyDeck
+Spatial query results can be visualized in Jupyter lab/notebook using 
SedonaPyDeck.
+
+SedonaPyDeck exposes APIs to create interactive map visualizations using 
[pydeck](https://pydeck.gl/index.html#) based on [deck.gl](https://deck.gl/)
+
+
+#### Creating a Choropleth map using SedonaPyDeck
+
+SedonaPyDeck exposes a create_choropleth_map API which can be used to 
visualize a choropleth map out of the passed SedonaDataFrame containing 
polygons with an observation:
+
+```python
+def create_choropleth_map(cls, df, fill_color=None, plot_col=None, 
initial_view_state=None, map_style=None, map_provider=None):
+```
+
+The parameter `fill_color` can be given a list of RGB/RGBA values, or a string 
that contains RGB/RGBA values based on a column.
+
+For example, all these are valid values of fill_color:
+```python
+fill_color=[255, 12, 250]
+fill_color=[0, 12, 250, 255]
+fill_color='[0, 12, 240, AirportCount * 10]' ## AirportCount is a column in 
the passed df
+```
+
+Instead of giving a `fill_color` parameter, a 'plot_col' can be passed which 
specifies the column to decide the choropleth. 
+SedonaPyDeck then creates a default color scheme based on the values of the 
column passed
+
+Optionally, parameters `initial_view_state`, `map_style`, `map_provider` can 
be passed to configure the map as per user's liking.
+More details on the parameters and their default values can be found on the 
pydeck website.
+
+#### Creating a Polygon map using SedonaPyDeck

Review Comment:
   Is SedonaPyDeck supporting all types of geometries? And what is the 
difference between `create_geometry_map` and `create_scatterplot_map` when it 
comes to `point` data?



-- 
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]

Reply via email to