how to transfer as.Date in R to Date in ArcGIS

1105
3
05-16-2019 04:38 AM
RamB
by
Occasional Contributor III

Hi,

how do I convert a as.Date of R to a Date in ArcGIS? The field is a date in the r data.frame, but when it is opened in arcgis, it is a character/ string type. 

thank you.

Tags (1)
0 Kudos
3 Replies
Egge-Jan_Pollé
MVP Regular Contributor

Hi Srirama Bhamidipati‌,

You may want to use Python to convert the string in ArcGIS to a datetime object.

Does this Stack Overflow discussion python - Converting string into datetime - Stack Overflow answer your question?

datetime.strptime is the main routine for parsing strings into datetimes. It can handle all sorts of formats, with the format determined by a format string you give it

HTH,

Egge-Jan

0 Kudos
RamB
by
Occasional Contributor III

Thank you, but my all workflow is in R. So Not sure what you mean ?

0 Kudos
ShaunWalbridge
Esri Regular Contributor

Can you provide a code sample? I'm not able to reproduce this, as.Date and POSIX date objects are being converted to a Date field in an output geodatabase in my tests. Here's an example:

library(arcgisbinding)
arc.check_product()

Sys.setenv(TZ="UTC")

df <- data.frame(
    a = c(0, 1, NA, -Inf, Inf),
    b = c("a", "b", NA, "c", ""),
    c = c(as.Date("2001-01-01"), NA, -99, 0, 1),
    d = c(as.POSIXct("2001-01-01"), NA, -99, 0, 1),


arc.write("date.gdb/with_date")

With that, I get two date columns, "c" and "d", which contain values I would expect.

0 Kudos