La plataforma BNB Linked Data proporciona acceso a la British National Bibliography (BNB) a través de un punto de acceso SPARQL.
Este notebook muestra cómo obtener obras y los lugares de publicación para crear un mapa interactivo.
import requests
import pandas as pd
import json
import csv
from pandas.io.json import json_normalize
import folium
url = 'https://bnb.data.bl.uk/sparql'
sentencia = """
PREFIX blt: <http://www.bl.uk/schemas/bibliographic/blterms#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX c4dm: <http://purl.org/NET/c4dm/event.owl#>
SELECT (count(?recurso) as ?total_obras) WHERE {
?recurso dct:title ?titulo .
?recurso blt:publication ?publicacion .
?publicacion c4dm:place ?lugar .
FILTER regex(?lugar, "geonames", "i")
}
"""
# usamos json como resultado
cabeceras = {'Accept': 'application/sparql-results+json'}
r = requests.get(url, params = {'format': 'application/sparql-results+json', 'query': sentencia}, headers=cabeceras)
print(r.text)
{ "head": { "link": [], "vars": ["total_obras"] }, "results": { "distinct": false, "ordered": true, "bindings": [ { "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4164098" }} ] } }
url = 'https://bnb.data.bl.uk/sparql'
sentencia = """
PREFIX blt: <http://www.bl.uk/schemas/bibliographic/blterms#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX c4dm: <http://purl.org/NET/c4dm/event.owl#>
SELECT (count(?recurso) as ?total_obras) WHERE {
?recurso dct:title ?titulo .
?recurso blt:publication ?publicacion .
?publicacion c4dm:place ?lugar .
}
"""
# usamos json como resultado
cabeceras = {'Accept': 'application/sparql-results+json'}
r = requests.get(url, params = {'format': 'application/sparql-results+json', 'query': sentencia}, headers=cabeceras)
print(r.text)
{ "head": { "link": [], "vars": ["total_obras"] }, "results": { "distinct": false, "ordered": true, "bindings": [ { "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "8565183" }} ] } }
url = 'https://bnb.data.bl.uk/sparql'
sentencia = """
PREFIX blt: <http://www.bl.uk/schemas/bibliographic/blterms#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX c4dm: <http://purl.org/NET/c4dm/event.owl#>
SELECT ?lugar (count(?recurso) as ?total_obras) WHERE {
?recurso dct:title ?titulo .
?recurso blt:publication ?publicacion .
?publicacion c4dm:place ?lugar .
FILTER regex(?lugar, "geonames", "i")
}
GROUP BY ?lugar
"""
# usamos json como resultado
cabeceras = {'Accept': 'application/sparql-results+json'}
r = requests.get(url, params = {'format': 'application/sparql-results+json', 'query': sentencia}, headers=cabeceras)
print(r.text)
{ "head": { "link": [], "vars": ["lugar", "total_obras"] }, "results": { "distinct": false, "ordered": true, "bindings": [ { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2635167/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "362170" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/6251999/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "14102" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2802361/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2931" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3017382/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3750" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1269750/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "10207" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2077456/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "22278" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2634895/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "73359" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2510769/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1637" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2328926/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "89" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/798544/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "722" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/617790/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1814991/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3172" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/953987/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2103" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1605651/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "237" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2017370/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "85" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3077311/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "124" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3489940/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "325" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2661886/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "456" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/878675/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "22" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3576916/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2960313/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "167" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/298795/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "48" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2245662/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "28" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1733045/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "119" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/289688/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "108" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/390903/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "90" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/798549/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "26" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3164670/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "6" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3144096/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "123" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/338010/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "10" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/719819/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "66" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1562822/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "12" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1327865/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "17" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2309096/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3686110/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "14" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1210997/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "26" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3277605/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "8" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3190538/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "10" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1966436/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "8" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3041565/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/337996/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "18" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1149361/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2400553/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/597427/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3202326/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "12" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1227603/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "13" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/4041685/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "6" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3580718/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3573591/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "9" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2461445/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2411586/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "5" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/895949/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "26" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/927384/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "8" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/145495/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3572887/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3578097/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2205218/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1252634/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2464461/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/718075/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3351879/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/934841/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3370751/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/142551/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/4020092/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/239880/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3508796/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/6269131/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2724867" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2921044/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "44284" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2638360/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "123811" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1880251/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "12941" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2641364/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "12166" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2782113/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "886" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/241170/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2413451/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "5" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1668284/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "100" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3895114/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "24" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/149590/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "24" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3374084/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "29" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2300660/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "21" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/130758/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "888" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2542007/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3469034/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "187" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/226074/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "40" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1694008/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "54" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2562770/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "34" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/453733/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "9" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/732800/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "21" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1835841/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "91" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/690791/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "12" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/290557/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "178" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/783754/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "53" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3378535/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "11" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/934292/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1643084/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "31" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/49518/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3577718/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1282988/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "10" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/614540/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "6" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2403846/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "7" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3576396/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/99237/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "6" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2629691/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "20" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3474414/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "7" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1062947/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "14" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3439705/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3355338/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "8" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2993457/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3580239/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1036973/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/248816/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "13" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2029969/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/285153/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2410758/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3562981/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3625428/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/4034894/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3575174/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/4043988/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3624060/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/6252001/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "589571" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2750405/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "35077" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2658434/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "42231" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3175395/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4216" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2963597/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "67033" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2186224/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1721" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1168579/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "347" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2623032/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "797" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/146669/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "15" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/4566966/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/294640/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "210" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/357994/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "545" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1861060/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1960" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3573345/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "6" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2139685/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "47" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/192950/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "106" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3996063/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "62" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1819730/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "128" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/285570/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3932488/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "18" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/102358/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "21" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2264397/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "53" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/6290252/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "18" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3923057/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3865483/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "19" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3042058/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "6" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/660013/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "42" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/272103/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "55" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/290291/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "5" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3194884/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "5" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2287781/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/286963/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "15" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2088628/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3057568/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3617476/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/2233387/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "7" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1282588/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1220409/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/932692/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/5880801/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "4" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1831722/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "5" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1655842/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3703430/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "6" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/366755/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/630336/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "5" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/458258/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/3582678/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1899402/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/203312/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/5854928/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/4030945/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "2" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/1475047/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/933860/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "3" }}, { "lugar": { "type": "uri", "value": "http://sws.geonames.org/163843/" } , "total_obras": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1" }} ] } }
bnbdatos = json.loads(r.text)
with open('bnb_registros_total.csv', 'w', newline='') as fichero:
csv_salida = csv.writer(fichero, delimiter = ',', quotechar = '"', quoting = csv.QUOTE_MINIMAL)
csv_salida.writerow(['id_geonames', 'total'])
for i in bnbdatos['results']['bindings']:
id_geonames = total= lat = lon = id_wikidata = etiqueta =''
id_geonames = i['lugar']['value']
total = i['total_obras']['value']
csv_salida.writerow([id_geonames, total])
df = pd.read_csv('bnb_registros_total.csv')
df.head()
id_geonames | total | |
---|---|---|
0 | http://sws.geonames.org/2635167/ | 362170 |
1 | http://sws.geonames.org/6251999/ | 14102 |
2 | http://sws.geonames.org/2802361/ | 2931 |
3 | http://sws.geonames.org/3017382/ | 3750 |
4 | http://sws.geonames.org/1269750/ | 10207 |
df['total'].sum()
4164098
df.count()
id_geonames 174 total 174 dtype: int64
lugares = pd.unique(df['id_geonames']).tolist()
cadena_lugares = ''
for a in sorted(lugares):
print(a)
cadena_lugares = cadena_lugares + ' \"' + a.replace("http://sws.geonames.org/", "").replace("/", "") + '\"'
http://sws.geonames.org/102358/ http://sws.geonames.org/1036973/ http://sws.geonames.org/1062947/ http://sws.geonames.org/1149361/ http://sws.geonames.org/1168579/ http://sws.geonames.org/1210997/ http://sws.geonames.org/1220409/ http://sws.geonames.org/1227603/ http://sws.geonames.org/1252634/ http://sws.geonames.org/1269750/ http://sws.geonames.org/1282588/ http://sws.geonames.org/1282988/ http://sws.geonames.org/130758/ http://sws.geonames.org/1327865/ http://sws.geonames.org/142551/ http://sws.geonames.org/145495/ http://sws.geonames.org/146669/ http://sws.geonames.org/1475047/ http://sws.geonames.org/149590/ http://sws.geonames.org/1562822/ http://sws.geonames.org/1605651/ http://sws.geonames.org/163843/ http://sws.geonames.org/1643084/ http://sws.geonames.org/1655842/ http://sws.geonames.org/1668284/ http://sws.geonames.org/1694008/ http://sws.geonames.org/1733045/ http://sws.geonames.org/1814991/ http://sws.geonames.org/1819730/ http://sws.geonames.org/1831722/ http://sws.geonames.org/1835841/ http://sws.geonames.org/1861060/ http://sws.geonames.org/1880251/ http://sws.geonames.org/1899402/ http://sws.geonames.org/192950/ http://sws.geonames.org/1966436/ http://sws.geonames.org/2017370/ http://sws.geonames.org/2029969/ http://sws.geonames.org/203312/ http://sws.geonames.org/2077456/ http://sws.geonames.org/2088628/ http://sws.geonames.org/2139685/ http://sws.geonames.org/2186224/ http://sws.geonames.org/2205218/ http://sws.geonames.org/2233387/ http://sws.geonames.org/2245662/ http://sws.geonames.org/226074/ http://sws.geonames.org/2264397/ http://sws.geonames.org/2287781/ http://sws.geonames.org/2300660/ http://sws.geonames.org/2309096/ http://sws.geonames.org/2328926/ http://sws.geonames.org/239880/ http://sws.geonames.org/2400553/ http://sws.geonames.org/2403846/ http://sws.geonames.org/2410758/ http://sws.geonames.org/2411586/ http://sws.geonames.org/241170/ http://sws.geonames.org/2413451/ http://sws.geonames.org/2461445/ http://sws.geonames.org/2464461/ http://sws.geonames.org/248816/ http://sws.geonames.org/2510769/ http://sws.geonames.org/2542007/ http://sws.geonames.org/2562770/ http://sws.geonames.org/2623032/ http://sws.geonames.org/2629691/ http://sws.geonames.org/2634895/ http://sws.geonames.org/2635167/ http://sws.geonames.org/2638360/ http://sws.geonames.org/2641364/ http://sws.geonames.org/2658434/ http://sws.geonames.org/2661886/ http://sws.geonames.org/272103/ http://sws.geonames.org/2750405/ http://sws.geonames.org/2782113/ http://sws.geonames.org/2802361/ http://sws.geonames.org/285153/ http://sws.geonames.org/285570/ http://sws.geonames.org/286963/ http://sws.geonames.org/289688/ http://sws.geonames.org/290291/ http://sws.geonames.org/290557/ http://sws.geonames.org/2921044/ http://sws.geonames.org/294640/ http://sws.geonames.org/2960313/ http://sws.geonames.org/2963597/ http://sws.geonames.org/298795/ http://sws.geonames.org/2993457/ http://sws.geonames.org/3017382/ http://sws.geonames.org/3041565/ http://sws.geonames.org/3042058/ http://sws.geonames.org/3057568/ http://sws.geonames.org/3077311/ http://sws.geonames.org/3144096/ http://sws.geonames.org/3164670/ http://sws.geonames.org/3175395/ http://sws.geonames.org/3190538/ http://sws.geonames.org/3194884/ http://sws.geonames.org/3202326/ http://sws.geonames.org/3277605/ http://sws.geonames.org/3351879/ http://sws.geonames.org/3355338/ http://sws.geonames.org/3370751/ http://sws.geonames.org/3374084/ http://sws.geonames.org/3378535/ http://sws.geonames.org/337996/ http://sws.geonames.org/338010/ http://sws.geonames.org/3439705/ http://sws.geonames.org/3469034/ http://sws.geonames.org/3474414/ http://sws.geonames.org/3489940/ http://sws.geonames.org/3508796/ http://sws.geonames.org/3562981/ http://sws.geonames.org/3572887/ http://sws.geonames.org/3573345/ http://sws.geonames.org/3573591/ http://sws.geonames.org/3575174/ http://sws.geonames.org/3576396/ http://sws.geonames.org/3576916/ http://sws.geonames.org/3577718/ http://sws.geonames.org/3578097/ http://sws.geonames.org/357994/ http://sws.geonames.org/3580239/ http://sws.geonames.org/3580718/ http://sws.geonames.org/3582678/ http://sws.geonames.org/3617476/ http://sws.geonames.org/3624060/ http://sws.geonames.org/3625428/ http://sws.geonames.org/366755/ http://sws.geonames.org/3686110/ http://sws.geonames.org/3703430/ http://sws.geonames.org/3865483/ http://sws.geonames.org/3895114/ http://sws.geonames.org/390903/ http://sws.geonames.org/3923057/ http://sws.geonames.org/3932488/ http://sws.geonames.org/3996063/ http://sws.geonames.org/4020092/ http://sws.geonames.org/4030945/ http://sws.geonames.org/4034894/ http://sws.geonames.org/4041685/ http://sws.geonames.org/4043988/ http://sws.geonames.org/453733/ http://sws.geonames.org/4566966/ http://sws.geonames.org/458258/ http://sws.geonames.org/49518/ http://sws.geonames.org/5854928/ http://sws.geonames.org/5880801/ http://sws.geonames.org/597427/ http://sws.geonames.org/614540/ http://sws.geonames.org/617790/ http://sws.geonames.org/6251999/ http://sws.geonames.org/6252001/ http://sws.geonames.org/6269131/ http://sws.geonames.org/6290252/ http://sws.geonames.org/630336/ http://sws.geonames.org/660013/ http://sws.geonames.org/690791/ http://sws.geonames.org/718075/ http://sws.geonames.org/719819/ http://sws.geonames.org/732800/ http://sws.geonames.org/783754/ http://sws.geonames.org/798544/ http://sws.geonames.org/798549/ http://sws.geonames.org/878675/ http://sws.geonames.org/895949/ http://sws.geonames.org/927384/ http://sws.geonames.org/932692/ http://sws.geonames.org/933860/ http://sws.geonames.org/934292/ http://sws.geonames.org/934841/ http://sws.geonames.org/953987/ http://sws.geonames.org/99237/
url = 'https://query.wikidata.org/sparql'
sentencia = """
PREFIX bibo: <http://purl.org/ontology/bibo/>
SELECT ?idgeonames ?lat ?lon ?x ?xLabel
WHERE {{
values ?idgeonames {{ {0} }}
?x wdt:P1566 ?idgeonames ;
p:P625 [
psv:P625 [
wikibase:geoLatitude ?lat ;
wikibase:geoLongitude ?lon ;
wikibase:geoGlobe ?globe ;
];
ps:P625 ?coord
]
SERVICE wikibase:label {{ bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }}
}}
"""
sentencia = sentencia.format(cadena_lugares)
print(sentencia)
r = requests.get(url, params = {'format': 'json', 'query': sentencia})
puntos_geo = r.json()
PREFIX bibo: <http://purl.org/ontology/bibo/> SELECT ?idgeonames ?lat ?lon ?x ?xLabel WHERE { values ?idgeonames { "102358" "1036973" "1062947" "1149361" "1168579" "1210997" "1220409" "1227603" "1252634" "1269750" "1282588" "1282988" "130758" "1327865" "142551" "145495" "146669" "1475047" "149590" "1562822" "1605651" "163843" "1643084" "1655842" "1668284" "1694008" "1733045" "1814991" "1819730" "1831722" "1835841" "1861060" "1880251" "1899402" "192950" "1966436" "2017370" "2029969" "203312" "2077456" "2088628" "2139685" "2186224" "2205218" "2233387" "2245662" "226074" "2264397" "2287781" "2300660" "2309096" "2328926" "239880" "2400553" "2403846" "2410758" "2411586" "241170" "2413451" "2461445" "2464461" "248816" "2510769" "2542007" "2562770" "2623032" "2629691" "2634895" "2635167" "2638360" "2641364" "2658434" "2661886" "272103" "2750405" "2782113" "2802361" "285153" "285570" "286963" "289688" "290291" "290557" "2921044" "294640" "2960313" "2963597" "298795" "2993457" "3017382" "3041565" "3042058" "3057568" "3077311" "3144096" "3164670" "3175395" "3190538" "3194884" "3202326" "3277605" "3351879" "3355338" "3370751" "3374084" "3378535" "337996" "338010" "3439705" "3469034" "3474414" "3489940" "3508796" "3562981" "3572887" "3573345" "3573591" "3575174" "3576396" "3576916" "3577718" "3578097" "357994" "3580239" "3580718" "3582678" "3617476" "3624060" "3625428" "366755" "3686110" "3703430" "3865483" "3895114" "390903" "3923057" "3932488" "3996063" "4020092" "4030945" "4034894" "4041685" "4043988" "453733" "4566966" "458258" "49518" "5854928" "5880801" "597427" "614540" "617790" "6251999" "6252001" "6269131" "6290252" "630336" "660013" "690791" "718075" "719819" "732800" "783754" "798544" "798549" "878675" "895949" "927384" "932692" "933860" "934292" "934841" "953987" "99237" } ?x wdt:P1566 ?idgeonames ; p:P625 [ psv:P625 [ wikibase:geoLatitude ?lat ; wikibase:geoLongitude ?lon ; wikibase:geoGlobe ?globe ; ]; ps:P625 ?coord ] SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
mapa_circulos = folium.Map(location=[20,0], tiles="OpenStreetMap", zoom_start=2)
for geo in puntos_geo['results']['bindings']:
idwikidata = geo['x']['value']
lat = geo['lat']['value']
lon = geo['lon']['value']
idgeonames = geo['idgeonames']['value']
etiqueta = geo['xLabel']['value']
total = df.loc[df['id_geonames'] == "http://sws.geonames.org/"+idgeonames+"/", ["total"]].values[0][0]
texto_popup = str(total) + " registros publicados en <a hreh='" + idwikidata + "'>" + etiqueta + "</a>"
folium.Circle(
location=[lat, lon],
popup=texto_popup,
radius=float(total)/10,
color='crimson',
fill=True,
fill_color='crimson'
).add_to(mapa_circulos)
mapa_circulos