Page MenuHomePhabricator

Display point features (coordinates) from the results of a SPARQL query on a map in Wikipedia
Closed, ResolvedPublic

Assigned To
Authored By
Ayack
Feb 26 2018, 6:12 PM
Referenced Files
F35544570: Screenshot 2022-10-02 at 23.16.59.png
Oct 2 2022, 10:19 PM
F35544571: Screenshot 2022-10-02 at 23.17.07.png
Oct 2 2022, 10:19 PM
F35544572: Screenshot 2022-10-02 at 23.17.13.png
Oct 2 2022, 10:19 PM
Tokens
"Like" token, awarded by Pcoombe."Mountain of Wealth" token, awarded by geraki."Mountain of Wealth" token, awarded by Sabas88."Burninate" token, awarded by Rehman."Burninate" token, awarded by Spinster."Like" token, awarded by Liuxinyu970226.

Description

On https://query.wikidata.org/, you can easily display the result of a query on a dynamic map (see the Venues in Broadway for example). But if you want to add this map to Wikipedia or any other Wikimedia project, you can't (except if you take a screenshot..).

Related Objects

StatusSubtypeAssignedTask
OpenNone
ResolvedECohen_WMDE
ResolvedNone
Resolvedlilients_WMDE
Resolvedlilients_WMDE
ResolvedAndrew-WMDE
ResolvedNone
ResolvedLena_WMDE
Resolvedawight
Resolvedthiemowmde
ResolvedNone
Resolvedthiemowmde
ResolvedWMDE-Fisch
Resolvedlilients_WMDE
Resolvedthiemowmde
Resolvedawight
ResolvedNone
ResolvedECohen_WMDE
Resolvedthiemowmde

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Ayack renamed this task from Display results of a SPARQL query on a map to Display results of a SPARQL query on a map in Wikipedia.Feb 26 2018, 6:13 PM

It is possible look here for example:
https://de.wikivoyage.org/wiki/Spiekeroog

@Yurik can explain you how it works.

It is possible look here for example:
https://de.wikivoyage.org/wiki/Spiekeroog

