In today’s digital age, Geographic Information Systems (GIS) play an integral role in various fields, from urban planning to environmental conservation. One such area where GIS is proving invaluable is in managing and studying zoo habitats. Zoos often encompass vast areas with diverse habitats for different species, and efficiently navigating and monitoring these spaces is crucial for both animal welfare and visitor experience. In this blog post, we’ll delve into a code snippet designed to facilitate this process within ArcGIS Field Maps, along with two practical examples of its application.

Examples of Use

  1. Real Estate Site Selection: Let’s say a real estate developer is scouting for potential locations to build a new residential complex. By utilizing the provided code within ArcGIS Field Maps, the developer can identify the closest available parcels of land to their current location. The code would buffer the developer’s location, intersect it with a dataset containing information about available land parcels, calculate the distances to each parcel, and return the closest one. This information is crucial for making informed decisions about site selection, taking into account factors such as proximity to amenities, accessibility, and zoning regulations.
  2. Emergency Response Planning: In the event of a natural disaster or emergency situation, such as a wildfire or flood, emergency response teams need to quickly identify suitable evacuation shelters or medical facilities nearest to the affected area. By deploying the provided code in ArcGIS Field Maps, responders can determine the closest shelters or medical facilities based on their current location. The code would buffer the emergency response team’s location, intersect it with datasets containing information about available shelters or medical facilities, calculate the distances to each facility, and return the closest one. This information is critical for efficiently coordinating emergency response efforts and ensuring the safety and well-being of affected individuals.

In both of these examples, the provided code serves as a valuable tool for spatial analysis within ArcGIS Field Maps, enabling users to make data-driven decisions based on proximity and accessibility to relevant features in their surroundings. Whether it’s selecting an optimal site for development or coordinating emergency response efforts, the code facilitates efficient decision-making by leveraging GIS technology and spatial data analysis techniques.

// If feature doesn't have geometry return null
if (IsEmpty(Geometry($feature))) { return null }
// Get the Zoo Habitats layer
var habitats = FeatureSetByName($map, 'Zoo Habitats')
// Buffer the current location and intersect with parcels
var bufferedLocation = Buffer($feature, 100, 'feet')
var candidateHabitats = Intersects(habitats, bufferedLocation)
// Calculate the distance between the Zoo Habitats and the current location
// Store the feature and distance as a dictionary and push it into an array
var featuresWithDistances = []
for (var f in candidateHabitats) {
    Push(featuresWithDistances, 
        {
            'distance': Distance($feature, f, 'feet'),
            'feature': f
        }
    )
}
// Sort the candidate Zoo Habitats by distance using a custom function
function sortByDistance(a, b) {
    return a['distance'] - b['distance']
}
var sorted = Sort(featuresWithDistances, sortByDistance)
// Get the closest feature
var closestFeatureWithDistance = First(sorted)
// If there was no feature, return null
if (IsEmpty(closestFeatureWithDistance)) { return null }
// Return the address
return `${closestFeatureWithDistance['feature']['ZIMSNumber']}`

Understanding the Code

Let’s break down the provided code snippet and understand how it can be used within ArcGIS Field Maps:

  1. Geometry Check: The code begins by checking if the current feature has geometry. If not, it returns null, indicating an invalid or empty feature.
  2. Accessing Zoo Habitats Layer: It retrieves the Zoo Habitats layer from the map using FeatureSetByName.
  3. Buffering and Intersection: The current location is buffered to create a search area, and then it is intersected with the Zoo Habitats layer to find potential candidate habitats within the specified buffer distance.
  4. Calculating Distances: For each candidate habitat, the code calculates the distance between it and the current location. These distances along with the corresponding features are stored in an array.
  5. Sorting by Distance: The array of features with distances is sorted based on the calculated distances using a custom sorting function.
  6. Identifying Closest Feature: The closest feature is then retrieved from the sorted array.
  7. Returning Result: Finally, the ZIMSNumber of the closest feature is returned as the result, providing essential information about the identified habitat.

Using it in ArcGIS Field Maps

To utilize this code within ArcGIS Field Maps, follow these steps:

  1. Integrate the Code: Incorporate the provided code snippet into the custom expressions or scripts section of ArcGIS Field Maps.
  2. Triggering the Function: Define a trigger event (e.g., user location update) that executes the code to identify the closest habitat based on the current location.
  3. Displaying the Result: Utilize the returned ZIMSNumber to display information about the identified habitat on the map interface for users.

By integrating this code into ArcGIS Field Maps, zoo managers, researchers, and visitors alike can gain valuable insights into zoo habitats, enhancing both conservation efforts and visitor engagement.

In conclusion, the provided code snippet offers a powerful tool for exploring zoo habitats within ArcGIS Field Maps, with applications ranging from wildlife monitoring to visitor navigation. By leveraging GIS technology, stakeholders can make informed decisions regarding habitat management and conservation, ultimately contributing to the well-being of zoo animals and the overall zoo experience for visitors.