mushroom-observer icon indicating copy to clipboard operation
mushroom-observer copied to clipboard

Improve iNat import Location

Open JoeCohen opened this issue 1 year ago • 4 comments

Imports sometimes (often?) have an MO Location and where which is weird and/or way too big. Need smaller, more correct where. Examples:

obs lat/lng geoprivacy location/where
https://www.inaturalist.org/observations/285825307 33.13018, -94.14981 ? Atlanta, TX, USA
https://mushroomobserver.org/575231 33.1302°N 94.1498°W n.a. Arkansas, USA
https://www.inaturalist.org/observations/285822158 33.130512,-94.150352 null Atlanta, TX, USA
https://mushroomobserver.org/obs/575226 33.1305°N 94.1504°W n.a. Arkansas, USA

For those iNat obss geoprivacy & public_positional_accuracy are null

Tasks

  • [x] Review current algorithms for Inat::Obs.where, and MO Observation.location
  • [ ] Again check that I'm doing the right thing with positional accuracy

Some ideas: app/classes/inat_obs.rb#where should return a real Location.name instead of:

def where = self[:place_guess]
  • [ ] smallest existing MO Location containing: inat.location +/- inat.positional accuracy
  • [ ] smallest existing MO Location containing smaller of (a) bounding box of inat.location +/- inat.positional accuracy, (b) bounding box of iNat place.
  • [ ] If smallest existing MO Location above is too big, new MO Location based on the iNat Place

JoeCohen avatar Sep 09 '24 16:09 JoeCohen

    def location
      ::Location.contains_box(north: blurred_north,
                              south: blurred_south,
                              east: blurred_east,
                              west: blurred_west).
        min_by { |loc| location_box(loc).calculate_area }
    end

blurred_north = [lat + public_accuracy_in_degrees[:lat] / 2, 90].min
blurred_south = [lat - public_accuracy_in_degrees[:lat] / 2, -90].max
blurred_east = ((lng + public_accuracy_in_degrees[:lng] / 2 + 180) % 360) - 180
blurred_west = ((lng - public_accuracy_in_degrees[:lng] / 2 + 180) % 360) - 180

JoeCohen avatar Jun 29 '25 12:06 JoeCohen

This is performing correctly. Atlanta TX is in Cass Co. As of this writing there's no Cass Co. MO Location.

JoeCohen avatar Jun 29 '25 13:06 JoeCohen

Improving this could involve some complicated js. Need to reverse geocode the iNat obs place guess, obtaining both the bounding box and the name. Better: limit ourselves to using the iNat Location.

JoeCohen avatar Jun 29 '25 15:06 JoeCohen

Another example:

webmaster mushroomobserver.org 9:03 AM (0 minutes ago) to huafang1960

  1. Thank you for reporting this. We actually have a ticket to improve the MO Location for imported Observations. But the improvement is complicated, and we haven't had time to do it. (Right now we're focused on making changes to accommodate the September NAMA and NEMF forays.) Your report is very useful and will help us focus on how to improve things.
  2. In the short term, I suggest you manually change the Locations of those two MO Observations. (I adjusted the Location boundaries to be the same as the state land shown on the official state park map.)
  3. In case you're interested, here's what happened.

When an iNat Observation is imported, we currently use: the smallest existing MO Location which contains the entire area of the latitude/longitude of the iNat observation, adjusted for the iNat margin of error ("Accuracy"). (We currently do not try to create new MO Locations because that's slow and complicated.) The iNat observations have an Accuracy of +/-2270 m. The smallest existing MO Location containing that entire area is Wisconsin, USA.

  1. What I'd like to change is how we pick the MO Location. In particular: if the smallest existing MO Location which contains the entire area of the adjusted iNat area is too large, then create a new MO Location based on the iNat Location, provided that this would result in a smaller MO Location. This will make Inat Imports run slower, but give more precise MO Locations for some imports.

On Wed, Aug 27, 2025 at 6:55 AM [email protected] wrote: (from User #11038 (Huafang)) Hi, I unloaded my observations from iNaturalist by using Import from iNat. Something weird happened. The location should be Ludington State Park but MO showed:

Collection location: Wisconsin, USA [Click for map] This observation will not appear on maps of its taxon because the location is too vague. If you would like it to be included in maps, choose a more precise location. 44.0428°N 86.4981°W [Click for map]

Location is wrong; the GPS coordinates are still right. I have manually changed my observations to Ludington State Park and left two observations unchanged for you to figure out what went wrong. https://mushroomobserver.org/obs/584749?q=25wiL https://mushroomobserver.org/obs/584748?q=25wiL

Huafang

JoeCohen avatar Aug 27 '25 16:08 JoeCohen