To solve
ImportError: cannot import name 'types' from 'geoarrow' (unknown location),
install geoarrow-types
.
ibis may also need geoarrow-c
to work with geoparquet now.
library(mapgl) | |
library(dplyr) | |
library(duckdbfs) | |
# This test file demonstrates that given a SQL query on the parquet version | |
# of the data, we can identify all the features included in the response and | |
# construct a maplibre filter that filters the corresponding features in | |
# the pmtiles vesion. | |
pmtiles <- "https://data.source.coop/cboettig/social-vulnerability/svi2020_us_tract.pmtiles" |
import ibis | |
from ibis import _ | |
import leafmap.maplibregl as leafmap | |
con = ibis.duckdb.connect(extensions=["spatial"]) | |
states = con.read_geo("https://raw.githubusercontent.com/PublicaMundi/MappingAPI/master/data/geojson/us-states.json") | |
## Add a fill-color column | |
import matplotlib.cm as cm | |
import matplotlib.colors as mcolors |
park = (con | |
.read_geo("/vsicurl/https://huggingface.co/datasets/cboettig/biodiversity/resolve/main/data/NPS.gdb") | |
.filter(_.UNIT_NAME == "Yosemite National Park") | |
.select(_.SHAPE) | |
.mutate(SHAPE = _.SHAPE.convert('EPSG:3857', 'EPSG:4326')) | |
.mutate(lng = _.SHAPE.centroid().x(), lat = _.SHAPE.centroid().y()) | |
.mutate(h1 = h3_latlng_to_cell(_.lat, _.lng, 1) ) | |
.mutate(neighbors = h3_grid_disk(_.h1, 1)) | |
#.mutate(cells = h3_polygon_wkt_to_cells_string(_.SHAPE.as_text(),1)) | |
) |
import streamlit as st | |
import os | |
#os.environ["OPENAI_API_KEY"] = st.secrets['OPENAI_API_KEY'] # for gpt | |
os.environ["OPENAI_API_KEY"] = st.secrets['LITELLM_KEY'] # for litellm | |
from pydantic import BaseModel, Field | |
class SQLResponse(BaseModel): | |
"""Defines the structure for SQL response.""" |
parquet = "https://espm-157-f24.github.io/spatial-carl-amanda-tyler/new_haven_stats.parquet" | |
# create sharable low-level connection, see: https://github.com/Mause/duckdb_engine | |
import sqlalchemy | |
eng = sqlalchemy.create_engine("duckdb:///:memory:") | |
# ibis can talk to this connection and create the VIEW | |
import ibis | |
con = ibis.duckdb.from_connection(eng.raw_connection()) |
%%time | |
import ibis | |
from ibis import _ | |
con = ibis.duckdb.connect() | |
endpoint="rook-ceph-rgw-nautiluss3.rook" | |
query= f''' | |
CREATE OR REPLACE SECRET secret2 ( |
import ibis | |
from ibis import _ | |
con = ibis.duckdb.connect() | |
# example query, could be anything | |
subset = (gbif | |
.filter(_["class"] == "Aves") | |
.rename(hex = "h8") | |
.group_by(_.hex) | |
.agg(n = _.count()) |
To solve
ImportError: cannot import name 'types' from 'geoarrow' (unknown location),
install geoarrow-types
.
ibis may also need geoarrow-c
to work with geoparquet now.
import os | |
from langchain_openai import ChatOpenAI | |
from langchain_core.prompts import ChatPromptTemplate | |
from langchain_core.runnables import ConfigurableField | |
from langchain_core.tools import tool | |
from langchain.agents import create_tool_calling_agent, AgentExecutor | |
@tool | |
def multiply(x: float, y: float) -> float: | |
"""Multiply 'x' times 'y'.""" | |
return x * y |
import ibis | |
con = ibis.duckdb.connect() | |
con.raw_sql(f''' | |
CREATE OR REPLACE SECRET secret ( | |
TYPE S3, | |
ENDPOINT 'sdsc.osn.xsede.org', | |
URL_STYLE 'path' | |
); |