init depot renew
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import requests
|
||||
import geopandas as gpd
|
||||
|
||||
|
||||
def get_orb_token():
|
||||
login = 'cgeier'
|
||||
pwd = 'adm1n*cEn38'
|
||||
url = "https://donnees.biodiversite-auvergne-rhone-alpes.fr/api/auth/login"
|
||||
return requests.post(
|
||||
url,
|
||||
json={"login": login, "password": pwd},
|
||||
headers={'Content-Type': 'application/json'}
|
||||
)
|
||||
|
||||
|
||||
def get_orb_sp(tok, params: dict = None, geo=None):
|
||||
import json
|
||||
print("LOAD ORB DATA ...")
|
||||
url = "https://donnees.biodiversite-auvergne-rhone-alpes.fr/api/synthese/for_web?"
|
||||
if geo:
|
||||
params += {
|
||||
# "geoIntersection":{"type":"Feature","properties":{},"geometry":_json_geo['features'][0]['geometry']},
|
||||
"geoIntersection": geo.to_crs(4326).unary_union.wkt,
|
||||
"with_areas": False
|
||||
}
|
||||
|
||||
res = requests.post(
|
||||
url,
|
||||
headers={'Content-Type': 'application/json'},
|
||||
cookies=tok.cookies,
|
||||
json=params)
|
||||
|
||||
_orb_geo = gpd.read_file(res.text)
|
||||
orb_geo = (
|
||||
_orb_geo[_orb_geo.geom_type == 'Point']
|
||||
.reset_index(drop=True)
|
||||
.to_crs(2154))
|
||||
|
||||
orb_geo['cd_nom'] = [
|
||||
[cd['cd_nom'] for cd in json.loads(o)]
|
||||
for o in orb_geo.observations
|
||||
]
|
||||
orb = orb_geo.explode('cd_nom')
|
||||
# orb.drop(['observations','cd_nom'],axis=1,inplace=True)
|
||||
|
||||
return orb
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
tok = get_orb_token()
|
||||
orb = get_orb_sp(tok, params={'regne': 'Animalia'})
|
||||
Reference in New Issue
Block a user