Skip to main content

cdrc

cdrc is a Python wrapper client library designed to connect to the CriticalMAAS Data Repository (CDR) and programmatically pull data. It can build GeoJSON files and GeoPackages for features extracted from COGs (Cloud Optimized GeoTIFF files of maps).

All georeferenced data returned will be in ESPG:4326 projection. Projected maps used to georeference features will be returned as the original projection they were projected with.

CDR github: https://github.com/DARPA-CRITICALMAAS/cdr

Features

  • Connect to the CDR with a token
  • Pull data programmatically from COGs
  • Build GeoJSON files
  • Build GeoPackages
  • Download COG images in pixel space and projected COGs if features are projected

Installation

To install the cdrc library, use pip:

pip install cdrc

Running cdrc

To import the library and set up the client:

import cdrc

client = cdrc.CDRClient(token="your bearer token")

If you want to view data for a specific cog you can use the client.build_cog_geopackages function. It will download data from the cdr and convert it to a ready to use geopackage or geojson files you can load directly into QGIS.

This query can return a lot of data and take a long time to complete so if you only care about certain feature types or data from specific system/versions those should be set.

Parameters:

cog_id: Cog id.

feature_types: An array of the features you want. Options are: line, point, polygon.

system_versions: An array of tuples with system and system_version. An empty array will return results from all systems.

validated: Return validated features or not validated. None will return both validated and not validated features/legend_items.

cog_id = "specify what cog you want"
system =  "system_name"
system_version = "0.0.1"

client.build_cog_geopackages(
    cog_id=cog_id,
    feature_types=['polygon', 'point', 'line'],
    system_versions=[(system, system_version)],
    validated=None
)

If you want to view data for a specific CMA area you can use the client.build_cma_geopackages function. It will download data from the cdr and convert it to a ready to use geopackage or geojson files you can load directly into QGIS.

This query can return a lot of data and take a long time to complete so if you only care about certain feature types or data from specific system/versions those should be set.

Parameters:

cog_ids: List of cog ids that you want results for.

feature_type: Provide an the type of feature you want. Options are line, point, polygon.

system_versions: An array of tuples with system and system_version. An empty array will return results from all systems

validated: Return validated features or not validated. None will return both validated and not validated features.

search_text: String to be searched over the Legend description/label/abbreviation fields.

intersect_polygon: Geojson polygon to intersect over the features. EPSG:4326

cma_name: Name of the output folder for this search.

cog_ids = ["specify list of cogs you want","..."]

client.build_cma_geopackages(
    cog_ids=cog_ids,
    feature_type='line',
    system_versions=[(system, system_version)],
    validated=None,
    search_text="",
    intersect_polygon= { 
        "type": "Polygon", 
        "coordinates": [
            [
                [-94.23558192118045, 48.0],
                [-94.24500827925175, 48.0],
                [-94.24500827925175, 49.0], 
                [-95.24500827925175, 49.0], 
                [-95.24500827925175, 48.0], 
                [-94.23558192118045, 48.0] 
            ]
        ] 
        },
    cma_name="cma_test"
)

Metadata

Release files for cdrc 0.1.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cdrc 0.1.15
File Size Uploaded
cdrc-0.1.15.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cdrc 0.1.15
File Interpreter ABI Platform
cdrc-0.1.15-py3-none-any.whl Python 3 none any Details

Total release size: 18.4 kB

Release files / cdrc-0.1.15.tar.gz

Download URL cdrc-0.1.15.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
def56e513bb22bb2e660a451ef22f7fd8b993cc48afd57d66860ec9bd06c935b
BLAKE2b-256 checksum
How to use checksums
00c6f353aef6c02b1010b16757dfc506bfe08700e6e029c4d55efa25afd25354
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.9.12 Darwin/23.4.0

Release files / cdrc-0.1.15-py3-none-any.whl

Download URL cdrc-0.1.15-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97061290b7ee5acd880528b138677f2a6b6aa12ac801df8cc1d61966e8e986ba
BLAKE2b-256 checksum
How to use checksums
59502991d8215fbe39aa4538b5baa0f36688d7be59da0bef0466d5ebd275e63a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.9.12 Darwin/23.4.0

Release history Release notifications | RSS feed

This release

0.1.15 This release

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page