Skip to content

Instantly share code, notes, and snippets.

@andrewxhill
Created May 4, 2011 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewxhill/954622 to your computer and use it in GitHub Desktop.
Save andrewxhill/954622 to your computer and use it in GitHub Desktop.
class OccurrenceSetIndex(db.Model): #parent = OccurrenceSet see below
terms = db.ListProperty() #string values to search for sets
class OccurrenceSet(db.Model): #key_name = wwf/puma_concolor or something
name = db.StringProperty() #this could be non-unique, Puma concolor is fine
source = db.StringProperty() #wwf
info = db.BlobProperty() #some meta standard for sets of occ polygons
class OccurrenceIndex(db.Model): #parent = OccurrencePolygon see below
introduced = db.BooleanProperty()
#etc
cluster = db.ReferenceProperty() #OccurrenceSet
class OccurrencePolygon(db.Model): #key_name = some_id
name = db.StringProperty()
type = db.CategoryProperty() #'ecoregion' would be one
info = db.BlobProperty() #some meta standard based on the type, but not restriced by the datastore model
@andrewxhill
Copy link
Author

ID,ECOREGION_CODE,SPECIES_ID,DELETED,INTRODUCED
1,AT0101,14,N,N
1,AT0103,14,N,N
1,AT0105,14,N,Y
"SPECIES_ID","Latin","GENUS","FAMILY","ORDER_DESC","CLASS","MAPPED","DELETED"
14,"Ambystoma amblycephalum","Ambystoma","Ambystomatidae","Caudata","Amphibia","Y","N"

@eightysteele
Copy link

class OccurrencePolygonSet(db.Model):
pass

class Ecoregion(db.Model):
cluster = db.ReferenceProperty(OccurrencePolygonSet)
terms = db.StringListProperty()

ecoName = db.StringProperty()
realm = db.StringProperty()
biome = db.IntegerProperty()
ecoNum = db.IntegerProperty()
ecoId = db.IntegerProperty()
g200Region = db.StringProperty()
g200Num = db.IntegerProperty()
g200Biome = db.IntegerProperty()
g200Stat = db.IntegerProperty()
extentNorthWest = db.GeoPtProperty()
extentSouthEast = db.GeoPtProperty()
polyStrings = db.StringListProperty()
dateCreated = db.DateTimeProperty(auto_now_add=True)

Find all ecoregions for a cluster where the ecoregion is introduced, deleted, and g200Num is 2:

cluster = OccurrencePolygonSet.get(some_key)
Ecoregion.all().filter('cluster =', cluster).filter('terms = introduced').filter('terms = deleted').filter('g200Num =', 2).fetch()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment