Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datasets by geometry #1031

Closed
alrocar opened this issue Sep 26, 2019 · 3 comments
Closed

Datasets by geometry #1031

alrocar opened this issue Sep 26, 2019 · 3 comments
Assignees

Comments

@alrocar
Copy link
Contributor

alrocar commented Sep 26, 2019

We have these two entities in the catalog

CREATE TABLE datasets
(
id TEXT  PRIMARY KEY ,
provider_id TEXT,
category_id TEXT,
data_source_id TEXT,
name TEXT,
description TEXT,
country_iso_code3 TEXT,
language_iso_code3 TEXT,
geography_id TEXT,


CREATE TABLE geographies
(
id TEXT PRIMARY KEY,
provider_id TEXT,
name TEXT,
description TEXT,
country_iso_code3 TEXT,
language_iso_code3 TEXT,
version TEXT,
geom_coverage GEOMETRY, -- admin,quadkey,zipcode...

Where geography_id is a FK.

Given a polygon, we want to be able to select the datasets in the catalog with available data for that region. Something like:

datasets = catalog.datasets(polygon)

The format of the polygon is yet to be defined (but it can be a shapely geometry).

We'd need to query the catalog with a query like this:

SELECT d.*
FROM geographies g
LEFT JOIN datasets d
ON g.id = d.geography_id
WHERE ST_Intersects(ST_geometryfromtext(local_polygon_wkt, 4326), geom_coverage)

So basically, convert the polygon to a WKT or WKB and perform the spatial intersection to get the list of datasets.

@alrocar
Copy link
Contributor Author

alrocar commented Sep 27, 2019

cc. @oleurud

@alasarr
Copy link
Contributor

alasarr commented Oct 7, 2019

First version working:

image

It only supports a dataset as input, but I'd like to add support to:

  • Pandas dataframe in WKT or WKB
  • GeoPandasDataFrame
  • Single geom in WKT

@alasarr
Copy link
Contributor

alasarr commented Oct 7, 2019

Just added support for WKT and GeoPandasDataFrame 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants