R-ArcGIS / arcgisgeocode

Utilize public or private ArcGIS Geocoder Services from R. Provides reverse geocoding, candidate search, single address, and batch geocoding.
http://r.esri.com/arcgisgeocode/
Apache License 2.0
32 stars 1 forks source link

Column "result_id" is not present #22

Closed aaronkrusniak closed 1 month ago

aaronkrusniak commented 1 month ago

Upon successful geocoding of some data, I'm getting the warning: Warning message: Column "result_id" is not present. Results may be out of order. (And indeed, there's no such column in the returned data, which makes it difficult to join the returned geometry back up to the original dataset without some potentially gnarly regex.)

As I talked about in #20, we're using an enterprise geocoder so, I'm actually not sure if the missing column is a bug in the package code or a quirk of our unique geocoder! But I suspect it may be another issue to do with custom fields, as they're being parsed through parse_custom_loc_json() as opposed to parse_location_json() for non-custom geocoders, and I'm not sure if this custom function is returning the result_id? I unfortunately don't know enough Rust to be able to investigate much further, though. And I don't seem to have the right token to authenticate with the reprex here, so I haven't been able to confirm if this is something across all geocoders with custom fields, or just ours.

My code hasn't really changed from #20, but here it is again for ease:

library(arcgis)
library(arcgisbinding)
library(arcgisgeocode)
library(tidyverse)

arc.check_portal()
set_arc_token(auth_binding())

music_venues <- tribble(
  ~Name,              ~Address,
  "Aragon Ballroom",  "1106 W. Lawrence Ave.",
  "House of Blues",   "329 N. Dearborn St.",
  "Bottom Lounge",    "1375 W. Lake St.",
  "The Vic",          "3145 N. Sheffield Ave.",
  "Park West",        "322 W. Armitage Ave.",
  "Thalia Hall",      "1807 S. Allport St.",
  "Lincoln Hall",     "2424 N. Lincoln Ave.",
  "Schubas Tavern",   "3159 N. Southport Ave."
)

chigeocode <- geocode_server("https://maps.chicago.gov/arcgis/rest/services/Chicago_Addresses/GeocodeServer")

venues_geocoded <- geocode_addresses(single_line = music_venues$Address,
                                     for_storage = TRUE,
                                     geocoder = chigeocode)

#> Warning message:
#>   Column "result_id" is not present. Results may be out of order. 

glimpse(venues_geocoded)

