Agriculture

Configuration

You can configure the endpoint directly or utilize env variables.

export PSW_AGRICULTURE_SITE="http://base.platform.url"
export PSW_AGRICULTURE_USER="3ScaleUsername"
export PSW_AGRICULTURE_PASSWORD="3ScalePassword"

Fields

The Field resource supports full CRUD of fields and also allows use of the geojson module for creating field geometries.

from geojson import MultiPolygon
from skywise.agriculture import Field

# Find all of your fields
fields = Field.find()

# Create your own field
field = Field()
field.description = 'Arthur Farm'
field.add_geometry(MultiPolygon([
    ([(-97.194156646728, 35.667442627764),
      (-97.191281318664, 35.668349114403),
      (-97.185573577880, 35.672497902647),
      (-97.185616493225, 35.676402447539),
      (-97.194499969482, 35.671591463121),
      (-97.194156646728, 35.667442627764)])
]))
field.save()
assert field.id is not None

# Retrieve a particular field using its ID
fresh_field = Field.find(field.id)
assert fresh_field.id == field.id

# Update a field's description
field.description = 'Arthur NW Field'
field.save()

fresh_field = Field.find(field.id)
assert fresh_field.description = field.description

# Delete a field
field.destroy()

Growing Degree Days

GDD data be retrieved using Gdd endpoints directly or through the use of fields.

By Location

import arrow
from skywise.agriculture import Gdd

start = arrow.get("2015-05-01").date()
end = arrow.get("2015-07-31").date()

summer_gdd = Gdd.location(35.66, -97.19, start=start, end=end)
assert summer_gdd.degreeDays > 0
assert summer_gdd.scale == 'Celsius'

By Field

from skywise.agriculture import Field

field = Field.find('my-field-id')
summer_gdd = field.gdd(start, end)
assert summer_gdd.degreeDays > 0
assert summer_gdd.scale == 'Celsius'

Contours

summer_contours = field.gdd_contours(start, end)

Precipitation

By Location

import arrow
from skywise.agriculture import Precip

start = arrow.get("2015-05-01").datetime
end = arrow.get("2015-07-31").datetime

summer_precip = Precip.location(35.66, -97.19, start=start, end=end)
assert summer_precip.precipitation > 0
assert summer_precip.unit == 'inches'

By Field

from skywise.agriculture import Field

field = Field.find('my-field-id')
summer_precip = field.precip(start, end)
assert summer_precip.precipitation > 0
assert summer_precip.unit == 'inches'
assert summer_precip.fieldMean > 0
assert summer_precip.fieldMaximum > 0

Contours

summer_contours = field.precip_contours(start, end)

Solar Radiation

By Location

import arrow
from skywise.agriculture import Solar

start = arrow.get("2015-05-01").datetime
end = arrow.get("2015-07-31").datetime

summer_precip = Solar.location(35.66, -97.19, start=start, end=end)
assert summer_precip.solarRadiation > 0
assert summer_precip.unit == 'Watts per square meter'

By Field

from skywise.agriculture import Field

field = Field.find('my-field-id')
summer_solar = field.solar(start, end)
assert summer_solar.solarRadiation > 0
assert summer_solar.unit == 'Watts per square meter'
assert summer_solar.fieldMean > 0
assert summer_solar.fieldMaximum > 0

Contours

summer_contours = field.solar_contours(start, end)