Skip to content

Instantly share code, notes, and snippets.

View shakasom's full-sized avatar

Abdishakur Hassan shakasom

View GitHub Profile
# Read_file --> Geopandas library uses fiona library which in turn uses GDAL/OGR
world = gpd.read_file("C:/GIS/GIS Data/countries/ne_50m_admin_0_countries.shp")
cities = gpd.read_file(gpd.datasets.get_path('naturalearth_cities'))
# Ploting to check the shapefile
base = world.plot(color='grey')
cities.plot(ax=base, marker='*', color='red', markersize=12);
plt.show()
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shakasom
shakasom / shapely.ipynp
Created January 6, 2018 21:25
Shapely Geometry example
{
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import geopandas as gpd\n",
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shakasom
shakasom / read_countries.py
Created May 20, 2019 08:55
Medium Article Series. Part 1 Introduction to Geographic Data science
# Read the data- Read Countries --> Geopackage Format
shp = '1-introData/countries.gpkg'
countries = gpd.read_file(shp)
@shakasom
shakasom / crs.py
Created May 20, 2019 09:01
Medium Article Series - Part 1 Introduction to Geographic Data Science
countries.crs
# First 5 rows
countries.head()
# Rows and columns of the countries data
countries.shape
# Describtive statistics of the countries data
countries.describe()
# 2. Read Cities --> Geojson Format
cities = gpd.read_file('1-introData/cities.geojson')
# Plot overlayed maps
fig, ax = plt.subplots(figsize=(14, 12))
countries.plot(ax=ax)
cities.plot(markersize=0.2, color='red',ax=ax)
plt.show()
countries.crs