smnorris / bcdata

Python and command line tools for quick access to DataBC geo-data available via WFS/WCS.
MIT License
29 stars 7 forks source link

schema for WHSE_LAND_USE_PLANNING RMP_LANDSCAPE_RSRV_DESIGN_SP is in resource of format oracle_sde, not wms #181

Closed smnorris closed 3 months ago

smnorris commented 3 months ago
$ bcdata list | grep WHSE_LAND_USE_PLANNING.RMP_LANDSCAPE_RSRV_DESIGN_SP
WHSE_LAND_USE_PLANNING.RMP_LANDSCAPE_RSRV_DESIGN_SP

$ bcdata info WHSE_LAND_USE_PLANNING.RMP_LANDSCAPE_RSRV_DESIGN_SP
Traceback (most recent call last):
  File "/Users/snorris/Projects/repo/harvest-restrictions/harvest_env/bin/bcdata", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/snorris/Projects/repo/harvest-restrictions/harvest_env/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/snorris/Projects/repo/harvest-restrictions/harvest_env/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/snorris/Projects/repo/harvest-restrictions/harvest_env/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/snorris/Projects/repo/harvest-restrictions/harvest_env/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/snorris/Projects/repo/harvest-restrictions/harvest_env/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/snorris/Projects/repo/harvest-restrictions/harvest_env/lib/python3.11/site-packages/bcdata/cli.py", line 137, in info
    table_definition = bcdata.get_table_definition(dataset)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/snorris/Projects/repo/harvest-restrictions/harvest_env/lib/python3.11/site-packages/bcdata/bcdc.py", line 144, in get_table_definition
    raise ValueError(
ValueError: BCDC search for WHSE_LAND_USE_PLANNING.RMP_LANDSCAPE_RSRV_DESIGN_SP does not return a table schema
smnorris commented 3 months ago

details key is empty for the wms resource.

smnorris commented 3 months ago

There are resources in the result (wms,kml,oracle_sde), and the resource with the schema details is the oracle_sde - not a format bcdata currently scans for details.

smnorris commented 3 months ago

https://catalogue.data.gov.bc.ca/api/3/action/package_search?q=%22WHSE_LAND_USE_PLANNING.RMP_LANDSCAPE_RSRV_DESIGN_SP%22

 "resources": [
          {
            "cache_last_updated": null,
            "package_id": "bdaf676e-200d-462a-9bc4-7bda79bda58f",
            "datastore_active": "false",
            "id": "6d8b0a7e-79b8-4e97-bd70-980e06bf5828",
            "description": "The Distribution Service allows for data to be downloaded in various file formats from the B.C. Geographic Warehouse (BCGW), a central government repository of spatial and non-spatial data.",
            "spatial_datatype": "SDO_GEOMETRY",
            "iso_topic_category": [
              "environment",
              "planningCadastre"
            ],
            "object_name": "WHSE_LAND_USE_PLANNING.RMP_LANDSCAPE_RSRV_DESIGN_SP",
            "temporal_extent": "{\"[object Object]\":\"\"}",
            "state": "active",
            "details": "[{\"data_precision\": 10, \"column_comments\": \"A system generated unique identification number.\", \"short_name\": \"RMP_LRD_SD\", \"data_type\": \"NUMBER\", \"column_name\": \"RMP_LRD_SYSID\"}, {\"data_precision\": 80, \"column_comments\": \"The Landcape Unit name as per the Landscape Units of British Columbia.\", \"short_name\": \"LU_NAME\", \"data_type\": \"VARCHAR2\", \"column_name\": \"LU_NAME\"}, {\"data_precision\": 7, \"column_comments\": \"The date that the Landscape Reserve Design was offically accepted by the Great Bear Rainforest G2G (Government to Government).\", \"short_name\": \"LRD_EST_DT\", \"data_type\": \"DATE\", \"column_name\": \"LRD_ESTABLISHMENT_DATE\"}, {\"data_precision\": 7, \"column_comments\": \"The date of most recent Great Bear Rainforest G2G (Government to Government) approval.\", \"short_name\": \"AMEND_DATE\", \"data_type\": \"DATE\", \"column_name\": \"LATEST_AMENDMENT_DATE\"}, {\"data_precision\": 10, \"column_comments\": \"The status of the Landscape Reserve Design area, i.e., current, retired.\", \"short_name\": \"LRD_STATUS\", \"data_type\": \"VARCHAR2\", \"column_name\": \"LRD_STATUS\"}, {\"data_precision\": 19, \"column_comments\": \"The system calculated area of a two-dimensional polygon in square meters.\", \"short_name\": \"FEAT_AREA\", \"data_type\": \"NUMBER\", \"column_name\": \"FEATURE_AREA_SQM\"}, {\"data_precision\": 19, \"column_comments\": \"The system calculated length or perimeter of a geometry in meters.\", \"short_name\": \"FEAT_LEN\", \"data_type\": \"NUMBER\", \"column_name\": \"FEATURE_LENGTH_M\"}, {\"data_precision\": 1, \"column_comments\": \"The column used to reference the spatial coordinates defining the feature.\", \"short_name\": \"SHAPE\", \"data_type\": \"SDO_GEOMETRY\", \"column_name\": \"SHAPE\"}, {\"data_precision\": 38, \"column_comments\": \"A column required by spatial layers that interact with ESRI ArcSDE. It is populated with unique values automatically by SDE.\", \"short_name\": \"OBJECTID\", \"data_type\": \"NUMBER\", \"column_name\": \"OBJECTID\"}, {\"data_precision\": 4000, \"column_comments\": \"A binary column used by spatial tools to store annotation, curve features and CAD data when using the SDO_GEOMETRY storage data type.\", \"short_name\": null, \"data_type\": \"BLOB\", \"column_name\": \"SE_ANNO_CAD_DATA\"}]",
            "bcdc_type": "geographic",
            "size": null,
            "resource_access_method": "indirect access",
            "hash": "",
            "object_short_name": "RMP_LRD",
            "format": "oracle_sde",
...
smnorris commented 3 months ago

bcdata can just be updated to add formats to scan for details as users find datasets that fail, but there must be a better way?

smnorris commented 3 months ago

@ateucher - before I get too deep into scanning the R source, do you have any guidance on whether schema details for this package are successfully picked up by R bcdata? And if so, do you just scan all resource formats, looking for a details key? I've just been looking at resources of "format"= "wfs"