Hi,
I am working with weather data and want to use USA Weather Watches and Warnings from ESRI Living Atlas in an RStudio. The issue is that I can't figure out how to get into the data in the feature class. Any help in how to use this in R will be greatly appreciated.
Thank you
#Library
library(arcgisbinding)
arc.check_product()
#Weather Event Classification
Event <- arc.open('https://services9.arcgis.com/RHVPKKiFTONKtxq3/arcgis/rest/services/NWS_Watches_Warnings_v1/FeatureServer')
> Event@children
$FeatureClass
[1] "L1Public_Forecast_Zones"
[2] "L2Fire_Forecast_Zones"
[3] "L3US_Counties"
[4] "L4US_States_and_Territories"
[5] "L5Coastal_and_Offshore_Marine_Zones"
[6] "L6Events_Ordered_by_Size_and_Severity"
[7] "L8Extreme_Events"
[8] "L9Severe_Events"
[9] "L10Moderate_Events"
[10] "L11Minor_Events"
[11] "L12Other_Events"
#Getting Data from Severe Events
SevereEvent <- arc.open('https://services9.arcgis.com/RHVPKKiFTONKtxq3/arcgis/rest/services/NWS_Watches_Warnings_v1/FeatureServer/L9Severe_Events')
> SevereEvent@fields
$OBJECTID
[1] "OID"
$Event
[1] "String"
$Severity
[1] "String"
$Summary
[1] "String"
$Link
[1] "String"
$Urgency
[1] "String"
$Certainty
[1] "String"
$Category
[1] "String"
$Updated
[1] "Date"
$Start
[1] "Date"
$End_
[1] "Date"
$Uid
[1] "String"
$Affected
[1] "String"
$AreaIds
[1] "String"
$Shape__Area
[1] "Double"
$Shape__Length
[1] "Double"
$Shape
[1] "Geometry"
> SevereEvent@shapeinfo
geometry type : Polygon
WKT : PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_...
WKID : 3857
Solved! Go to Solution.
Thanks for providing the additional context. It looks like the particular service you're using has a couple of empty geometries in the input, and sf doesn't like this input. I'm not sure if there is a simple way to filter these from the sf side, you might want to check in their documentation. As a quick workaround, sp will drop these geometries on import, and sf can read sp objects. This worked for me locally:
library(arcgisbinding)
arc.check_product()
arc.open(path='https://services9.arcgis.com/RHVPKKiFTONKtxq3/arcgis/rest/services/NWS_Watches_Warnings_v1/FeatureServer/5')
wes <- arc.select(wec)
wes.sp <- arc.data2sp(wes)
# sp reports: "removed missing geometry:393 451"
# convert the resulting sp object back to sf
wes.sf <- sf::st_as_sf(wes.sp)
If you discover a filter on sf that does the trick, potentially we could add that to our documentation, or otherwise find a way to make the need to have non-null geometries when working with sf clearer.
Cheers,
Shaun
Hello Explorador,
How would you like to use the data? If you want the shape in an R native format, you can use arc.shape2sp or arc.shape2sf to export into the sp and sf formats which would be easier to work with elsewhere in R. You can also use arc.shape to pull out the native Esri geometry, but typically you'll want to be working with something that understands the complexities of the polygon format.
Cheers, Shaun
Hi, I am not sure what is happening with this layer. I have been using similar layers for a couple of years now but I keep getting an error when I try to bring this FC into R. Here is the error I get.
Error in MtrxSet(x, dim, type = "POLYGON", needClosed = TRUE) :
is.list(x) is not TRUE
Typically I bring data into R using one string via dplyr pipes. like this.
#Weather Event Classification
wec <- arc.open(path = 'https://services9.arcgis.com/RHVPKKiFTONKtxq3/arcgis/rest/services/NWS_Watches_Warnings_v1/FeatureSe...') %>% arc.select() %>% arc.data2sf()
Thanks for providing the additional context. It looks like the particular service you're using has a couple of empty geometries in the input, and sf doesn't like this input. I'm not sure if there is a simple way to filter these from the sf side, you might want to check in their documentation. As a quick workaround, sp will drop these geometries on import, and sf can read sp objects. This worked for me locally:
library(arcgisbinding)
arc.check_product()
arc.open(path='https://services9.arcgis.com/RHVPKKiFTONKtxq3/arcgis/rest/services/NWS_Watches_Warnings_v1/FeatureServer/5')
wes <- arc.select(wec)
wes.sp <- arc.data2sp(wes)
# sp reports: "removed missing geometry:393 451"
# convert the resulting sp object back to sf
wes.sf <- sf::st_as_sf(wes.sp)
If you discover a filter on sf that does the trick, potentially we could add that to our documentation, or otherwise find a way to make the need to have non-null geometries when working with sf clearer.
Cheers,
Shaun
Thank you @BenjaminDorsey and @ShaunWalbridge . I really appreciate your help in understanding how to use ArcGIS in a R environment.