Selecting only 1 image from hundrets of cities

Started by sinus, January 19, 2024, 10:09:16 AM

Previous topic - Next topic

sinus

Does anyone have an idea for my problem?
I have photos of maybe 2,000 different cities. Now I would like to have only one picture of each city.

In other words, I would end up with 2,000 photos that were all taken in different places.

At the moment I have no idea how I can do this without selecting everything "by hand".
Does anyone have any ideas on how to do this?

IF I have the 2'000 pictures (in a category or whatever), then my next step is to display them on a map, but of course not as a picture, but each photo only as a dot or pin or something.

Something ROUGHLY like my two attachments.
But that's not so much the problem at the moment.

But the question is, how do I select only 1 picture from each location in IMatch? 
Best wishes from Switzerland! :-)
Markus

mopperle

Do I understand you correct:
e.g. you have
- 100 pictures from London
- 50 pictures from Paris
- 80 pictures from Zürich

Now you want 1 picture from London, 1 from Paris and 1 from Zürich?

Based on which criteria should it be choosen?

sinus

Thanks to think about it.

Yes, you are correct. That is right.
Because I want after the selection set a point (or pin or whatever) on a map, it does not matter, what picture it is, it must be only (from your example) be 1 from London, 1 from Paris, and 1 from Zürich. 

Even if the pic from Zürich is a bad one, what counts, is the city Zürich for set a pin on a map. 
I do not want see on a map (later) the thumb, because this would neet too much room.
Hence I want later only set a small pin, point or something like this. 

You see, I guess, you have also pics from different cities.
Basically, would it not be interesting, to see a pin on a map, where you have been in the past (or in you whole life)?
That is, what I am lookin for.  :)

Best wishes from Switzerland! :-)
Markus

mopperle

#3
Maybe the solution lies here:
https://www.photools.com/community/index.php/topic,13848.0.html
Mario must also somehow select a picture for this specific view. Maybe he programmed a routine or he uses some kind of query/filter in IMatch.

Disregard the above. You do not want to see a picture, but 1 pin representing the 100 images of London?

Jingo

Well - for data gathering purposes, I would do this via scripting (of course right?)  8)

I would loop through the XMP:location country data of all images and make a simple list/array by country. Then, I would export this list and use other software to generate pins on a map (like: https://www.pinmaps.net).

sinus

Quote from: mopperle on January 19, 2024, 12:50:40 PMMaybe the solution lies here:
https://www.photools.com/community/index.php/topic,13848.0.html
Mario must also somehow select a picture for this specific view. Maybe he programmed a routine or he uses some kind of query/filter in IMatch.

Disregard the above. You do not want to see a picture, but 1 pin representing the 100 images of London?

Thanks, mopperle
Yep, I want 1 pin (or point) representing the 100 images of London.
Best wishes from Switzerland! :-)
Markus

sinus

Quote from: Jingo on January 19, 2024, 01:25:52 PMWell - for data gathering purposes, I would do this via scripting (of course right?)  8)

I would loop through the XMP:location country data of all images and make a simple list/array by country. Then, I would export this list and use other software to generate pins on a map (like: https://www.pinmaps.net).

Thanks, Jingo
yep, of course you would do this by scripting. I am sure.  ;D

But I hope, there is a way inside IMatch. Hmmm, let's look.

Your link is interesting, because I looked a bit around. If I have a lot of cities, then even a pin could be too big. I have seen some examples with points or very small pins. 
Best wishes from Switzerland! :-)
Markus

Mario

#7
This is way to specific for a generic / built-in functionality.
When you create a data-driven category based on the "City" tag and then select all images, the Map Panel displays something like this:

Image1.jpg

Data-driven categories have no "limit each category to one random file only".

The Map Panel code in IMatch automatically clusters "nearby" file markers. The amount of clustering depends on the zoom level. File makers are revealed as you zoom in. Above a certain zoom level you will see only one group per city.
That's more than sufficient (and complex, as it is) for almost all users.

What you have in mind can be done with an IMatch app. Fetch the city for all or selected files, pick one coordinate pair for each unique city name. Then load OSM or Google Maps and use their API to present each city with a flag or pin or whatever.

Google Earth Pro (not sure if this still exists) could import GPS coordinates from a CSV file. Basically, name and lat/lon.
In that case your script would only need to extract one GPS coordinate pair for each city and store it into a CSV text file. Then import the resulting CSV file into Google Earth. Much easier than learning and understanding the map APIs from OSM or Google. There are many tutorials which shows this.

