Analyze rodent infestation utilizing Amazon SageMaker geospatial capabilities


Rodents resembling rats and mice are related to various well being dangers and are recognized to unfold greater than 35 ailments. Figuring out areas of excessive rodent exercise may help native authorities and pest management organizations plan for interventions successfully and exterminate the rodents.

On this put up, we present the best way to monitor and visualize a rodent inhabitants utilizing Amazon SageMaker geospatial capabilities. We then visualize rodent infestation results on vegetation and our bodies of water. Lastly, we correlate and visualize the variety of monkey pox circumstances reported with rodent sightings in a area. Amazon SageMaker makes it simpler for information scientists and machine studying (ML) engineers to construct, prepare, and deploy fashions utilizing geospatial information. The software makes it simpler to entry geospatial information sources, run purpose-built processing operations, apply pre-trained ML fashions, and use built-in visualization instruments sooner and at scale.

Pocket book

First, we use an Amazon SageMaker Studio pocket book with a geospatial picture by following the steps outlined in Getting Started with Amazon SageMaker geospatial capabilities.

Knowledge entry

The geospatial picture comes preinstalled with SageMaker geospatial capabilities that make it simpler to counterpoint information for geospatial evaluation and ML. For our put up, we use satellite tv for pc photos from Sentinel-2 and the rodent activity and monkeypox datasets from open-source NYC open data.

First, we use the rodent exercise and extract the latitude and longitude of rodent sightings and inspections. Then we enrich this location data with human-readable avenue addresses. We create a vector enrichment job (VEJ) within the SageMaker Studio pocket book to run a reverse geocoding operation so that you could convert geographic coordinates (latitude, longitude) to human-readable addresses, powered by Amazon Location Service. We create the VEJ as follows:

import boto3
import botocore
import sagemaker
import sagemaker_geospatial_map

area = boto3.Session().region_name
session = botocore.session.get_session()
execution_role = sagemaker.get_execution_role()

sg_client= session.create_client(
    service_name="sagemaker-geospatial",
    region_name=area
)
response = sg_client.start_vector_enrichment_job(
    ExecutionRoleArn=execution_role,
    InputConfig={
        'DataSourceConfig': {
            'S3Data': {
                'S3Uri': 's3://<bucket>/pattern/rodent.csv'
            }
        },
        'DocumentType': 'CSV'
    },
    JobConfig={
        "ReverseGeocodingConfig": { 
         "XAttributeName": "longitude",
         "YAttributeName": "latitude"
      }
    },
    Identify="vej-reversegeo",
)

my_vej_arn = response['Arn']

Visualize rodent exercise in a area

Now we will use SageMaker geospatial capabilities to visualise rodent sightings. After the VEJ is full, we export the output of the job to an Amazon S3 bucket.

sg_client.export_vector_enrichment_job(
    Arn=my_vej_arn,
    ExecutionRoleArn=execution_role,
    OutputConfig={
        'S3Data': {
            'S3Uri': 's3://<bucket>/reversegeo/'
        }
    }
)

When the export is full, you will note the output CSV file in your Amazon Simple Storage Service (Amazon S3) bucket, which consists of your enter information (longitude and latitude coordinates) together with extra columns: tackle quantity, nation, label, municipality, neighborhood, postal code, and area of that location appended on the finish.

From the output file generated by VEJ, we will use SageMaker geospatial capabilities to overlay the output on a base map and supply layered visualization to make collaboration simpler. SageMaker geospatial capabilities present built-in visualization tooling powered by Foursquare Studio, which natively works from inside a SageMaker pocket book through the SageMaker geospatial Map SDK. Beneath, we will visualize the rodent sightings and likewise get the human readable addresses for every of the info factors. The tackle data of every of the rodent sightings information factors might be helpful for rodent inspection and therapy functions.

Analyze the consequences of rodent infestation on vegetation and our bodies of water

To research the consequences of rodent infestation on vegetation and our bodies of water, we have to classify every location as vegetation, water, and naked floor. Let’s take a look at how we will use these geospatial capabilities to carry out this evaluation.

The brand new geospatial capabilities in SageMaker supply simpler entry to geospatial information resembling Sentinel-2 and Landsat 8. Constructed-in geospatial dataset entry saves weeks of effort in any other case misplaced to accumulating and processing information from varied information suppliers and distributors. Additionally, these geospatial capabilities supply a pre-trained Land Use Land Cowl (LULC) segmentation mannequin to determine the bodily materials, resembling vegetation, water, and naked floor, on the earth floor.

We use this LULC ML mannequin to investigate the consequences of rodent inhabitants on vegetation and our bodies of water.

Within the following code snippet, we first outline the realm of curiosity coordinates (aoi_coords) of New York Metropolis. Then we create an Earth Remark Job (EOJ) and choose the LULC operation. SageMaker downloads and preprocesses the satellite tv for pc picture information for the EOJ. Subsequent, SageMaker routinely runs mannequin inference for the EOJ. The runtime of the EOJ will differ from a number of minutes to hours relying on the variety of photos processed. You’ll be able to monitor the standing of EOJs utilizing the get_earth_observation_job perform, and visualize the enter and output of the EOJ within the map.

