[ckan-dev] Spatial search for datasets with dataset collection
Adrià Mercader
adria.mercader at okfn.org
Mon Jul 29 16:56:16 UTC 2013
Hi,
CKAN 2.X definitely supports spatial queries via the API. As shown on
the example in the ckanext-spatial documentation the endpoint for the
action api (v3) is /api/action/package_search.
Note as well that up to CKAN 2.0.1 the request needs to be a POST
request, as shown in these working examples on catalog.data.gov:
* BBox search (5132 results):
curl -XPOST -d '{"extras":{"ext_bbox":"-121,45,-120,46"}}'
http://catalog.data.gov/api/action/package_search
* BBox search within a collection (6 results):
curl -XPOST -d '{"fq":
"collection_package_id:b64c5a49-80bf-4fd2-ac7f-c2f7fe474ae6",
"extras":{"ext_bbox":"-121,45,-120,46"}}'
http://catalog.data.gov/api/action/package_search
(Note that the fq parameter is used for defining the collection id,
this is due to the implementation of this custom option on data.gov)
Not related to catalog.data.gov, as it uses a slightly older version,
but starting on CKAN 2.0.1 queries can be done via a GET request in
the following form:
curl http://demo.ckan.org/api/action/package_search?ext_bbox=-16.171875,38.8225909761771,12.65625,57.7041472343419
Hope this helps,
Adrià
On 22 July 2013 17:20, Fawcett, David (MNIT) <David.Fawcett at state.mn.us> wrote:
> I am not convinced that API spatial queries work with CKAN v2.0 (API v3). I
> would love to have someone demonstrate a working bbox query under API v3.
>
>
>
> Here is a challenge to the list: Please provide a simple example that
> confirms that spatial queries work via APIv3 and shows the correct syntax
> for using a spatial query to select packages/datasets. This example can be
> written against data.gov or any of the other public CKAN instances out
> there.
>
>
>
> Here is a little more information on my similar issue:
>
> I have a CKAN instance with the spatial extension installed.
>
> We have some datasets the include the ‘spatial’ metadata element
>
> Using the spatial extension gui, I can correctly find/select datasets based
> on their bbox
>
> I haven’t been able to produce an API request that selects the correct
> datasets.
>
>
>
> I put a question out to this list last week and haven’t received any
> responses. In trying to come up with a proper API request, I looked at the
> tests in ckanext-spatial. The tests are still written against version 2 of
> the API. This didn’t seem like a great sign to me…
>
>
>
> Thanks,
>
>
>
> David.
>
>
>
> From: ckan-dev-bounces at lists.okfn.org
> [mailto:ckan-dev-bounces at lists.okfn.org] On Behalf Of Tracy Harton
> Sent: Monday, July 22, 2013 12:32 AM
> To: ckan-dev at lists.okfn.org
> Subject: [ckan-dev] Spatial search for datasets with dataset collection
>
>
>
> I'm trying to search for datasets from a dataset collection, given an area
> of interest. This works interactively and the following returns 6 datasets
> as expected:
>
>
>
> http://catalog.data.gov/dataset?q=&collection_package_id=b64c5a49-80bf-4fd2-ac7f-c2f7fe474ae6&ext_bbox=-121,45,-120,46
>
>
>
> If I try to do an API call to retrieve the data as JSON, the following
> always returns 0 results, but no error, regardless of bbox:
>
>
>
> http://catalog.data.gov/api/search/dataset?q=&collection_package_id=b64c5a49-80bf-4fd2-ac7f-c2f7fe474ae6&ext_bbox=-121,45,-120,46
>
>
>
> Leaving off the bbox returns the entire collection as expected:
>
>
>
> http://catalog.data.gov/api/search/dataset?q=&collection_package_id=b64c5a49-80bf-4fd2-ac7f-c2f7fe474ae6
>
>
>
> For a package_search, which does work for ext_bbox, I am not able to filter
> by collection_package_id, only "q"
>
>
>
> So, is ext_bbox supported for this API search? Or is this a data.gov issue?
> Any help would be appreciated...
>
>
>
> /tracy
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
>
More information about the ckan-dev
mailing list