{"id":28070158,"url":"https://github.com/geoarrow/geoarrow-python","last_synced_at":"2025-05-12T19:38:39.466Z","repository":{"id":196384381,"uuid":"676617154","full_name":"geoarrow/geoarrow-python","owner":"geoarrow","description":"Python implementation of the GeoArrow specification","archived":false,"fork":false,"pushed_at":"2025-04-30T22:05:53.000Z","size":3842,"stargazers_count":78,"open_issues_count":8,"forks_count":4,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-30T23:19:52.352Z","etag":null,"topics":["geoarrow","python"],"latest_commit_sha":null,"homepage":"http://geoarrow.org/geoarrow-python/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geoarrow.png","metadata":{"files":{"readme":"README.ipynb","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-08-09T15:58:29.000Z","updated_at":"2025-04-30T22:05:18.000Z","dependencies_parsed_at":"2024-07-19T17:33:39.849Z","dependency_job_id":"e08809e8-664d-4d9e-a92b-c9b1a2f483ce","html_url":"https://github.com/geoarrow/geoarrow-python","commit_stats":null,"previous_names":["geoarrow/geoarrow-python"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoarrow%2Fgeoarrow-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoarrow%2Fgeoarrow-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoarrow%2Fgeoarrow-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoarrow%2Fgeoarrow-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geoarrow","download_url":"https://codeload.github.com/geoarrow/geoarrow-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253808964,"owners_count":21967631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geoarrow","python"],"created_at":"2025-05-12T19:38:37.554Z","updated_at":"2025-05-12T19:38:39.457Z","avatar_url":"https://github.com/geoarrow.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"{\n \"cells\": [\n  {\n   \"attachments\": {},\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# GeoArrow for Python\\n\",\n    \"\\n\",\n    \"The GeoArrow Python packages provide an implementation of the [GeoArrow specification](https://github.com/geoarrow/geoarrow) that integrates with [pyarrow](https://arrow.apache.org/docs/python) and [pandas](https://pandas.pydata.org/). The GeoArrow Python bindings enable input/output to/from Arrow-friendly formats (e.g., Parquet, Arrow Stream, Arrow File) and general-purpose coordinate shuffling tools among GeoArrow, WKT, and WKB encodings. \\n\",\n    \"\\n\",\n    \"## Installation\\n\",\n    \"\\n\",\n    \"Python bindings for GeoArrow are available on PyPI. You can install them with:\\n\",\n    \"\\n\",\n    \"```bash\\n\",\n    \"pip install geoarrow-pyarrow geoarrow-pandas\\n\",\n    \"```\\n\",\n    \"\\n\",\n    \"You can install the latest development versions with:\\n\",\n    \"\\n\",\n    \"```bash\\n\",\n    \"pip install \\\"git+https://github.com/geoarrow/geoarrow-python.git#egg=geoarrow-pyarrow\u0026subdirectory=geoarrow-pyarrow\\\"\\n\",\n    \"pip install \\\"git+https://github.com/geoarrow/geoarrow-python.git#egg=geoarrow-pandas\u0026subdirectory=geoarrow-pandas\\\"\\n\",\n    \"```\\n\",\n    \"\\n\",\n    \"If you can import the namespaces, you're good to go!\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 1,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"import geoarrow.pyarrow as ga\\n\",\n    \"import geoarrow.pandas as _\"\n   ]\n  },\n  {\n   \"attachments\": {},\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Examples\\n\",\n    \"\\n\",\n    \"You can create geoarrow-encoded `pyarrow.Array`s with `as_geoarrow()`:\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 2,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text/plain\": [\n       \"PointArray:PointType(geoarrow.point)[1]\\n\",\n       \"\u003cPOINT (0 1)\u003e\"\n      ]\n     },\n     \"execution_count\": 2,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"ga.as_geoarrow([\\\"POINT (0 1)\\\"])\"\n   ]\n  },\n  {\n   \"attachments\": {},\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"This will work with:\\n\",\n    \"\\n\",\n    \"- An existing array created by geoarrow\\n\",\n    \"- A `geopandas.GeoSeries`\\n\",\n    \"- A `pyarrow.Array` or `pyarrow.ChunkedArray` (geoarrow text interpreted as well-known text; binary interpreted as well-known binary)\\n\",\n    \"- Anything that `pyarrow.array()` will convert to a text or binary array\\n\",\n    \"\\n\",\n    \"If there is no common geometry type among elements of the input, `as_geoarrow()` will fall back to well-known binary encoding. To explicitly convert to well-known text or binary, use `as_wkt()` or `as_wkb()`.\\n\",\n    \"\\n\",\n    \"Alternatively, you can construct GeoArrow arrays directly from a series of buffers as described in the specification:\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 3,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text/plain\": [\n       \"PointArray:PointType(geoarrow.point)[3]\\n\",\n       \"\u003cPOINT (1 3)\u003e\\n\",\n       \"\u003cPOINT (2 4)\u003e\\n\",\n       \"\u003cPOINT (3 5)\u003e\"\n      ]\n     },\n     \"execution_count\": 3,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"import numpy as np\\n\",\n    \"\\n\",\n    \"ga.point().from_geobuffers(\\n\",\n    \"    None, \\n\",\n    \"    np.array([1.0, 2.0, 3.0]),\\n\",\n    \"    np.array([3.0, 4.0, 5.0])\\n\",\n    \")\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 4,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text/plain\": [\n       \"PointArray:PointType(interleaved geoarrow.point)[3]\\n\",\n       \"\u003cPOINT (1 2)\u003e\\n\",\n       \"\u003cPOINT (3 4)\u003e\\n\",\n       \"\u003cPOINT (5 6)\u003e\"\n      ]\n     },\n     \"execution_count\": 4,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"ga.point().with_coord_type(ga.CoordType.INTERLEAVED).from_geobuffers(\\n\",\n    \"    None,\\n\",\n    \"    np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])\\n\",\n    \")\"\n   ]\n  },\n  {\n   \"attachments\": {},\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"Importing `geoarrow.pyarrow` will register the geoarrow extension types with pyarrow such that you can read/write Arrow streams, Arrow files, and Parquet that contains Geoarrow extension types. A number of these files are available from the [geoarrow-data](https://github.com/geoarrow/geoarrow-data) repository.\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 5,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text/plain\": [\n       \"OBJECTID: int64\\n\",\n       \"FEAT_CODE: string\\n\",\n       \"LINE_CLASS: int32\\n\",\n       \"MISCID_1: string\\n\",\n       \"MISCNAME_1: string\\n\",\n       \"MISCID_2: string\\n\",\n       \"MISCNAME_2: string\\n\",\n       \"HID: string\\n\",\n       \"MISCID_3: string\\n\",\n       \"MISCNAME_3: string\\n\",\n       \"MISCID_4: string\\n\",\n       \"MISCNAME_4: string\\n\",\n       \"SHAPE_LEN: double\\n\",\n       \"geometry: extension\u003cgeoarrow.multilinestring\u003cMultiLinestringType\u003e\u003e\"\n      ]\n     },\n     \"execution_count\": 5,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"import urllib.request\\n\",\n    \"from pyarrow import feather\\n\",\n    \"\\n\",\n    \"url = \\\"https://github.com/geoarrow/geoarrow-data/releases/download/v0.1.0/ns-water-basin_line.arrow\\\"\\n\",\n    \"local_filename, headers = urllib.request.urlretrieve(url)\\n\",\n    \"feather.read_table(local_filename).schema\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"The `as_geoarrow()` function can accept a `geopandas.GeoSeries` as input:\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 6,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text/plain\": [\n       \"MultiLinestringArray:MultiLinestringType(geoarrow.multilinestring \u003c{\\\"$schema\\\":\\\"https://proj.org/schem...\u003e)[255]\\n\",\n       \"\u003cMULTILINESTRING ((648686.210534334 5099183.050480807, 648626.2095...\u003e\\n\",\n       \"\u003cMULTILINESTRING ((687688.0166642987 5117030.253445747, 686766.217...\u003e\\n\",\n       \"\u003cMULTILINESTRING ((631355.7058094738 5122893.354471898, 631364.529...\u003e\\n\",\n       \"\u003cMULTILINESTRING ((665166.2114203956 5138643.056812348, 665146.211...\u003e\\n\",\n       \"\u003cMULTILINESTRING ((673606.2114490251 5162963.061371056, 673606.211...\u003e\\n\",\n       \"...245 values...\\n\",\n       \"\u003cMULTILINESTRING ((681672.817898342 5078602.646958541, 681866.2179...\u003e\\n\",\n       \"\u003cMULTILINESTRING ((414868.0669037141 5093041.933686847, 414793.966...\u003e\\n\",\n       \"\u003cMULTILINESTRING ((414868.0669037141 5093041.933686847, 414829.866...\u003e\\n\",\n       \"\u003cMULTILINESTRING ((414868.0669037141 5093041.933686847, 414937.366...\u003e\\n\",\n       \"\u003cMULTILINESTRING ((648686.210534334 5099183.050480807, 648866.2105...\u003e\"\n      ]\n     },\n     \"execution_count\": 6,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"import geopandas\\n\",\n    \"\\n\",\n    \"url = \\\"https://github.com/geoarrow/geoarrow-data/releases/download/v0.1.0/ns-water-basin_line.fgb.zip\\\"\\n\",\n    \"df = geopandas.read_file(url)\\n\",\n    \"array = ga.as_geoarrow(df.geometry)\\n\",\n    \"array\"\n   ]\n  },\n  {\n   \"attachments\": {},\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"You can convert back to geopandas using `to_geopandas()`:\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 7,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text/plain\": [\n       \"0      MULTILINESTRING ((648686.211 5099183.050, 6486...\\n\",\n       \"1      MULTILINESTRING ((687688.017 5117030.253, 6867...\\n\",\n       \"2      MULTILINESTRING ((631355.706 5122893.354, 6313...\\n\",\n       \"3      MULTILINESTRING ((665166.211 5138643.057, 6651...\\n\",\n       \"4      MULTILINESTRING ((673606.211 5162963.061, 6736...\\n\",\n       \"                             ...                        \\n\",\n       \"250    MULTILINESTRING ((681672.818 5078602.647, 6818...\\n\",\n       \"251    MULTILINESTRING ((414868.067 5093041.934, 4147...\\n\",\n       \"252    MULTILINESTRING ((414868.067 5093041.934, 4148...\\n\",\n       \"253    MULTILINESTRING ((414868.067 5093041.934, 4149...\\n\",\n       \"254    MULTILINESTRING ((648686.211 5099183.050, 6488...\\n\",\n       \"Length: 255, dtype: geometry\"\n      ]\n     },\n     \"execution_count\": 7,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"ga.to_geopandas(array)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Pandas integration\\n\",\n    \"\\n\",\n    \"The `geoarrow-pandas` package provides an extension array that wraps geoarrow memory and an accessor that provides pandas-friendly wrappers around the compute functions available in `geoarrow.pyarrow`.\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 8,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text/plain\": [\n       \"0     MULTIPOINT (277022.6936181751 4820886.609673489)\\n\",\n       \"1     MULTIPOINT (315701.2552756762 4855051.378571571)\\n\",\n       \"2    MULTIPOINT (255728.65994492616 4851022.107901295)\\n\",\n       \"3     MULTIPOINT (245206.7841665779 4895609.409696873)\\n\",\n       \"4    MULTIPOINT (337143.18135472975 4860312.288760258)\\n\",\n       \"dtype: string[pyarrow]\"\n      ]\n     },\n     \"execution_count\": 8,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"import geoarrow.pandas as _\\n\",\n    \"import pandas as pd\\n\",\n    \"\\n\",\n    \"df = pd.read_feather(\\\"https://github.com/geoarrow/geoarrow-data/releases/download/v0.1.0/ns-water-basin_point.arrow\\\")\\n\",\n    \"df.geometry.geoarrow.format_wkt().head(5)\"\n   ]\n  },\n  {\n   \"attachments\": {},\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Building\\n\",\n    \"\\n\",\n    \"Python bindings for geoarrow are managed with [setuptools](https://setuptools.pypa.io/en/latest/index.html).\\n\",\n    \"This means you can build the project using:\\n\",\n    \"\\n\",\n    \"```shell\\n\",\n    \"git clone https://github.com/geoarrow/geoarrow-python.git\\n\",\n    \"pip install -e geoarrow-pyarrow/ geoarrow-pandas/\\n\",\n    \"```\\n\",\n    \"\\n\",\n    \"Tests use [pytest](https://docs.pytest.org/):\\n\",\n    \"\\n\",\n    \"```shell\\n\",\n    \"pytest\\n\",\n    \"```\"\n   ]\n  }\n ],\n \"metadata\": {\n  \"kernelspec\": {\n   \"display_name\": \"Python 3\",\n   \"language\": \"python\",\n   \"name\": \"python3\"\n  },\n  \"language_info\": {\n   \"codemirror_mode\": {\n    \"name\": \"ipython\",\n    \"version\": 3\n   },\n   \"file_extension\": \".py\",\n   \"mimetype\": \"text/x-python\",\n   \"name\": \"python\",\n   \"nbconvert_exporter\": \"python\",\n   \"pygments_lexer\": \"ipython3\",\n   \"version\": \"3.11.2\"\n  },\n  \"orig_nbformat\": 4\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 2\n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeoarrow%2Fgeoarrow-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeoarrow%2Fgeoarrow-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeoarrow%2Fgeoarrow-python/lists"}