Skip to main content

improved esri rest io for geopandas

Project description

restgdf

improved esri rest io for geopandas

License: BSD-3-Clause python

Publish to PyPI GitHub tag (with filter) Read the Docs

Code Climate maintainability Code Climate issues Code Climate technical debt coverage

pre-commit Ruff Checked with mypy Code style: black

security: bandit Known Vulnerabilities

gpd.read_file(url, driver="ESRIJSON") does not account for max record count limitations

so if you read a service with 100000 features but there's a limit of 1000 records per query, then your gdf will only have 1000 features

these functions use asyncio to read all features from a service, not limited by max record count

keyword arguments to FeatureLayer.getgdf are passed on to requests.Session.post; include query parameters like where str and token str in data dict

this enables enhanced control over queries and allow use of any valid authentication scheme (eg requests_ntlm.HttpNtlmAuth) with use of requests.Session.auth or data={"token": str}

Usage

pip install restgdf
import asyncio

from aiohttp import ClientSession

from restgdf import FeatureLayer


beaches_url = r"https://maps1.vcgov.org/arcgis/rest/services/Beaches/MapServer/6"

zipcodes_url = "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_ZIP_Codes_2016/FeatureServer/0"

async def main():
    async with ClientSession() as session:
        beaches = await FeatureLayer.from_url(beaches_url, session=session)
        beaches_gdf = await beaches.getgdf()

        daytona = await beaches.where("LOWER(City) LIKE 'daytona%'")
        daytona_gdf = await daytona.getgdf()

        oh_zipcodes = await FeatureLayer.from_url(zipcodes_url, where="STATE = 'OH'", session=session)
        oh_zipcodes_gdf = await oh_zipcodes.getgdf()

    return beaches_gdf, daytona_gdf, oh_zipcodes_gdf


beaches_gdf, daytona_gdf, oh_zipcodes_gdf = asyncio.run(main())

print(beaches_gdf.shape)
# (243, 10)

print(daytona_gdf.shape)
# (83, 10)

print(oh_zipcodes_gdf.shape)
# (1026, 8)

Documentation

https://restgdf.readthedocs.io/

Uses

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

restgdf-0.9.8.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

restgdf-0.9.8-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file restgdf-0.9.8.tar.gz.

File metadata

  • Download URL: restgdf-0.9.8.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for restgdf-0.9.8.tar.gz
Algorithm Hash digest
SHA256 fbe606c5d5f4a5c72a11e5b476501330901913480fed8c2a5ca9bef86ad00ac4
MD5 2aacd47e99950fb7a43240610a91f7d8
BLAKE2b-256 c80284f072a9564f6dc9fd5601495ebdbaa86768fd3f01a3142aba64a87ce9e0

See more details on using hashes here.

File details

Details for the file restgdf-0.9.8-py3-none-any.whl.

File metadata

  • Download URL: restgdf-0.9.8-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for restgdf-0.9.8-py3-none-any.whl
Algorithm Hash digest
SHA256 e0c4712943f7c4520d925ca0f6ad1edce741e7db8e4161c24c990b6f89ee9ddc
MD5 114e400897280b2a85b39fea2e21dd78
BLAKE2b-256 bf319bc36aba188dd6494d83714fb71a6d07bbe688b62a3fedbe7a997d29d50d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page