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

SemanticWeb
212
accept rate: 0%

2

Welcome

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
}
ORDER BY ?nm
link

answered 06 Dec '12, 04:48

SemanticWeb's gravatar image

SemanticWeb
212
accept rate: 0%

edited 06 Dec '12, 13:11

Rob%20Vesse's gravatar image

Rob Vesse ♦
13.6k1715

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))
} GROUP BY ?x
link

answered 10 Sep '13, 07:24

StefanOllinger's gravatar image

StefanOllinger
212
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

By RSS:

Answers

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

Tags:

×1,250
×10

Asked: 03 Dec '12, 03:57

Seen: 955 times

Last updated: 10 Sep '13, 07:24