Search code examples
xmlexcelvbaapiarcgis

FEMA NFHL Flood Hazard Zones ArcGIS Online API access through VBA


I am trying to access ArcGIS Online with an API through VBA. My end goal is to provide a List of Lat/Longs in Excel, then have the FEMA Flood Hazard Zone layer return what flood zone my Lat/Long is in (e.g. "X", "AE", etc.).

I have only found a couple resources but cannot interpret how to access the data from the layer. ANY help is really appreciated. I'm not a pro at this by any means, but I'm competent.

Here are some resources I've found:

https://hazards.fema.gov/gis/nfhl/rest/services/public/NFHL/MapServer/28

https://hazards.fema.gov/femaportal/wps/portal/NFHLWMS

https://msc.fema.gov/portal/home

Some code I have (clearly not complete):

Function FEMA(LatLong As String)

Dim surl As String Dim oXH As Object Dim bodytxt As String

surl = "https://hazards.fema.gov/gis/nfhl/rest/services/public/NFHL/MapServer/28" & LatLong

Set oXH = CreateObject("msxml2.xmlhttp")

With oXH
    .Open "get", surl, False
    .send
    bodytxt = .responseText
End With

Cells(3, 3).Value = bodytxt


Set oXH = Nothing
End Function

Solution

  • I have resolved my issue... As I stated, I was trying to access a LAYER from ArcGIS. This contains polygons that are identified as Flood Hazard Zones. The link to this layer was stated in my original question... I was trying to pass a Lat/Long to this layer to have it return whatever the Zone name was by determining which polygon it is in. Turns out this cannot be returned in an XML format, only JSON. Here is the query string for anybody who needs it in the future... This is for a Lat: 32.333, Long: -96.6666 and returns the FLOOD HAZARD ZONE that this point is in. It is returned in a JSON format...

    hazards.fema.gov/gis/nfhl/rest/services/public/NFHL/MapServer/28/query?where=1%3D1&text=&objectIds=&time=&geometry=-96.6666%2C32.333&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&relationParam=&outFields=FLD_ZONE&returnGeometry=false&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=&resultRecordCount=&queryByDistance=&returnExtentsOnly=false&datumTransformation=&parameterValues=&rangeValues=&f=pjson

    ... This Reddit Post helped me greatly.