{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Merge" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Merge together the buildings and parcels file into a consolidated data set." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import geopandas as gpd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import warnings\n", "warnings.simplefilter(\"ignore\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Import the buildings" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "buildings = gpd.pd.read_csv(\n", " \"./output/buildings.csv\",\n", " dtype={\"ACCOUNT\": str, \"IN_HOUSTON\": str}\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Import the parcels" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "parcels = gpd.read_file(\"./output/parcels.shp\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Merge the two files" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "merged = parcels.merge(\n", " buildings,\n", " on=\"ACCOUNT\",\n", " how=\"inner\"\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Clean up the columns" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "merged.columns = [\n", " 'account',\n", " 'condo',\n", " 'owner',\n", " 'address',\n", " 'city',\n", " 'zipcode',\n", " 'geometry',\n", " 'use',\n", " 'class',\n", " 'number',\n", " 'erected',\n", " 'houston',\n", " 'decade',\n", "]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Output the result" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "merged.to_file(\"./output/buildings-and-parcels.shp\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.14" } }, "nbformat": 4, "nbformat_minor": 2 }