|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "id": "50f502bd", |
| 7 | + "metadata": { |
| 8 | + "tags": [ |
| 9 | + "remove-input" |
| 10 | + ] |
| 11 | + }, |
| 12 | + "outputs": [], |
| 13 | + "source": [ |
| 14 | + "import warnings\n", |
| 15 | + "\n", |
| 16 | + "warnings.filterwarnings(\"ignore\")" |
| 17 | + ] |
| 18 | + }, |
| 19 | + { |
| 20 | + "cell_type": "markdown", |
| 21 | + "id": "2ee126e9", |
| 22 | + "metadata": {}, |
| 23 | + "source": [ |
| 24 | + "# Geometries\n", |
| 25 | + "\n", |
| 26 | + "`pytileproj` does not have GDAL and OGR as a direct dependency and instead defines its own classes to store geospatial geometries. These geometries are used as an interface to and from many functions and class methods within `pytileproj`. \n", |
| 27 | + "\n", |
| 28 | + "Several geospatial geometry classes are declared in `pytileproj`'s `projgeom` module and are defined by two properties:\n", |
| 29 | + "\n", |
| 30 | + "- `geom`: a `shapely.Geometry` instance, e.g. `shapely.Point`, `shapely.Polygon`, and `shapely.MultiPolygon` \n", |
| 31 | + "- `crs`: a `pyproj.CRS` instance\n", |
| 32 | + "\n", |
| 33 | + "The simplest class, is the `ProjCoord` class defining a projected coordinate tuple." |
| 34 | + ] |
| 35 | + }, |
| 36 | + { |
| 37 | + "cell_type": "code", |
| 38 | + "execution_count": null, |
| 39 | + "id": "ad748924", |
| 40 | + "metadata": {}, |
| 41 | + "outputs": [], |
| 42 | + "source": [ |
| 43 | + "import pyproj\n", |
| 44 | + "\n", |
| 45 | + "from pytileproj import ProjCoord\n", |
| 46 | + "\n", |
| 47 | + "proj_coord = ProjCoord(x=25, y=10, crs=pyproj.CRS.from_epsg(3857))\n", |
| 48 | + "proj_coord" |
| 49 | + ] |
| 50 | + }, |
| 51 | + { |
| 52 | + "cell_type": "markdown", |
| 53 | + "id": "4bb1a565", |
| 54 | + "metadata": {}, |
| 55 | + "source": [ |
| 56 | + "For geographical (longitude and latitude) coordinates, there is a child class `GeogCoord`:" |
| 57 | + ] |
| 58 | + }, |
| 59 | + { |
| 60 | + "cell_type": "code", |
| 61 | + "execution_count": null, |
| 62 | + "id": "9f4c43c7", |
| 63 | + "metadata": {}, |
| 64 | + "outputs": [], |
| 65 | + "source": [ |
| 66 | + "from pytileproj import GeogCoord\n", |
| 67 | + "\n", |
| 68 | + "geog_coord = GeogCoord(25, 10)\n", |
| 69 | + "geog_coord" |
| 70 | + ] |
| 71 | + }, |
| 72 | + { |
| 73 | + "cell_type": "markdown", |
| 74 | + "id": "6c1e7c00", |
| 75 | + "metadata": {}, |
| 76 | + "source": [ |
| 77 | + "All other geometries can be defined with the basic class `ProjGeom`:" |
| 78 | + ] |
| 79 | + }, |
| 80 | + { |
| 81 | + "cell_type": "code", |
| 82 | + "execution_count": null, |
| 83 | + "id": "d9299ecf", |
| 84 | + "metadata": {}, |
| 85 | + "outputs": [], |
| 86 | + "source": [ |
| 87 | + "from shapely import Polygon\n", |
| 88 | + "\n", |
| 89 | + "from pytileproj import ProjGeom\n", |
| 90 | + "\n", |
| 91 | + "geom = Polygon([(1, 1), (10, 2), (8, 7), (2, 4)])\n", |
| 92 | + "proj_geom = ProjGeom(geom=geom, crs=pyproj.CRS.from_epsg(27701))\n", |
| 93 | + "proj_geom" |
| 94 | + ] |
| 95 | + }, |
| 96 | + { |
| 97 | + "cell_type": "markdown", |
| 98 | + "id": "6651a3a2", |
| 99 | + "metadata": {}, |
| 100 | + "source": [ |
| 101 | + "Also here we can use a special class for geographic coordinates:" |
| 102 | + ] |
| 103 | + }, |
| 104 | + { |
| 105 | + "cell_type": "code", |
| 106 | + "execution_count": null, |
| 107 | + "id": "2da28e68", |
| 108 | + "metadata": {}, |
| 109 | + "outputs": [], |
| 110 | + "source": [ |
| 111 | + "from pytileproj import GeogGeom\n", |
| 112 | + "\n", |
| 113 | + "geog_geom = GeogGeom(geom=geom)\n", |
| 114 | + "geog_geom" |
| 115 | + ] |
| 116 | + } |
| 117 | + ], |
| 118 | + "metadata": { |
| 119 | + "kernelspec": { |
| 120 | + "display_name": "pytileproj", |
| 121 | + "language": "python", |
| 122 | + "name": "python3" |
| 123 | + }, |
| 124 | + "language_info": { |
| 125 | + "codemirror_mode": { |
| 126 | + "name": "ipython", |
| 127 | + "version": 3 |
| 128 | + }, |
| 129 | + "file_extension": ".py", |
| 130 | + "mimetype": "text/x-python", |
| 131 | + "name": "python", |
| 132 | + "nbconvert_exporter": "python", |
| 133 | + "pygments_lexer": "ipython3", |
| 134 | + "version": "3.12.3" |
| 135 | + } |
| 136 | + }, |
| 137 | + "nbformat": 4, |
| 138 | + "nbformat_minor": 5 |
| 139 | +} |
0 commit comments