I'm using python (jupyter notebook) to get data of hospitals in Bali area, Indonesia. Here is my code and query:

import pandas as pd
import requests
import json
overpass_api = "http://overpass-api.de/api/interpreter"

query_hospital = """
{{geocodeArea:'Provinsi Bali'}}->.searchArea;

response_hospital = requests.get(overpass_api, params={'data':query_hospital})

but when I run the next code,

data_hospital = response_hospital.json()

it returns error JSONDecodeError: Expecting value: line 1 column 1 (char 0)

the query works well in Overpass Turbo but when I put in notebook, it returns error.

Thanks for the help.

asked 08 May, 15:05

salmiah-ls's gravatar image

accept rate: 0%

edited 09 May, 23:43

check the status code of the query, it's returning 400. The .text says: Error: line 2: parse error: Unknown type "{", Error: line 2: parse error: An empty query is not allowed and Error: line 2: parse error: ';' expected - '{' found.

(08 May, 20:31) Marcos Dione

yes, I have the same thought. looks like python can't parse that double curly braces {{ }}.

I wonder if there is way to modify the query in OSM so it can return the same result but without that double curly braces.

(09 May, 05:53) salmiah-ls

I've found the solution.

I modify the query so I doesn't include the double curly braces {{ }} anymore, which seems python can't parse. Here is my new query:

query_hospital = """

or if we use area name in local language:

query_hospital = """
area['name:id'='Provinsi Bali'];

the query returns same result and python can parse it now.

permanent link

answered 09 May, 23:41

salmiah-ls's gravatar image

accept rate: 0%

edited 09 May, 23:57

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 08 May, 15:05

question was seen: 189 times

last updated: 09 May, 23:57

powered by OSQA