aoi_coords = [
    [
            [
              -74.13513011934334,
              40.87856296920188
            ],
            [
              -74.13513011934334,
              40.565792636343616
            ],
            [
              -73.8247144462764,
              40.565792636343616
            ],
            [
              -73.8247144462764,
              40.87856296920188
            ],
            [
              -74.13513011934334,
              40.87856296920188
            ]
    ]
]

eoj_input_config = {
    "RasterDataCollectionQuery": {
        "RasterDataCollectionArn": "arn:aws:sagemaker-geospatial:us-west-2:378778860802:raster-data-collection/public/nmqj48dcu3g7ayw8",
        "AreaOfInterest": {
            "AreaOfInterestGeometry": {
                "PolygonGeometry": {
                    "Coordinates": aoi_coords
                }
            }
        },
        "TimeRangeFilter": {
            "StartTime": "2023-01-01T00:00:00Z",
            "EndTime": "2023-02-28T23:59:59Z",
        },
        "PropertyFilters": {
            "Properties": [{"Property": {"EoCloudCover": {"LowerBound": 0, "UpperBound": 2.0}}}],
            "LogicalOperator": "AND",
        },
    }
}
eoj_config = {
  "LandCoverSegmentationConfig": {}
}

response = geospatial_client.start_earth_observation_job(
    Identify="eoj-rodent-infestation-lulc-example",
    InputConfig=eoj_input_config,
    JobConfig=eoj_config,
    ExecutionRoleArn=execution_role,
)
eoj_arn = response["Arn"]
eoj_arn

Map = sagemaker_geospatial_map.create_map()
Map.set_sagemaker_geospatial_client(sg_client)

Map.render()

time_range_filter = {
    "start_date": "2023-01-01T00:00:00Z",
    "end_date": "2023-02-28T23:59:59Z",
}


config = {"preset": "singleBand", "band_name": "masks"}
output_layer = Map.visualize_eoj_output(
    Arn=eoj_arn, config=config, time_range_filter=time_range_filter
)

To visualise the rodent inhabitants with respect to vegetation, we overlay the rodent inhabitants and sighting information on the land cowl segmentation mannequin predictions. This visualization may help us find the inhabitants of rodents and analyze it on vegetation and our bodies of water.

Visualize monkeypox circumstances and corelating with rodent information

To visualise the relation between the monkeypox circumstances and rodent sightings, we add the monkeypox dataset and the geoJSON file for New York City borough boundaries. See the next code:

nybb = pd.read_csv("./nybb.csv")
monkeypox = pd.read_csv("./monkeypox.csv")
dataset = Map.add_dataset({
    "information": nybb
}, auto_create_layers=False)
dataset = Map.add_dataset({
    "information": monkeypox
}, auto_create_layers=False)

Inside a SageMaker Studio pocket book, we will use the visualization software powered by Foursquare so as to add layers within the map and add charts. Right here, we added the monkeypox information as a chart to indicate the variety of monkeypox circumstances for every of the boroughs. To see the correlation between monkeypox circumstances and rodent sightings, we now have added the borough boundaries as a polygon layer and added the heatmap layer that represents rodent exercise. The borough boundary layer is coloured to match the monkeypox information chart. As we will see, the borough of Manhattan displays a excessive focus of rodent sightings and information the very best variety of monkeypox circumstances, adopted by Brooklyn.

That is supported by a easy statistical evaluation of calculating the correlation between the focus of rodent sightings and monkeypox circumstances in every borough. The calculation produced an r worth of 0.714, which suggests a optimistic correlation.

r = np.corrcoef(borough_stats['Concentration (sightings per square km)'], borough_stats['Monkeypox Cases'])

Conclusion

On this put up, we demonstrated how you should utilize SageMaker geospatial capabilities to get detailed addresses of rodent sightings and visualize the rodent results on vegetation and our bodies of water. This may help native authorities and pest management organizations plan for interventions successfully and exterminate rodents. We additionally correlated the rodent sightings to monkeypox circumstances within the space with the built-in visualization software. By using vector enrichment and EOJs together with the built-in visualization instruments, SageMaker geospatial capabilities remove the challenges of dealing with large-scale geospatial datasets, mannequin coaching, and inference, and supply the flexibility to quickly discover predictions and geospatial information on an interactive map utilizing 3D accelerated graphics and built-in visualization instruments.

You may get began with SageMaker geospatial capabilities in two methods:

To study extra, go to Amazon SageMaker geospatial capabilities and Getting Started with Amazon SageMaker geospatial capabilitites. Additionally, go to our GitHub repo, which has a number of instance notebooks on SageMaker geospatial capabilities.


Concerning the authors

Bunny Kaushik is a Options Architect at AWS. He’s keen about constructing AI/ML options and serving to prospects innovate on the AWS platform. Exterior of labor, he enjoys mountain climbing, mountain climbing, and swimming.

Clarisse Vigal is a Sr. Technical Account Supervisor at AWS, centered on serving to prospects speed up their cloud adoption journey. Exterior of labor, Clarisse enjoys touring, mountain climbing, and studying sci-fi thrillers.

Veda Raman is a Senior Specialist Options Architect for machine studying primarily based in Maryland. Veda works with prospects to assist them architect environment friendly, safe and scalable machine studying purposes. Veda is desirous about serving to prospects leverage serverless applied sciences for Machine studying.

Leave a Reply

Your email address will not be published. Required fields are marked *