{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import psycopg2\n", "import geopandas as gpd\n", "\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "conn = psycopg2.connect( \"dbname=osm_local\")\n", "curs = conn.cursor()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "tSQL = '''select osm_id, \n", " ST_IsSimple(way) as simple,\n", " ST_NPoints(way) as pts_cnt,\n", " (building is not Null) as bldg, \n", " way as geom from planet_osm_polygon\n", " WHERE ST_NPoints(way) > 7\n", "'''\n", "\n", "res_df = gpd.read_postgis( tSQL, conn)\n", "#print( res_df.shape[0],\" rows of \",res_df.shape[1],\" columns\")\n", "#res_df.dtypes\n", "res_df.info()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# make a subset dataframe via a filter expression\n", "# boolean column 'bldg' only keep True entries\n", "res_df_A = res_df[ res_df['bldg'] ]\n", "\n", "# example test -- exactly 24 poly points\n", "res_df_A33 = res_df_A[ res_df_A['pts_cnt'] == 24]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "res_df_A33.plot( figsize=(12,20) )" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "res_df_A.plot( column='pts_cnt', cmap=None, figsize=(12,20) )" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 2 }