---
title: "OpenDataGouv : Transaction immobilière sur Biot"
url: https://www.cyber-neurones.org/2019/04/opendatagouv-transaction-immobiliere-sur-biot/
date: 2019-04-28
modified: 2019-04-28
author: "Frederic"
description: "En quelques étapes ... Etape 1: Voir un tweet passer de @ollybret : Etape 2 : Vérifier l'information sur @datagouvfr : le lien étant : https://www.data.gouv.fr/fr/datasets/demandes-de-valeurs-foncieres/  Et se faire un..."
categories:
  - "BIOT"
tags:
  - "inondation"
  - "OpenData"
  - "Python"
word_count: 386
---

# OpenDataGouv : Transaction immobilière sur Biot

En quelques étapes ...

**Etape 1**: Voir un tweet passer de [@**ollybret**](https://twitter.com/ollybret) :

[![](https://www.cyber-neurones.org/wp-content/uploads/2019/04/capture-decran-2019-04-28-a-10-39-32.png)](https://www.cyber-neurones.org/wp-content/uploads/2019/04/capture-decran-2019-04-28-a-10-39-32.png)

**Etape 2** : Vérifier l'information sur [@**datagouvfr**](https://twitter.com/datagouvfr) : le lien étant : [https://www.data.gouv.fr/fr/datasets/demandes-de-valeurs-foncieres/ ](https://www.data.gouv.fr/fr/datasets/demandes-de-valeurs-foncieres/)

Et se faire un profil :

[![](https://www.cyber-neurones.org/wp-content/uploads/2019/04/capture-decran-2019-04-28-a-10-47-52.png)](https://www.cyber-neurones.org/wp-content/uploads/2019/04/capture-decran-2019-04-28-a-10-47-52.png)

**Etape 3** : Voir du **JSON** : Micro-API DVF (Demande de Valeurs Foncières) et une API :

- [https://www.data.gouv.fr/fr/reuses/micro-api-dvf-demande-de-valeurs-foncieres/ ](https://www.data.gouv.fr/fr/reuses/micro-api-dvf-demande-de-valeurs-foncieres/)

Voir même le résultat en fonction de la commune ou du code postal :

- http://api.cquest.org/dvf?code_commune=94068 ( code_commune = code INSEE de la commune (ex: 94068) )
- http://api.cquest.org/dvf?code_postal=89110 ( code_postal = code postal )

Superbe travail de Christian Quest ( sur Twitter [@**cq94** ](https://twitter.com/cq94)‏) avec en plus la mise du code sur GitHub : [https://github.com/cquest/dvf_as_api](https://github.com/cquest/dvf_as_api) .( [@**github**](https://twitter.com/github) )

**Etape 4** : Sortir le python ( [@**ThePSF**](https://twitter.com/ThePSF) ) et se faire une petite carte sur Biot :
**$ python3 API_DVF_ToStaticMapColor.py**
Number total of request 1
Number total of pin 2598 Before date 624 After date 1974

Et publier les sources ([ https://github.com/CYBERNEURONES/Python](https://github.com/CYBERNEURONES/Python) )  : les conditions d'utilisations : [http://data.cquest.org/dgfip_dvf/conditions-generales-dutilisation.pdf.](http://data.cquest.org/dgfip_dvf/conditions-generales-dutilisation.pdf.)
#
# for Python 3
#
# ARIAS Frederic
# Sorry ... It's difficult for me the python :)
#

from time import gmtime, strftime
import time
import json
import requests
from datetime import *
from staticmap import StaticMap, CircleMarker

m = StaticMap(1100, 1100, url_template='http://a.tile.osm.org/{z}/{x}/{y}.png')

**codepostal = "06410"
date_inondation = datetime.strptime("2015-10-03",'%Y-%m-%d')**
nb_request = 0
nb_plot = 0
after_inondation = 0
before_inondation = 0
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
url_notes = (
"http://api.cquest.org/dvf?"
"code_postal="+codepostal
)
try:
resp = requests.get(url_notes, headers=headers)
nb_request += 1
resp.raise_for_status()
resp_dict = resp.json()
#print(resp_dict);
for my_resource in resp_dict['resultats']:
#print(my_resource)
long = my_resource.get('lon')
lat = my_resource.get('lat')
my_date = datetime.strptime(my_resource.get('date_mutation'),'%Y-%m-%d')
if (long) and (lat):
nb_plot += 1
#print("Long:",float(long),"Lat:",float(lat),"Date:",my_date);
if my_date > date_inondation :
marker = CircleMarker((float(long), float(lat)), '#0036FF', 8)
after_inondation += 1
else :
marker = CircleMarker((float(long), float(lat)), '#FF3600', 8)
before_inondation += 1
m.add_marker(marker)
except requests.exceptions.HTTPError as e:
print("Bad HTTP status code:", e)
except requests.exceptions.RequestException as e:
print("Network error:", e)

image = m.render(zoom=13)
image.save('mymap_zoom13_col.png')
image = m.render(zoom=14)
image.save('mymap_zoom14_col.png')
image = m.render(zoom=15)
image.save('mymap_zoom15_col.png')

print ("Number total of request",nb_request)
print ("Number total of pin",nb_plot,"Before date",before_inondation,"After date",after_inondation)

**Etape n°5 :** Voir le résultat :

[![](https://www.cyber-neurones.org/wp-content/uploads/2019/04/mymap_zoom14_col-1024x1024.png)](https://www.cyber-neurones.org/wp-content/uploads/2019/04/mymap_zoom14_col.png)

A la base je voulais localiser les achats du Fond Barnier, mais je n'ai rien trouvé ... sniff.

J'ai aussi fait un programme ( [https://github.com/CYBERNEURONES/Python/blob/master/API_DVF_ToStaticMapColor_V2.py](https://github.com/CYBERNEURONES/Python/blob/master/API_DVF_ToStaticMapColor_V2.py) )  pour travailler avec le code insee .... mais pas mieux :

[![](https://www.cyber-neurones.org/wp-content/uploads/2019/04/mymap_biot_zoom14_col-1024x1024.png)](https://www.cyber-neurones.org/wp-content/uploads/2019/04/mymap_biot_zoom14_col.png)Toutes les données

[![](https://www.cyber-neurones.org/wp-content/uploads/2019/04/mymap_biot_adjudication_expro_zoom14_col-1024x1024.png)](https://www.cyber-neurones.org/wp-content/uploads/2019/04/mymap_biot_adjudication_expro_zoom14_col.png)Expropriation, Adjudication.

A suivre ...