#> Rows: 8
#> Columns: 61
#> $ Loc_name   <chr> "CHI_singleaddr", "CHI_sing…
#> $ Shape      <dbl> 0, 0, 0, 0, 0, 0, 0, 0
#> $ Status     <chr> "M", "M", "M", "M", "M", "M…
#> $ Score      <dbl> 100, 100, 100, 100, 100, 10…
#> $ Match_addr <chr> "1106 W LAWRENCE AVE, 60640…
#> $ LongLabel  <chr> "1106 W LAWRENCE AVE, 60640…
#> $ ShortLabel <chr> "1106 W LAWRENCE AVE", "329…
#> $ Addr_type  <chr> "PointAddress", "PointAddre…
#> $ Type       <chr> "", "", "", "", "", "", "",…
#> $ PlaceName  <chr> "", "", "", "", "", "", "",…
#> $ Place_addr <chr> "1106 W LAWRENCE AVE, 60640…
#> $ Phone      <chr> "", "", "", "", "", "", "",…
#> $ URL        <chr> "", "", "", "", "", "", "",…
#> $ Rank       <dbl> 20, 20, 20, 20, 20, 20, 20,…
#> $ AddBldg    <chr> "", "", "", "", "", "", "",…
#> $ AddNum     <chr> "1106", "329", "1375", "314…
#> $ AddNumFrom <chr> "", "", "", "", "", "", "18…
#> $ AddNumTo   <chr> "", "", "", "", "", "", "18…
#> $ AddRange   <chr> "", "", "", "", "", "", "18…
#> $ Side       <chr> "", "", "", "", "", "", "L"…
#> $ StPreDir   <chr> "W", "N", "W", "N", "W", "N…
#> $ StPreType  <chr> "", "", "", "", "", "", "",…
#> $ StName     <chr> "LAWRENCE", "DEARBORN", "LA…
#> $ StType     <chr> "AVE", "ST", "ST", "AVE", "…
#> $ StDir      <chr> "", "", "", "", "", "", "",…
#> $ BldgType   <chr> "", "", "", "", "", "", "",…
#> $ BldgName   <chr> "", "", "", "", "", "", "",…
#> $ LevelType  <chr> "", "", "", "", "", "", "",…
#> $ LevelName  <chr> "", "", "", "", "", "", "",…
#> $ UnitType   <chr> "", "", "", "", "", "", "",…
#> $ UnitName   <chr> "", "", "", "", "", "", "",…
#> $ SubAddr    <chr> "", "", "", "", "", "", "",…
#> $ StAddr     <chr> "1106 W LAWRENCE AVE", "329…
#> $ Block      <chr> "", "", "", "", "", "", "",…
#> $ Sector     <chr> "", "", "", "", "", "", "",…
#> $ Nbrhd      <chr> "", "", "", "", "", "", "",…
#> $ District   <chr> "", "", "", "", "", "", "",…
#> $ City       <chr> "", "", "", "", "", "", "",…
#> $ MetroArea  <chr> "", "", "", "", "", "", "",…
#> $ Subregion  <chr> "", "", "", "", "", "", "",…
#> $ Region     <chr> "", "", "", "", "", "", "",…
#> $ RegionAbbr <chr> "", "", "", "", "", "", "",…
#> $ Territory  <chr> "", "", "", "", "", "", "",…
#> $ Zone       <chr> "", "", "", "", "", "", "",…
#> $ Postal     <chr> "60640", "60654", "60607", …
#> $ PostalExt  <chr> "", "", "", "", "", "", "",…
#> $ Country    <chr> "", "", "", "", "", "", "",…
#> $ CntryName  <chr> "USA", "USA", "USA", "USA",…
#> $ LangCode   <chr> "ENG", "ENG", "ENG", "ENG",…
#> $ Distance   <dbl> 0, 0, 0, 0, 0, 0, 0, 0
#> $ X          <dbl> 1167886, 1176003, 1167116, …
#> $ Y          <dbl> 1932184, 1902659, 1901423, …
#> $ DisplayX   <dbl> 1167886, 1176003, 1167116, …
#> $ DisplayY   <dbl> 1932184, 1902659, 1901423, …
#> $ Xmin       <dbl> 1167617, 1175734, 1166847, …
#> $ Xmax       <dbl> 1168155, 1176272, 1167386, …
#> $ Ymin       <dbl> 1931818, 1902292, 1901057, …
#> $ Ymax       <dbl> 1932551, 1903025, 1901790, …
#> $ ExInfo     <chr> "", "", "", "", "", "", "",…
#> $ User_fld   <chr> "", "", "", "", "", "", "",…
#> $ geometry   <POINT [US_survey_foot]> POINT (1167886 1932184), PO…

I think I could rejoin on Match_addr/LongLabel/ShortLabel or something if I had to? Would be nice to have result_id, though, since depending on the input addresses you might have to use some regex that would be prone to mistakes.

JosiahParry commented 1 month ago

The custom json parser was looking for the candidate fields. ResultID was not present in there. I've pushed a change that sorts and returns the ResultID.

https://github.com/R-ArcGIS/arcgisgeocode/commit/7b3b3d330dff6909990ac4bc6e584e64cf1a4b5d

Please let me know if this resolves your issue!

aaronkrusniak commented 1 month ago

Just tested the new build and it's working a treat! Thanks again, @JosiahParry!

JosiahParry commented 1 month ago

Amazing! Thank you so much for your help on this!

On Fri, Jun 7, 2024 at 13:06 Aaron Krusniak @.***> wrote:

Just tested the new build and it's working a treat! Thanks again, @JosiahParry https://github.com/JosiahParry!

— Reply to this email directly, view it on GitHub https://github.com/R-ArcGIS/arcgisgeocode/issues/22#issuecomment-2155215307, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADHIKLEY7CPAYMCZGDZKKPDZGHSBNAVCNFSM6AAAAABI62CFWOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJVGIYTKMZQG4 . You are receiving this because you were mentioned.Message ID: @.***>