TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Follow publication

Analyzing Geospatial Data with Python

A practical data analysis post with Python code.

Gustavo R Santos
TDS Archive
Published in
8 min readAug 19, 2023

Introduction

Geospatial Data Science is one of my areas of interest. I find it fascinating how we can visualize data on a map and how — many times — the relationships between the data points present great insights real quickly.

I believe the applicability of this sub area of data science is pretty useful for any business, namely grocery stores, car rentals, logistics, real estate etc. In this post, we will go over a dataset from AirBnb for the city of Asheville, NC, in USA.

Side note: In that city lies one of the most amazing real estates in America, — and I would dare to say in the world. The property pertains to the Vanderbilt family and, during a long time, it was the largest private property in the country. Well, it is so worth a visit, but that’s not the core subject here.

Biltmore estate building in Ashville, NC. Photo by Stephanie Klepacki on Unsplash.

The datasets to be used in this exercise are the AirBnb rentals for the city of Asheville. They can be downloaded directly from this web site in http://insideairbnb.com/get-the-data, under the Creative Commons Attribution 4.0 International License.

Let’s get to work.

Geospatial Data Science

The knowledge from this post is mostly from the book referred below (Applied Geospatial Data Science with Python, by David S. JORDAN). So let’s begin importing some modules to our session.

import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
import pysal
import splot
import re
import seaborn as sns
import folium


# For points map
import geoplot.crs as gcrs
import geoplot as gplt

Now notice that some of them might be new for you, as they are for me as well. If needed, use pip install module_name to install any package needed. In my case, pysal and geoplot are new to me, so they had to be installed.

Next, we will read the data from AirBnb.

# Open listings file
listings = pd.read_csv('/content/listings.csv',
usecols=['id', 'property_type', 'neighbourhood_cleansed',
'bedrooms', 'beds', 'bathrooms_text', 'price'

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Gustavo R Santos
Gustavo R Santos

Written by Gustavo R Santos

Data Scientist | I solve business challenges through the power of data. | Visit my site: https://gustavorsantos.me

Responses (5)

Write a response