Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6890771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:19:28+00:00 2026-05-27T06:19:28+00:00

The following code queries DBpedia for places within a bounded geographic area and returns

  • 0

The following code queries DBpedia for places within a bounded geographic area and returns the name, lat, and long of the place. I’d also like the query to return the category of the place–e.g., park, restaurant, museum, etc.

The following code works fine.

        sparql = SPARQLWrapper("http://dbpedia.org/sparql")
        sparql.setQuery("""
        PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
        PREFIX dbo: <http://dbpedia.org/ontology/>
        PREFIX category: <http://dbpedia.org/resource/Category:>
        SELECT * WHERE {
        ?s a dbo:Place .
        ?s geo:lat ?lat .
        ?s geo:long ?long .

I tried to add the following code to get categories for places, but this doesn’t work:

        ?s category:cat ?cat .

What should I add/change? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:19:29+00:00Added an answer on May 27, 2026 at 6:19 am

    You can get the category of a place (assuming you mean the type) by finding the type (rdfs:type) or the subject (dcterms:subject) of a resource. In DBPedia the first relates to the DBPedia and Yago ontologies and the second is a SKOS hierarchy in DBPedia. Here is an example query:

     PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
     PREFIX dbo: <http://dbpedia.org/ontology/>
     PREFIX dcterms: <http://purl.org/dc/terms/>
            SELECT * WHERE {
            ?s a dbo:Place .
            ?s geo:lat ?lat .
            ?s geo:long ?long .
            ?s a ?type . 
            ?s dcterms:subject ?sub
    } 
    

    Note that you will get multiple types and subjects for each place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code queries a Google fusion table based on a circular map region.
I can use the following code for tiny little queries: DECLARE @sql VARCHAR(8000) SET
I'm doing a small test. The following code runs 3 random queries 1000 times
i have the following code that queries a db and populates a datatable. private
I'm using the following code pattern to run some queries on a third party
I have the following code, which generates insert queries For Each f As String
How many database queries will be executed for the following code: q = SomeModel.objects.filter(pk__in=ids)
I use select queries as by following code: $params = array( 'username' => 'root',
I am trying to sort a xml using linq queries using the following code
Following code iterates through many data-rows, calcs some score per row and then sorts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.