Skip to content

Instantly share code, notes, and snippets.

View rasha-salim's full-sized avatar
🌏
Working from home

Rasha G. Salim rasha-salim

🌏
Working from home
View GitHub Profile
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active May 22, 2024 14:36
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@urschrei
urschrei / png_to_polygon_to_geojson.py
Last active November 16, 2022 16:58
Read a PNG into a numpy array, convert it to a Shapely Polygon, and dump it as GeoJSON
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created by Stephan Hügel on 2017-03-02
The MIT License (MIT)
Copyright (c) 2017 Stephan Hügel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@urschrei
urschrei / shapefile.py
Last active September 29, 2021 08:24
Open a shapefile using Fiona, and plot its features using Matplotlib and Descartes
import matplotlib.pyplot as plt
from matplotlib.collections import PatchCollection
from descartes import PolygonPatch
import fiona
from shapely.geometry import Polygon, MultiPolygon, shape
# We can extract the London Borough boundaries by filtering on the AREA_CODE key
mp = MultiPolygon(
[shape(pol['geometry']) for pol in fiona.open('data/boroughs/boroughs.shp')
if pol['properties']['AREA_CODE'] == 'LBO'])