예제 #1
0
class County:
    counties = {
        county['properties']['name']:
        GEOSGeometry(json.dumps(county['geometry']))
        for county in datafile('california-counties.geojson')['features']
        if county['properties']['name'] in [
            'Fresno',
            'Kern',
            'Kings',
            'Madera',
            'Merced',
            'San Joaquin',
            'Stanislaus',
            'Tulare',
        ]
    }

    names = list(sorted(counties.keys()))

    @classmethod
    def lookup(cls, point, default=''):
        for name, geometry in cls.counties.items():
            if geometry.contains(point):
                return name
        return default
 def load_counties(self):
     geometry = [
         shape(county['geometry']) for county
         in datafile('california-counties.geojson')['features']
         if county['properties']['name'] in [
             'Fresno',
             'Kern',
             'Kings',
             'Madera',
             'Merced',
             'San Joaquin',
             'Stanislaus',
             'Tulare',
         ]
     ]
     return gpd.GeoDataFrame({'geometry': geometry})
예제 #3
0
def load_datafile(name):
    return datafile(name)