IMatch helps you a lot along the way. For example, this code fragment groups all files in the database by the city tag:

<script src="/system/imws/imwslib.js"></script>

const categories = await IMWS.get('v1/files/groups', {
    groupby: 'tag',
    grouptag: 'city',
    fields: 'id,name,gps',
}).then(function (response) {
    console.log(JSON.stringify(response,null,2));
});

For each unique city name, there will be one entry in the resulting groups[] array.
For each file in that group, IMWS returns the id, name and the gps lat/lon/alt.

Note: If this exceeds limits for your database, comment out the fields: 'id..." line.
Then you'll get a group entry for each city in your database, but no file info.
Iterate over the groups and fetch one file for each category.

This should get you going if you really want this and are prepared to put some effort into it.

If you want to learn how to embed OSM into a HTML page (or IMatch app) and display points on it, see https://openlayers.org/ (does OSM, HERE, Bing). For Google, see here https://developers.google.com/maps/documentation/javascript
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Thanks, Mario

uhhh, heavy stuff (for me), but your thoughts makes sense. 
I have to think about it.

Your example with the map looks interesting and promising.

Funny, what can be done with images, if they have some information.  :)
Best wishes from Switzerland! :-)
Markus

Mario

If your files don't have GPS coordinates, things will become more difficult.
You can then fetch the "central" GPS coordinates for your cities from somewhere and use that to visualize each city on a map.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Ger

Where I can think of smart solutions with apps, maybe a very down-to-earth and not-so-fancy solution can work as well; especially if it's a one-time effort:

- Select all categories that contain images in the cities you want to select
- Export the full path/name of the image + city variable to text file or clipboard (e.g. {File.Path}[tab]{File.MD.City})
- In Excel or similar, select one file per city (e.g. with the Remove duplicates option, or with a simple formula)
- Use the app file name match (I think it is, don't have access to IMatch now) to flag the selected excel files in the database
- Copy these files to a separate category and show the files on the map panel

ger

Mario

I think it would be easier (and quicker) to
use a data-driven category based on City
Rate/Pin/Dot one file manually for each resulting category.
Or use your approach to manually assign one file of each city to a special category and then show the files in that category on the map.

Basically 4,000 clicks (City category, file, next city category, next file, ...)
Should be much faster than setting up apps, scripts, exports to/from Excel or whatnot.

All approaches would require for each chosen file to have GPS coordinates. Not sure if @sinus did that.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Yes, at least all my relevant images has gps-coordinates.
And I have already a data-driven category with all cities.

Therefore, (ger, thanks for your idea), I was a bit on the idea to simply take the time to click on one image on each city and assign them (with favourites I think) to a category.
And since Mario mentiones this also with his 4000 clicks, yes, maybe this is easier (at least for me) then create a script or something else.

Finally the weekend is coming and I have a bit time to think about it.
But inputs for other users and of course Mario are always very welcome!

If I have once the category filled with the images, then come the next step to visualize them on a map.
IMatch itself has such possibilities, it is then (I hope) quite easy to try this out (like Mario's example above).

Why I want this?
Well, of course it is not really necessary. But a friend showed me lately a real mal on the wall, and his has sticked about 200 pins, in what cities hes was in other countries.

This brought me on the idea, to do this with help from IMatch.
At least, I have all information in the DB.

But I want show then two maps (I think):
one with the whole world, but in this case there will not be a lot of pins, except countries from Europe.
but the main map will be the one from Switzerland.

Because my work I was in really a lot of small and big cities (and small villages) and the map of Switzerland with such pins will be quite interesting for me.
Maybe, if you are not more twenty year old or so ... such things becomes more interesting, abit looking back, what you have done and where you have been.  ;D  8)

If I look on the example from Mario, it you fill a map with your own cities, where you have been, it seems to me simply interesting.




Best wishes from Switzerland! :-)
Markus

sinus

Just an idea-update:

Data-driven categories gives me a list like

Aarau (33334)
Basel (20670)
Bern ((1012)
Zürich (13455)

In brackets the amount of files ,where I need finally only once.

Now I can jump with the key from up to down.
The last try for me is, if Automation could help.

Means,

start in Aarau
jump to the first file
assign this with a favourites to a category
jump back to Aarau
go a line down
jump to the first file ....

and so on.
But I have to first lern more about Automation.

If this is not possible, then I will do it "by hand" - what is finally also not sooo bad, because I have to do it only once.  :) 
Best wishes from Switzerland! :-)
Markus

Mario

Do it manually. Should only take an hour or so.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Best wishes from Switzerland! :-)
Markus