geospatial-analysis
Introduction
In this micro-course, you’ll learn about different methods to wrangle and visualize geospatial data, or data with a geographic location.
Along the way, you’ll offer solutions to several real-world problems like:
- Where should a global non-profit expand its reach in remote areas of the Philippines?
- How do purple martins, a threatened bird species, travel between North and South America? Are the birds travelling to conservation areas?
- Which areas of Japan could potentially benefit from extra earthquake reinforcement?
- Which Starbucks stores in California are strong candidates for the next Starbucks Reserve Roastery location?
- Does New York City have sufficient hospitals to respond to motor vehicle collisions? Which areas of the city have gaps in coverage?
You’ll also visualize crime in the city of Boston, examine health facilities in Ghana, explore top universities in Europe, and track releases of toxic chemicals in the United States.
In this first tutorial, we’ll quickly cover the pre-requisites that you’ll need to complete this micro-course. And, if you’d like to review more deeply, we recommend the Pandas micro-course.
We’ll also get started with visualizing our first geospatial dataset!
#Reading data
The first step is to read in some geospatial data! To do this, we’ll use the GeoPandas library.
This is a wonderful packages called GeoPandas
While this column can contain a variety of different datatypes, each entry will typically be a Point, LineString, or Polygon.
The “geometry” column in our dataset contains 2983 different Polygon objects, each corresponding to a different shape in the plot above.
In the code cell below, we create three more GeoDataFrames, containing campsite locations (Point), foot trails (LineString), and county boundaries (Polygon).
读入数据
绘制地图
!!!得到所有国家的地图边界数据
#This dataset is provided in GeoPandas
world_filepath = gpd.datasets.get_path(‘naturalearth_lowres’)
world = gpd.read_file(world_filepath)
!!!画出我中华人民共和国的地图
#This dataset is provided in GeoPandas
world_filepath = gpd.datasets.get_path('naturalearth_lowres')
world = gpd.read_file(world_filepath)
data_China = world[world['name'] == 'China']
data_China.plot(figsize = (10,10) , color= 'none' , edgecolor = 'gainsboro' , zorder = 3)
画出Kiva慈善组织的在全世界范围内的行善地点
#This dataset is provided in GeoPandas
world_filepath = gpd.datasets.get_path('naturalearth_lowres')
world = gpd.read_file(world_filepath)
ax = world.plot(figsize=(20,20), color='whitesmoke', linestyle=':', edgecolor='black')
world_loans.plot(ax=ax, markersize=2)