I see only one map in this page which (if I'm not wrong) is not based on a SPARQL query. Are you sure this is the right page?

@Evad37 has just confirmed here that this is not currently possible.

Since Kartographer already supports SPARQL queries (for geoshapes) and fetching coordinates from Wikidata based on a fixed list of Wikidata ids, I assume that it shouldn't be such a big change to display the results of a SPARQL query as geopoints on a map. WDQ already do that very well.

To clarify, what is wanted is a new external data service that takes in a query, looks up the P625 for each item from the query, and displays these as point features on a map
(in a similar way to how point features are displayed for geoJSON like { "type": "Point", "coordinates": [-150, 64] })

Basically, we should be able to use syntax like

<mapframe>
{
  "type": "ExternalData",
  "service": "geopoint",
  "query": "
// query goes here
"}
</mapframe>

to display point features based on wikidata coordinates, without having to know the wikidata ids in advance.

It would also be nice if there was a way to individually specify the Maki marker image, similar to how the geoshape example can specify fill colours for shapes.

Plus if there was also a way to just specify one or more wikidata ids without a query, then T178321 could be solved without having to use Lua.

Evad37 renamed this task from Display results of a SPARQL query on a map in Wikipedia to Display point features (coordinates) from the results of a SPARQL query on a map in Wikipedia.Jun 8 2018, 3:40 AM
MSantos moved this task from Unsorted to Feature requests on the Maps (Kartographer) board.

I want this too. Actually a deceptively simple thing that would be quite useful on Wikimedia Commons as well.

For instance, on gallery pages about artist James Ensor I want to include dynamic Wikidata-driven maps indicating the cultural institutions that have his works in their collection (simple query), where the map auto-updates as we add more works (and corresponding collections/institutions) on Wikidata.

ECohen_WMDE claimed this task.

I believe this ticket can now be closed since T302297: Display geopoint SPARQL queries in a map in Wikipedia (GeoPoints) was deployed to all wikis on Sept 26. Kartographer generated maps can now display the result of a SPARQL query with geopoints/markers instead of only geoshapes as it was previously.

See the help page for how to use it. It works basically as @Evad37 suggested in T188291#4266453.

Is it possible to populate the marker text in the popup via the query as in the geoshape example?
I tried to pass the text in ?description execting that it would generate the clickable marker.
https://it.wikipedia.org/wiki/Utente:Sabas88/Maps/Staglieno

Is it possible to populate the marker text in the popup via the query as in the geoshape example?
I tried to pass the text in ?description execting that it would generate the clickable marker.

Same question. Without description and link to the item it’s almost useless.

Is it possible to populate the marker text in the popup via the query as in the geoshape example?
I tried to pass the text in ?description execting that it would generate the clickable marker.
https://it.wikipedia.org/wiki/Utente:Sabas88/Maps/Staglieno

If you enter that query into the query service, you’ll notice that ur description is still empty, so it’s logical that it didn’t work for you

It's possible, but not straightforward. With a few Wikimedians we're trying to figure it out.

Examples for now:

I would also like to include links to Wikipedia articles but am stuck. I have requested SPARQL help at https://www.wikidata.org/wiki/Wikidata:Request_a_query#Help_with_a_SPARQL_query_for_Kartographer

I can imagine a big collection of Kartographer-SPARQL examples would make sense; the examples at https://www.mediawiki.org/wiki/Help:Extension:Kartographer#Via_Wikidata_query are good but not enough to help people like me to build things with confidence.

Is it possible to get dots rather than pushpins? Disadvantage of the latter is that very many of them - e.g. in the example above or at https://commons.wikimedia.org/wiki/User:Spinster/Map_test - occlude the map altogether & will be completely inappropriate for many SPARQL-derived applications.

Screenshot 2022-10-02 at 23.17.13.png (888×1 px, 1 MB)

Screenshot 2022-10-02 at 23.17.07.png (698×722 px, 777 KB)

Screenshot 2022-10-02 at 23.16.59.png (1×1 px, 707 KB)

Is it possible to get dots rather than pushpins? Disadvantage of the latter is that very many of them - e.g. in the example above or at https://commons.wikimedia.org/wiki/User:Spinster/Map_test - occlude the map altogether & will be completely inappropriate for many SPARQL-derived applications.

I don't think anything but pushpins are currently supported by Kartographer. There is T131618: Customize map markers in Kartographer as a request.

BTW. You can set ('small' AS ?marker_size) to make the markers the smaller version.

I've tried with a simple query which is working fine on WQS but got not result: https://www.wikidata.org/wiki/User:Ayack/Draft
Is there a max number of items to be displayed?

I've tried with a simple query which is working fine on WQS but got not result: https://www.wikidata.org/wiki/User:Ayack/Draft
Is there a max number of items to be displayed?

There are always limits. In this case though, I wonder if it is because some of your results are set to the special value 'unknown'.
Confirmed. Adding FILTER (!wikibase:isSomeValue(?geo)). fixed it by removing values of which the location is unknown.

There are always limits. In this case though, I wonder if it is because some of your results are set to the special value 'unknown'.
Confirmed. Adding FILTER (!wikibase:isSomeValue(?geo)). fixed it by removing values of which the location is unknown.

Thanks! I hadn't thought of that.

I've tried to use it in a template but it seems the parameter is not passed to it: https://www.wikidata.org/wiki/User:Ayack/Draft
Any idea where it comes from please?

Edit: You have to use

{{#tag:mapframe
|
{
  "type": "ExternalData",
  "service": "geopoint",
  "query": "SELECT ..."
}
}}

Here is an example with the link to the article as part of the title and the image being part of the description.

SELECT ?id ?geo (CONCAT("[[w:", SUBSTR(STR(?article), 31 , 400 ), "{{!}}", ?label, "]]") AS ?title) 
(CONCAT(?descr, ' [[File:', SUBSTR(STR(?image), 52 , 400 ), '{{!}}200px]]') AS ?description) ?image ?article WHERE {
  VALUES ?id {
    wd:Q1431922
  }
  ?id wdt:P625 ?geo;
    schema:description ?descr;
    rdfs:label ?label;
    wdt:P18 ?image .
  ?article schema:about ?id;
    schema:inLanguage "en" .
  FILTER (SUBSTR(str(?article), 1, 25) = "https://en.wikipedia.org/")
  FILTER(LANGMATCHES(LANG(?label), "EN"))
  FILTER(LANGMATCHES(LANG(?descr), "EN"))
}