Spatial analytics on Apache Superset

Spatial analytics on Apache Superset

Apache superset offers deck.gl spatial visualizations. Here are a set of examples possible: deck.gl Demo (datatest.ch)

We don’t have to store data in a spatial database like PostGIS to do spatial analytics on Superset.

For spatial charts like scatter plots, heatmaps, screen grids, arcs and point clusters, all we need are two floating point columns in our relational database (or a CSV upload/Google Sheets Connector): Latitude and Longitude.

Heatmaps and Screen grids

For charts like Choropleths and Paths we will have to convert the polygon and lines into a specific format: [[lon1, lat1], [lon2, lat2]…..] (List of polygon vertices)

Here is a small code snippet to convert a Polygon layer (GeoJSON) to a CSV with a text column containing the polygon vertices

gdf = gpd.read_file("polygons.geojson")

# Function to convert geometry to text
def geometry_to_text(geom):
    coords = list(geom.exterior.coords) if geom.geom_type == 'Polygon' else list(geom.coords)
    return str([[lon, lat] for lon, lat in coords])

# Apply the function to create a new column
gdf['polygons'] = gdf['geometry'].apply(geometry_to_text)

gdf.drop('geometry', axis=1).to_csv('polygons.csv')        

Upload this CSV into any relational database and connect it to Superset. When building a choropleth, we can choose this polygon vertices column.


Choropleths

Multiple spatial layers can be overlaid as well

Overlaid a scatter plot on a screengrid

The view port of the map can also be modified. Pitch and Bearing can be changed to give a 3D perspective.

All of it without having a spatial extension to your database!

要查看或添加评论,请登录

Sai Krishna Dammalapati的更多文章

  • Datafication of Indian court judgments | Part-2

    Datafication of Indian court judgments | Part-2

    I worked on the datafication of Indian court judgments two years ago. I detailed that work here: Exploring the…

  • LogProbs

    LogProbs

    LogProbs is one of the basic skills for a prompt engineer to have. Some background before implementing it: An LLM model…

    1 条评论
  • When to brush your teeth? A good ANOVA study!

    When to brush your teeth? A good ANOVA study!

    I found this paper which did a simple ANOVA study to find out when should one brush their teeth! TL;DR Brush twice a…

  • Statistical issues in this paper studying relation between air quality and LULC

    Statistical issues in this paper studying relation between air quality and LULC

    A paper got published in Environmental Monitoring and Assessment. It studied relation between land-use classes (Urban…

  • Bayesian probabilistic forecasts using categorical information | Part 1

    Bayesian probabilistic forecasts using categorical information | Part 1

    In this blog, I will make Bayesian forecasts of Ozone concentrations. My previous blog on Bayesian analysis: Bayesian…

  • 100% Mediation in Action

    100% Mediation in Action

    I wrote about Mediators in the previous article. This is a follow-up to it.

  • Mediators

    Mediators

    I one of my previous blogs, we saw Omitted Variable Bias. In this blog, we’ll do mediation analysis using the same…

  • Visualize Collider Bias with me

    Visualize Collider Bias with me

    It’s 2020. You are a doctor.

  • A Statistician counts well

    A Statistician counts well

    I’ve come across an article Counting as Statistics in Saket Choudhary's blog. The blog has a story on how statisticians…

  • Omitted Variable Bias (OVB)

    Omitted Variable Bias (OVB)

    You performed a regression between house prices and area and obtained a coefficient (β) for area. You’d interpret it…

社区洞察

其他会员也浏览了