I have a list of Wikimedia URL’s that I would like to obtain location information for. I am trying to use the Wikimedia Commons web API to get that information, and I’m encountering some failures I can not make sense of. Ideally I would like to obtain information such as country, region, city, etc. however if GPS coordinates are all that I can get that would serve as a starting point
From what I’m reading in the documentation, when someone requests coordinates, they can also try to request region and country, however, for the queries I’m submitting I”m only getting back just the coordinates. For example, if I submit this query:
https://commons.wikimedia.org/w/api.php?action=query&format=json&pro...
All that is returned for coordinates is:
"coordinates": [ { "lat": 48.858296, "lon": 2.294479, "primary": "" } ]
Also, if I submit a similar query for a category like Nilkheimer Park I do not get any coordinate information even though the web page for that category can at least say the park is located in Germany. I’m wondering if there is a different kind of query someone can use other than coordinates that might provide that kind of information.
The country property seems to be set from the region parameter of the {{#coordinates}} parserfunction [1]. When the coordinate comes from Wikibase (as is the case with that category page), it seems like it is never set [2]. I did not check the other properties but presumably the same situation.
[1] https://gerrit.wikimedia.org/g/mediawiki/extensions/GeoData/+/f2fc19967630d0... [2] https://gerrit.wikimedia.org/g/mediawiki/extensions/Wikibase/+/c962837948cd6...
Hello George,
Thanks for the information.
I’m wondering if you are saying that this might be a bug with the query when trying to issue it from the Wikibase.
If not I'm wondering if you can suggest an alternative approach that might be able to get the desired information.
On Jan 8, 2024, at 20:45, Gergo Tisza gtisza@wikimedia.org wrote:
The country property seems to be set from the region parameter of the {{#coordinates}} parserfunction [1]. When the coordinate comes from Wikibase (as is the case with that category page), it seems like it is never set [2]. I did not check the other properties but presumably the same situation.
[1] https://gerrit.wikimedia.org/g/mediawiki/extensions/GeoData/+/f2fc19967630d0... [2] https://gerrit.wikimedia.org/g/mediawiki/extensions/Wikibase/+/c962837948cd6... _______________________________________________ Mediawiki-api mailing list -- mediawiki-api@lists.wikimedia.org To unsubscribe send an email to mediawiki-api-leave@lists.wikimedia.org
On Tue, Jan 9, 2024 at 9:15 AM Tron Thomas tron@mylio.com wrote:
I’m wondering if you are saying that this might be a bug with the query when trying to issue it from the Wikibase.
I don't see why it would be a bug. You should feel free to file a feature request though. Or a request on Commons to improve the Wikidata Infobox https://commons.wikimedia.org/wiki/Template:Wikidata_Infobox template.
If not I'm wondering if you can suggest an alternative approach that might
be able to get the desired information.
You could get the linked Wikidata item and see if it has some sort of location-related property. (With the Eiffel Tower category that's Q6741108 https://www.wikidata.org/wiki/Q6741108 and then you follow the "category's main topic" property to Q243 https://www.wikidata.org/wiki/Q243 and that has "country" and "location" properties, but with Wikidata it is always hard to know how consistent the data structure is across many items.
Alternatively, there are many third party geolookup APIs which can convert a coordinate into country, city etc.
mediawiki-api@lists.wikimedia.org