Hello! We have saved the geonames in AllegroGraph as N-triple format. I would like to build SPARQL 1. to get the all the countries 2. to get all cities from a country I look forward for your answers. Thanks. Regards, Florin

asked 03 Dec '12, 03:57

SemanticWeb's gravatar image

accept rate: 0%



Could you be more specific? What queries have you tried? What results are you getting? Where exactly are you having difficulties?

(03 Dec '12, 04:31) Sweet Burlap Sweet%20Burlap's gravatar image

1.In geonames is difficult to identify which predicate and which object identifies a country (see my answer) 2. I don't know if there is any documenation on geonames that explains the meaning of the given featureCodes. For example A.PCLI denotes country. What code (if any denotes a city?)

(06 Dec '12, 04:54) SemanticWeb SemanticWeb's gravatar image

@SemanticWeb They appear to have a fairly comprehensive documentation on what feature codes mean - http://www.geonames.org/export/codes.html - They do not appear to have a specific code for city, PPL is the general code for any populated place.

(06 Dec '12, 13:14) Rob Vesse ♦ Rob%20Vesse's gravatar image

On one my colleague developed this query for getting the countries from geonames. Hope that will help others. Regards, Florin

PREFIX gnO:<http://www.geonames.org/ontology#>
SELECT ?s ?nm
  ?s gnO:featureCode gnO:A.PCLI .
  ?s gnO:name ?nm
permanent link

answered 06 Dec '12, 04:48

SemanticWeb's gravatar image

accept rate: 0%

edited 06 Dec '12, 13:11

Rob%20Vesse's gravatar image

Rob Vesse ♦

You can also use the IN operator:

SELECT ?x MIN(?code) MIN(?name) MIN(?iso) WHERE {
  ?x gn:featureCode ?code ;
    gn:name ?name ;
    gn:countryCode ?iso .
  FILTER (?code IN (gn:A.PCL, gn:A.PCLD, gn:A.PCLF, gn:A.PCLI, gn:A.PCLIX, gn:A.PCLS, gn:A.TERR))
permanent link

answered 10 Sep '13, 07:24

StefanOllinger's gravatar image

accept rate: 0%

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: 03 Dec '12, 03:57

question was seen: 1,886 times

last updated: 10 Sep '13, 07:24