From 72f3e190ee21d253b44a1fa15cb4382f63505474 Mon Sep 17 00:00:00 2001 From: Boba Fett <bobafett@maap-project.org> Date: Fri, 24 Jul 2020 22:24:55 +0000 Subject: [PATCH] Upload New File --- Intersection.ipynb | 156 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 Intersection.ipynb diff --git a/Intersection.ipynb b/Intersection.ipynb new file mode 100644 index 0000000..d2b608b --- /dev/null +++ b/Intersection.ipynb @@ -0,0 +1,156 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas\n", + "import geopandas as gpd\n", + "from geopandas import GeoDataFrame\n", + "from geopandas.tools import sjoin" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "<div>\n", + "<style scoped>\n", + " .dataframe tbody tr th:only-of-type {\n", + " vertical-align: middle;\n", + " }\n", + "\n", + " .dataframe tbody tr th {\n", + " vertical-align: top;\n", + " }\n", + "\n", + " .dataframe thead th {\n", + " text-align: right;\n", + " }\n", + "</style>\n", + "<table border=\"1\" class=\"dataframe\">\n", + " <thead>\n", + " <tr style=\"text-align: right;\">\n", + " <th></th>\n", + " <th>lon</th>\n", + " <th>lat</th>\n", + " <th>h_max_can</th>\n", + " <th>h_can</th>\n", + " <th>rh25</th>\n", + " <th>rh50</th>\n", + " <th>rh60</th>\n", + " <th>rh70</th>\n", + " <th>rh75</th>\n", + " <th>rh80</th>\n", + " <th>...</th>\n", + " <th>sig_h</th>\n", + " <th>sig_topo</th>\n", + " <th>n_te_ph</th>\n", + " <th>h_te_best</th>\n", + " <th>h_te_unc</th>\n", + " <th>ter_slp</th>\n", + " <th>snr</th>\n", + " <th>sol_az</th>\n", + " <th>sol_el</th>\n", + " <th>geometry</th>\n", + " </tr>\n", + " </thead>\n", + " <tbody>\n", + " </tbody>\n", + "</table>\n", + "<p>0 rows × 37 columns</p>\n", + "</div>" + ], + "text/plain": [ + "Empty GeoDataFrame\n", + "Columns: [lon, lat, h_max_can, h_can, rh25, rh50, rh60, rh70, rh75, rh80, rh85, rh90, rh95, n_ca_ph, n_toc_ph, can_open, tcc_flg, tcc_prc, cloud_flg, msw_flg, n_seg_ph, night_flg, seg_snow, seg_water, sig_vert, sig_acr, sig_along, sig_h, sig_topo, n_te_ph, h_te_best, h_te_unc, ter_slp, snr, sol_az, sol_el, geometry]\n", + "Index: []\n", + "\n", + "[0 rows x 37 columns]" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Points = gpd.GeoDataFrame.from_file('/projects/bobafett/Icesat2Gabon/Data/Shapefiles/Gabon_IS2_ATL08.shp')\n", + "\n", + "Points\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "GPKG = gpd.GeoDataFrame.from_file('/projects/bobafett/Icesat2Gabon/Data/PongaraGPKG/Pongara_Dissolved.shp')" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'Points' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m<ipython-input-6-b47e2ff581c1>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mpointInPolys\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mPoints\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mGPKG\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhow\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'left'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;31m#print(pointInPolys.head())\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mNameError\u001b[0m: name 'Points' is not defined" + ] + } + ], + "source": [ + "pointInPolys = sjoin(Points, GPKG, how='left')\n", + "#print(pointInPolys.head())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save the GeoDataFrame\n", + "# HAS CRS ISSUE\n", + "#points.to_file(driver = 'GPKG', filename= \"/projects/bobafett/Icesat2Gabon/Data/CSV/Gabon_IS2_ATL08.gpkg\")\n", + "\n", + "print('finished')" + ] + } + ], + "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.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} -- GitLab