ChuBL / OpenMindat

A Python package for the OpenMindat API.
https://pypi.org/project/openmindat/
Apache License 2.0
4 stars 2 forks source link

Mineral Occurence Endpoint #3

Closed fros1y closed 7 months ago

fros1y commented 8 months ago

Hello!

Thanks for the awesome work opening up this great data. The OpenMindat paper shows Mineral Occurrence records linking Mineral Species to Localities. Can end points for accessing that data be added to the API?

ChuBL commented 8 months ago

Hello! I am glad to hear this project helps.

The function you mentioned was already available from the API, though it was hard to find. Thank you for pointing it out.

I have updated the coding examples to the readme file for your reference.

Please let me know if you need more help using openmindat API.

Jiyin

fros1y commented 8 months ago

Thanks,

My use case here is trying to convert OpenMindat data into map layers usable in GIS analysis. I've been able to retrieve a list of locations, but that does not include any mineral occurrence data.

From the example you added to the README, it looks like something like

lr = openmindat.LocalitiesRetriever()
lr.expand("geomaterials")
lr.save()

should work. However, the results don't appear to be any different. when using the expand option. Am I missing something?

ChuBL commented 8 months ago

Bug Reproduction

I encountered problems running this code. Noticing that the function expand might result in many internal queries and crush the retrieval session, I tested an alternative code for single locality ID querying.

import openmindat
lr = openmindat.LocalitiesRetriever()
lr.id__in("6646").expand("geomaterials")
lr.saveto('./test/', 'test')

As you mentioned, the expand() function doesn't retrieve anything different from the retrieval without it. This is probably a problem from the API side. I will study it and discuss it with the API developers. Thank you for pointing it out.

Updating the Package

You might notice that the LocalitiesRetriever() class was problematic in the Pypi version of the package. We have fixed this issue; now you can import it in the manner shown in the examples. However, the updated code hasn't been published on the Pypi platform. To install the up-to-date version of this package, please clone this repo to your local environment, and run

pip install .

in your root directory of the cloned repo, which should look like:

/Users/YourUserName/.../OpenMindat/