Skip to content

Instantly share code, notes, and snippets.

@bitner
Last active December 12, 2023 14:35
Show Gist options
  • Save bitner/5dcc13c663157c8a36dbe4500aebaffb to your computer and use it in GitHub Desktop.
Save bitner/5dcc13c663157c8a36dbe4500aebaffb to your computer and use it in GitHub Desktop.
tipg2pgstac.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2023-11-11T22:43:11.93182+00:00 2023-12-11T17:32:19.347536+00:00\n",
"{\n",
" \"type\": \"Feature\",\n",
" \"stac_version\": \"1.0.0\",\n",
" \"id\": \"public.countries_wdt\",\n",
" \"collection\": \"tipg\",\n",
" \"geometry\": {\n",
" \"type\": \"Polygon\",\n",
" \"geometry\": {\n",
" \"coordinates\": [\n",
" [\n",
" [\n",
" -181.8000030517578,\n",
" -90.86692810058594\n",
" ],\n",
" [\n",
" 181.8000030517578,\n",
" -90.86692810058594\n",
" ],\n",
" [\n",
" 181.8000030517578,\n",
" 84.46760559082031\n",
" ],\n",
" [\n",
" -181.8000030517578,\n",
" 84.46760559082031\n",
" ],\n",
" [\n",
" -181.8000030517578,\n",
" -90.86692810058594\n",
" ]\n",
" ]\n",
" ]\n",
" }\n",
" },\n",
" \"bbox\": [\n",
" -181.8000030517578,\n",
" -90.86692810058594,\n",
" 181.8000030517578,\n",
" 84.46760559082031\n",
" ],\n",
" \"links\": [],\n",
" \"assets\": {\n",
" \"features\": {\n",
" \"title\": \"OGC Feature Service\",\n",
" \"description\": \"OGC Feature Service Endpoint.\",\n",
" \"href\": \"/items/public.countries_wdt\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" },\n",
" \"vectortiles\": {\n",
" \"title\": \"OGC Vector Tiles\",\n",
" \"description\": \"OGC Vector Tiles Endpoint.\",\n",
" \"href\": \"/items/public.countries_wdt\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" }\n",
" },\n",
" \"stac_extensions\": [\n",
" \"https://stac-extensions.github.io/table/v1.2.0/schema.json\"\n",
" ],\n",
" \"properties\": {\n",
" \"description\": null,\n",
" \"table:columns\": [\n",
" {\n",
" \"name\": \"admin\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"dt\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"geom\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" },\n",
" {\n",
" \"name\": \"gid\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" }\n",
" ],\n",
" \"table:primary_geometry\": \"geom\",\n",
" \"table:primary_datetime\": \"dt\"\n",
" }\n",
"}\n",
"-infinity infinity\n",
"{\n",
" \"type\": \"Feature\",\n",
" \"stac_version\": \"1.0.0\",\n",
" \"id\": \"public.sentinel_mgrs\",\n",
" \"collection\": \"tipg\",\n",
" \"geometry\": {\n",
" \"type\": \"Polygon\",\n",
" \"geometry\": {\n",
" \"coordinates\": [\n",
" [\n",
" [\n",
" -180.0,\n",
" -83.83595275878906\n",
" ],\n",
" [\n",
" 180.0,\n",
" -83.83595275878906\n",
" ],\n",
" [\n",
" 180.0,\n",
" 83.74835205078125\n",
" ],\n",
" [\n",
" -180.0,\n",
" 83.74835205078125\n",
" ],\n",
" [\n",
" -180.0,\n",
" -83.83595275878906\n",
" ]\n",
" ]\n",
" ]\n",
" }\n",
" },\n",
" \"bbox\": [\n",
" -180.0,\n",
" -83.83595275878906,\n",
" 180.0,\n",
" 83.74835205078125\n",
" ],\n",
" \"links\": [],\n",
" \"assets\": {\n",
" \"features\": {\n",
" \"title\": \"OGC Feature Service\",\n",
" \"description\": \"OGC Feature Service Endpoint.\",\n",
" \"href\": \"/items/public.sentinel_mgrs\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" },\n",
" \"vectortiles\": {\n",
" \"title\": \"OGC Vector Tiles\",\n",
" \"description\": \"OGC Vector Tiles Endpoint.\",\n",
" \"href\": \"/items/public.sentinel_mgrs\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" }\n",
" },\n",
" \"stac_extensions\": [\n",
" \"https://stac-extensions.github.io/table/v1.2.0/schema.json\"\n",
" ],\n",
" \"properties\": {\n",
" \"description\": null,\n",
" \"table:columns\": [\n",
" {\n",
" \"name\": \"geom\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" },\n",
" {\n",
" \"name\": \"id\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"ogc_fid\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" }\n",
" ],\n",
" \"table:primary_geometry\": \"geom\",\n",
" \"table:primary_datetime\": null\n",
" }\n",
"}\n",
"-infinity infinity\n",
"{\n",
" \"type\": \"Feature\",\n",
" \"stac_version\": \"1.0.0\",\n",
" \"id\": \"public.landsat_wrs\",\n",
" \"collection\": \"tipg\",\n",
" \"geometry\": {\n",
" \"type\": \"Polygon\",\n",
" \"geometry\": {\n",
" \"coordinates\": [\n",
" [\n",
" [\n",
" -180.0,\n",
" -82.64010620117188\n",
" ],\n",
" [\n",
" 180.0,\n",
" -82.64010620117188\n",
" ],\n",
" [\n",
" 180.0,\n",
" 82.64010620117188\n",
" ],\n",
" [\n",
" -180.0,\n",
" 82.64010620117188\n",
" ],\n",
" [\n",
" -180.0,\n",
" -82.64010620117188\n",
" ]\n",
" ]\n",
" ]\n",
" }\n",
" },\n",
" \"bbox\": [\n",
" -180.0,\n",
" -82.64010620117188,\n",
" 180.0,\n",
" 82.64010620117188\n",
" ],\n",
" \"links\": [],\n",
" \"assets\": {\n",
" \"features\": {\n",
" \"title\": \"OGC Feature Service\",\n",
" \"description\": \"OGC Feature Service Endpoint.\",\n",
" \"href\": \"/items/public.landsat_wrs\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" },\n",
" \"vectortiles\": {\n",
" \"title\": \"OGC Vector Tiles\",\n",
" \"description\": \"OGC Vector Tiles Endpoint.\",\n",
" \"href\": \"/items/public.landsat_wrs\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" }\n",
" },\n",
" \"stac_extensions\": [\n",
" \"https://stac-extensions.github.io/table/v1.2.0/schema.json\"\n",
" ],\n",
" \"properties\": {\n",
" \"description\": null,\n",
" \"table:columns\": [\n",
" {\n",
" \"name\": \"geom\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" },\n",
" {\n",
" \"name\": \"id\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"ogc_fid\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"path\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"pr\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"row\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" }\n",
" ],\n",
" \"table:primary_geometry\": \"geom\",\n",
" \"table:primary_datetime\": null\n",
" }\n",
"}\n",
"-infinity infinity\n",
"{\n",
" \"type\": \"Feature\",\n",
" \"stac_version\": \"1.0.0\",\n",
" \"id\": \"public.countries\",\n",
" \"collection\": \"tipg\",\n",
" \"geometry\": {\n",
" \"type\": \"Polygon\",\n",
" \"geometry\": {\n",
" \"coordinates\": [\n",
" [\n",
" [\n",
" -180.0,\n",
" -89.99893188476562\n",
" ],\n",
" [\n",
" 180.0,\n",
" -89.99893188476562\n",
" ],\n",
" [\n",
" 180.0,\n",
" 83.599609375\n",
" ],\n",
" [\n",
" -180.0,\n",
" 83.599609375\n",
" ],\n",
" [\n",
" -180.0,\n",
" -89.99893188476562\n",
" ]\n",
" ]\n",
" ]\n",
" }\n",
" },\n",
" \"bbox\": [\n",
" -180.0,\n",
" -89.99893188476562,\n",
" 180.0,\n",
" 83.599609375\n",
" ],\n",
" \"links\": [],\n",
" \"assets\": {\n",
" \"features\": {\n",
" \"title\": \"OGC Feature Service\",\n",
" \"description\": \"OGC Feature Service Endpoint.\",\n",
" \"href\": \"/items/public.countries\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" },\n",
" \"vectortiles\": {\n",
" \"title\": \"OGC Vector Tiles\",\n",
" \"description\": \"OGC Vector Tiles Endpoint.\",\n",
" \"href\": \"/items/public.countries\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" }\n",
" },\n",
" \"stac_extensions\": [\n",
" \"https://stac-extensions.github.io/table/v1.2.0/schema.json\"\n",
" ],\n",
" \"properties\": {\n",
" \"description\": null,\n",
" \"table:columns\": [\n",
" {\n",
" \"name\": \"abbrev\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"abbrev_len\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"adm0_a3\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"adm0_a3_is\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"adm0_a3_un\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"adm0_a3_us\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"adm0_a3_wb\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"adm0_dif\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"admin\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"brk_a3\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"brk_diff\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"brk_group\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"brk_name\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"continent\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"economy\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"featurecla\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"fips_10_\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"formal_en\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"formal_fr\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"gdp_md_est\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"gdp_year\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"geom\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" },\n",
" {\n",
" \"name\": \"geou_dif\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"geounit\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"gid\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"gu_a3\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"homepart\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"income_grp\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"iso_a2\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"iso_a3\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"iso_a3_eh\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"iso_n3\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"labelrank\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"lastcensus\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"level\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"long_len\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"mapcolor13\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"mapcolor7\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"mapcolor8\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"mapcolor9\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"max_label\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"min_label\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"min_zoom\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"name\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_alt\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_ar\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_bn\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_ciawf\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_de\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_el\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_en\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_es\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_fr\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_hi\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_hu\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_id\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_it\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_ja\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_ko\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_len\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"name_long\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_nl\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_pl\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_pt\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_ru\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_sort\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_sv\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_tr\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_vi\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"name_zh\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"ne_id\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"note_adm0\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"note_brk\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"pop_est\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"pop_rank\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"pop_year\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"postal\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"region_un\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"region_wb\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"scalerank\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"sov_a3\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"sovereignt\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"su_a3\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"su_dif\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"subregion\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"subunit\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"tiny\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"type\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"un_a3\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"wb_a2\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"wb_a3\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"wikidataid\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"wikipedia\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"woe_id\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"woe_id_eh\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"woe_note\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" }\n",
" ],\n",
" \"table:primary_geometry\": \"geom\",\n",
" \"table:primary_datetime\": null\n",
" }\n",
"}\n",
"-infinity infinity\n",
"{\n",
" \"type\": \"Feature\",\n",
" \"stac_version\": \"1.0.0\",\n",
" \"id\": \"public.postgis_srs\",\n",
" \"collection\": \"tipg\",\n",
" \"geometry\": {\n",
" \"type\": \"Polygon\",\n",
" \"geometry\": {\n",
" \"coordinates\": [\n",
" [\n",
" [\n",
" -180.0,\n",
" -90.0\n",
" ],\n",
" [\n",
" 180.0,\n",
" -90.0\n",
" ],\n",
" [\n",
" 180.0,\n",
" 90.0\n",
" ],\n",
" [\n",
" -180.0,\n",
" 90.0\n",
" ],\n",
" [\n",
" -180.0,\n",
" -90.0\n",
" ]\n",
" ]\n",
" ]\n",
" }\n",
" },\n",
" \"bbox\": [\n",
" -180.0,\n",
" -90.0,\n",
" 180.0,\n",
" 90.0\n",
" ],\n",
" \"links\": [],\n",
" \"assets\": {\n",
" \"features\": {\n",
" \"title\": \"OGC Feature Service\",\n",
" \"description\": \"OGC Feature Service Endpoint.\",\n",
" \"href\": \"/items/public.postgis_srs\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" },\n",
" \"vectortiles\": {\n",
" \"title\": \"OGC Vector Tiles\",\n",
" \"description\": \"OGC Vector Tiles Endpoint.\",\n",
" \"href\": \"/items/public.postgis_srs\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" }\n",
" },\n",
" \"stac_extensions\": [\n",
" \"https://stac-extensions.github.io/table/v1.2.0/schema.json\"\n",
" ],\n",
" \"properties\": {\n",
" \"description\": null,\n",
" \"table:columns\": [\n",
" {\n",
" \"name\": \"auth_name\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"auth_srid\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"point_ne\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" },\n",
" {\n",
" \"name\": \"point_sw\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" },\n",
" {\n",
" \"name\": \"proj4text\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"srname\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"srtext\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" }\n",
" ],\n",
" \"table:primary_geometry\": \"point_ne\",\n",
" \"table:primary_datetime\": null\n",
" }\n",
"}\n",
"-infinity infinity\n",
"{\n",
" \"type\": \"Feature\",\n",
" \"stac_version\": \"1.0.0\",\n",
" \"id\": \"public.postgis_srs_all\",\n",
" \"collection\": \"tipg\",\n",
" \"geometry\": {\n",
" \"type\": \"Polygon\",\n",
" \"geometry\": {\n",
" \"coordinates\": [\n",
" [\n",
" [\n",
" -180.0,\n",
" -90.0\n",
" ],\n",
" [\n",
" 180.0,\n",
" -90.0\n",
" ],\n",
" [\n",
" 180.0,\n",
" 90.0\n",
" ],\n",
" [\n",
" -180.0,\n",
" 90.0\n",
" ],\n",
" [\n",
" -180.0,\n",
" -90.0\n",
" ]\n",
" ]\n",
" ]\n",
" }\n",
" },\n",
" \"bbox\": [\n",
" -180.0,\n",
" -90.0,\n",
" 180.0,\n",
" 90.0\n",
" ],\n",
" \"links\": [],\n",
" \"assets\": {\n",
" \"features\": {\n",
" \"title\": \"OGC Feature Service\",\n",
" \"description\": \"OGC Feature Service Endpoint.\",\n",
" \"href\": \"/items/public.postgis_srs_all\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" },\n",
" \"vectortiles\": {\n",
" \"title\": \"OGC Vector Tiles\",\n",
" \"description\": \"OGC Vector Tiles Endpoint.\",\n",
" \"href\": \"/items/public.postgis_srs_all\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" }\n",
" },\n",
" \"stac_extensions\": [\n",
" \"https://stac-extensions.github.io/table/v1.2.0/schema.json\"\n",
" ],\n",
" \"properties\": {\n",
" \"description\": null,\n",
" \"table:columns\": [\n",
" {\n",
" \"name\": \"auth_name\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"auth_srid\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"point_ne\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" },\n",
" {\n",
" \"name\": \"point_sw\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" },\n",
" {\n",
" \"name\": \"proj4text\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"srname\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"srtext\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" }\n",
" ],\n",
" \"table:primary_geometry\": \"point_ne\",\n",
" \"table:primary_datetime\": null\n",
" }\n",
"}\n",
"-infinity infinity\n",
"{\n",
" \"type\": \"Feature\",\n",
" \"stac_version\": \"1.0.0\",\n",
" \"id\": \"public.postgis_srs_search\",\n",
" \"collection\": \"tipg\",\n",
" \"geometry\": {\n",
" \"type\": \"Polygon\",\n",
" \"geometry\": {\n",
" \"coordinates\": [\n",
" [\n",
" [\n",
" -180.0,\n",
" -90.0\n",
" ],\n",
" [\n",
" 180.0,\n",
" -90.0\n",
" ],\n",
" [\n",
" 180.0,\n",
" 90.0\n",
" ],\n",
" [\n",
" -180.0,\n",
" 90.0\n",
" ],\n",
" [\n",
" -180.0,\n",
" -90.0\n",
" ]\n",
" ]\n",
" ]\n",
" }\n",
" },\n",
" \"bbox\": [\n",
" -180.0,\n",
" -90.0,\n",
" 180.0,\n",
" 90.0\n",
" ],\n",
" \"links\": [],\n",
" \"assets\": {\n",
" \"features\": {\n",
" \"title\": \"OGC Feature Service\",\n",
" \"description\": \"OGC Feature Service Endpoint.\",\n",
" \"href\": \"/items/public.postgis_srs_search\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" },\n",
" \"vectortiles\": {\n",
" \"title\": \"OGC Vector Tiles\",\n",
" \"description\": \"OGC Vector Tiles Endpoint.\",\n",
" \"href\": \"/items/public.postgis_srs_search\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" }\n",
" },\n",
" \"stac_extensions\": [\n",
" \"https://stac-extensions.github.io/table/v1.2.0/schema.json\"\n",
" ],\n",
" \"properties\": {\n",
" \"description\": null,\n",
" \"table:columns\": [\n",
" {\n",
" \"name\": \"auth_name\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"auth_srid\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"point_ne\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" },\n",
" {\n",
" \"name\": \"point_sw\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" },\n",
" {\n",
" \"name\": \"proj4text\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"srname\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" },\n",
" {\n",
" \"name\": \"srtext\",\n",
" \"description\": null,\n",
" \"type\": \"string\"\n",
" }\n",
" ],\n",
" \"table:primary_geometry\": \"point_ne\",\n",
" \"table:primary_datetime\": null\n",
" }\n",
"}\n",
"-infinity infinity\n",
"{\n",
" \"type\": \"Feature\",\n",
" \"stac_version\": \"1.0.0\",\n",
" \"id\": \"public.st_subdivide\",\n",
" \"collection\": \"tipg\",\n",
" \"geometry\": {\n",
" \"type\": \"Polygon\",\n",
" \"geometry\": {\n",
" \"coordinates\": [\n",
" [\n",
" [\n",
" -180.0,\n",
" -90.0\n",
" ],\n",
" [\n",
" 180.0,\n",
" -90.0\n",
" ],\n",
" [\n",
" 180.0,\n",
" 90.0\n",
" ],\n",
" [\n",
" -180.0,\n",
" 90.0\n",
" ],\n",
" [\n",
" -180.0,\n",
" -90.0\n",
" ]\n",
" ]\n",
" ]\n",
" }\n",
" },\n",
" \"bbox\": [\n",
" -180.0,\n",
" -90.0,\n",
" 180.0,\n",
" 90.0\n",
" ],\n",
" \"links\": [],\n",
" \"assets\": {\n",
" \"features\": {\n",
" \"title\": \"OGC Feature Service\",\n",
" \"description\": \"OGC Feature Service Endpoint.\",\n",
" \"href\": \"/items/public.st_subdivide\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" },\n",
" \"vectortiles\": {\n",
" \"title\": \"OGC Vector Tiles\",\n",
" \"description\": \"OGC Vector Tiles Endpoint.\",\n",
" \"href\": \"/items/public.st_subdivide\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" }\n",
" },\n",
" \"stac_extensions\": [\n",
" \"https://stac-extensions.github.io/table/v1.2.0/schema.json\"\n",
" ],\n",
" \"properties\": {\n",
" \"description\": null,\n",
" \"table:columns\": [\n",
" {\n",
" \"name\": \"st_subdivide\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" }\n",
" ],\n",
" \"table:primary_geometry\": \"st_subdivide\",\n",
" \"table:primary_datetime\": null\n",
" }\n",
"}\n",
"-infinity infinity\n",
"{\n",
" \"type\": \"Feature\",\n",
" \"stac_version\": \"1.0.0\",\n",
" \"id\": \"public.st_hexagongrid\",\n",
" \"collection\": \"tipg\",\n",
" \"geometry\": {\n",
" \"type\": \"Polygon\",\n",
" \"geometry\": {\n",
" \"coordinates\": [\n",
" [\n",
" [\n",
" -180.0,\n",
" -90.0\n",
" ],\n",
" [\n",
" 180.0,\n",
" -90.0\n",
" ],\n",
" [\n",
" 180.0,\n",
" 90.0\n",
" ],\n",
" [\n",
" -180.0,\n",
" 90.0\n",
" ],\n",
" [\n",
" -180.0,\n",
" -90.0\n",
" ]\n",
" ]\n",
" ]\n",
" }\n",
" },\n",
" \"bbox\": [\n",
" -180.0,\n",
" -90.0,\n",
" 180.0,\n",
" 90.0\n",
" ],\n",
" \"links\": [],\n",
" \"assets\": {\n",
" \"features\": {\n",
" \"title\": \"OGC Feature Service\",\n",
" \"description\": \"OGC Feature Service Endpoint.\",\n",
" \"href\": \"/items/public.st_hexagongrid\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" },\n",
" \"vectortiles\": {\n",
" \"title\": \"OGC Vector Tiles\",\n",
" \"description\": \"OGC Vector Tiles Endpoint.\",\n",
" \"href\": \"/items/public.st_hexagongrid\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" }\n",
" },\n",
" \"stac_extensions\": [\n",
" \"https://stac-extensions.github.io/table/v1.2.0/schema.json\"\n",
" ],\n",
" \"properties\": {\n",
" \"description\": null,\n",
" \"table:columns\": [\n",
" {\n",
" \"name\": \"geom\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" },\n",
" {\n",
" \"name\": \"i\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"j\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" }\n",
" ],\n",
" \"table:primary_geometry\": \"geom\",\n",
" \"table:primary_datetime\": null\n",
" }\n",
"}\n",
"-infinity infinity\n",
"{\n",
" \"type\": \"Feature\",\n",
" \"stac_version\": \"1.0.0\",\n",
" \"id\": \"public.st_squaregrid\",\n",
" \"collection\": \"tipg\",\n",
" \"geometry\": {\n",
" \"type\": \"Polygon\",\n",
" \"geometry\": {\n",
" \"coordinates\": [\n",
" [\n",
" [\n",
" -180.0,\n",
" -90.0\n",
" ],\n",
" [\n",
" 180.0,\n",
" -90.0\n",
" ],\n",
" [\n",
" 180.0,\n",
" 90.0\n",
" ],\n",
" [\n",
" -180.0,\n",
" 90.0\n",
" ],\n",
" [\n",
" -180.0,\n",
" -90.0\n",
" ]\n",
" ]\n",
" ]\n",
" }\n",
" },\n",
" \"bbox\": [\n",
" -180.0,\n",
" -90.0,\n",
" 180.0,\n",
" 90.0\n",
" ],\n",
" \"links\": [],\n",
" \"assets\": {\n",
" \"features\": {\n",
" \"title\": \"OGC Feature Service\",\n",
" \"description\": \"OGC Feature Service Endpoint.\",\n",
" \"href\": \"/items/public.st_squaregrid\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" },\n",
" \"vectortiles\": {\n",
" \"title\": \"OGC Vector Tiles\",\n",
" \"description\": \"OGC Vector Tiles Endpoint.\",\n",
" \"href\": \"/items/public.st_squaregrid\",\n",
" \"roles\": [\n",
" \"data\"\n",
" ]\n",
" }\n",
" },\n",
" \"stac_extensions\": [\n",
" \"https://stac-extensions.github.io/table/v1.2.0/schema.json\"\n",
" ],\n",
" \"properties\": {\n",
" \"description\": null,\n",
" \"table:columns\": [\n",
" {\n",
" \"name\": \"geom\",\n",
" \"description\": null,\n",
" \"type\": \"object\"\n",
" },\n",
" {\n",
" \"name\": \"i\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" },\n",
" {\n",
" \"name\": \"j\",\n",
" \"description\": null,\n",
" \"type\": \"number\"\n",
" }\n",
" ],\n",
" \"table:primary_geometry\": \"geom\",\n",
" \"table:primary_datetime\": null\n",
" }\n",
"}\n"
]
}
],
"source": [
"from tipg.collections import get_collection_index\n",
"from buildpg import asyncpg\n",
"from tipg.database import connection_factory\n",
"import json\n",
"\n",
"def box2geojson(box):\n",
" return {\n",
" \"type\": \"Polygon\",\n",
" \"geometry\": {\n",
" \"coordinates\": [[\n",
" [box[0],box[1]],\n",
" [box[2],box[1]],\n",
" [box[2],box[3]],\n",
" [box[0],box[3]],\n",
" [box[0],box[1]]\n",
" ]]\n",
" }\n",
" }\n",
"\n",
"con_init=connection_factory()\n",
"pool = await asyncpg.create_pool_b(init=con_init)\n",
"idx = await get_collection_index(pool)\n",
"for c in idx['collections'].values():\n",
" extent = c.extent\n",
" spatial = extent.spatial\n",
" bbox = extent.spatial.bbox[0]\n",
" geom = box2geojson(bbox)\n",
" temporal = extent.temporal\n",
" if temporal is None:\n",
" start = '-infinity'\n",
" end = 'infinity'\n",
" else:\n",
" start = temporal.interval[0][0]\n",
" end = temporal.interval[0][1]\n",
" cols = [{\n",
" \"name\": col.name,\n",
" \"description\": col.description,\n",
" \"type\": col.json_type\n",
" } for col in c.properties]\n",
" print(start,end)\n",
" gcol = c.get_geometry_column()\n",
" if gcol:\n",
" gcolname = gcol.name\n",
" else:\n",
" gcolname = None\n",
" dcol = c.get_datetime_column()\n",
" if dcol:\n",
" dcolname = dcol.name\n",
" else:\n",
" dcolname = None\n",
"\n",
" feature = {\n",
" \"type\": \"Feature\",\n",
" \"stac_version\": \"1.0.0\",\n",
" \"id\": c.id,\n",
" \"collection\": \"tipg\",\n",
" \"geometry\": geom,\n",
" \"bbox\": bbox,\n",
" \"links\": [],\n",
" \"assets\": {\n",
" \"features\" : {\n",
" \"title\": \"OGC Feature Service\",\n",
" \"description\": \"OGC Feature Service Endpoint.\",\n",
" \"href\": f\"/collections/{c.id}/items\",\n",
" \"roles\": [\"data\"]\n",
" },\n",
" \"vectortiles\" : {\n",
" \"title\": \"OGC Vector Tiles\",\n",
" \"description\": \"OGC Vector Tiles Endpoint.\",\n",
" \"href\": f\"/collections/{c.id}/tiles\",\n",
" \"roles\": [\"data\"]\n",
" }\n",
" },\n",
" \"stac_extensions\": [\n",
" \"https://stac-extensions.github.io/table/v1.2.0/schema.json\"\n",
" ],\n",
" \"properties\":{\n",
" \"description\": c.description,\n",
" \"table:columns\": cols,\n",
" \"table:primary_geometry\": gcolname,\n",
" \"table:primary_datetime\": dcolname\n",
" }\n",
" }\n",
" print(json.dumps(feature, indent=2))\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "tipg",
"language": "python",
"name": "tipg"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment