Catching lat lon in wrong country errors
John Irish
jirish at MWEB.COM.NA
Tue Jan 4 11:37:12 CST 2005
If you put your country polygons into a MySQL database, you can run a
SQL query on it to determine whether a specific pair of coordinates fall
within a specific polygon. For any non-rectangular country (like
Namibia), this will be rather more accurate than testing a bounding box.
If you are not running MySQL, maybe a sister institution is and they
would be willing to remotely host the polygon database for you.
Whichever scripting language you currently use to query ADL should also
be able to query a MySQL database.
A description of the MySQL function 'Within' is near the bottom of this
page of the online MySQL manual:
http://dev.mysql.com/doc/mysql/en/Functions_that_test_spatial_relationships_between_geometries.html
Basically you send it the coordinates and the polygon, and it returns
true or false as expected. I have not yet used 'Within' myself, but am
using some of MySQL's other spatial functions along with PHP with
success. I expect something along the lines of
"SELECT Within (PointFromText ('YourLongitude', 'YourLatitude'), SELECT
CountryPolygon FROM PolygonTable WHERE CountryName = 'TheName')"
should work.
John
--
Dr. John Irish
Tel./Fax +264-61-202-2038; Cell/SMS: +264-81-269-6602
P.O. Box 21148, Windhoek
Namibia Biosystematics Web Portal: http://www.biodiversity.org.na/index.php
"The universe is full of magical things patiently waiting for our wits
to grow sharper - E. Phillpots"
Steve Ginzbarg wrote:
> Mary Barkworth brought up the problem of how to catch errors where
> the lat lon for a specimen doesn't fall within the country where it
> was said to have been collected.
>
> The Alexandria Digital Library has fields w_b_coord, e_b_coord,
> n_b_coord, and s_b_coord. ADL Catalog records give
>
> titles:
> Alabama
> geographic-locations:
> Lat/Lon Bounding Box: North=35.07 South=29.76 East=-84.87 West=-88.5
>
> Is anyone who is using ADL as their geographic authority file making use
> of the bounding boxes of countries and their political subdivisions
> to check if a lat lon for a specimen actually falls within a
> rectangle containing the country and political subdivisions it is
> reported for?
>
> The Getty Thesaurus of Geographic Names
> http://www.getty.edu/research/conducting_research/vocabularies/tgn/ind
> ex.html gives only the centroid and not a bounding box.
>
> MicroCam for Windows by Scott A. Loomer, loomer at att.net, has the
> latitude and longitude of each point in the polygon forming the
> border of a country or political subdivision. One could calculate the
> area's bounding box by finding the maximum and minimum latitude and
> longitude of all the points forming the border. Is there a way to
> determine whether a latitude and longitude from a specimen is within
> the "fill" area of the polygon?
>
> Does anyone know of other geographic authority files that include
> bounding boxes for political subdivisions?
>
> The following response is from the HERBARIA list:
>
> From: "Mary Barkworth" <Mary at biology.usu.edu>
> To: <herbaria at scarab.science.oregonstate.edu>
> Subject: [HERBARIA] Map problems
> Date sent: Mon, 20 Dec 2004 16:03:30 -0700
>
> Further to my question/comments about lat lon errors in our database
> (and the majority are correct, despite my phrasing in the message that
> triggered Steve's comment:
> The following from Russell, the student to whom I sent the email that
> started the thread:
>
> Steve asked: Is there a way to determine whether a latitude and
> longitude from a specimen is within the "fill" area of the polygon?
> Yes, it's called the point-in-polygon algorithm. Depending on how
> accessible the data in Microcam turn out to be, I'm looking forward to
> implementing it. It's quite exciting to think that something I learned
> in a CS class will actually be put to use in the `real' world!
> Once we get it working, it won't be hard at all to stitch it into a
> lat/lon data entry form, so we will be able to flag all the current
> errors as well as prevent some future headaches.
>
> Hmm. Herbaria are part of the real world? What a lovely thought!
>
> Mary
>
> _______________________________________________
> HERBARIA mailing list
> HERBARIA at scarab.science.oregonstate.edu
> http://scarab.science.oregonstate.edu/mailman/listinfo/herbaria
>
> -Steve Ginzbarg
>
> Steve Ginzbarg, Assistant Curator
> Herbarium (UNA)
> Department of Biological Sciences
> Box 870345
> The University of Alabama
> Tuscaloosa, AL 35487-0345
>
> (205) 348-1829, FAX: (205) 348-6460
> sginzbar at bsc.as.ua.edu
> .
>
More information about the Taxacom
mailing list