How to use the geojson.dumps function in geojson

To help you get started, we’ve selected a few geojson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jazzband / geojson / tests / test_strict_json.py View on Github external
def _raises_on_dump(self, unstrict):
        with self.assertRaises(ValueError):
            geojson.dumps(unstrict)
github jazzband / geojson / tests / test_crs.py View on Github external
def test_crs_decode(self):
        dumped = geojson.dumps(self.crs)
        actual = geojson.loads(dumped)
        self.assertEqual(actual, self.crs)
github SEL-Columbia / networkplanner / np / controllers / scenarios.py View on Github external
elif format == 'zip':
                return ''
            elif format == 'geojson':
                return geojson.dumps(geojson.FeatureCollection([]))
            elif format == 'json':
                return cjson.encode({})
        # If the scenario has an error,
        if c.scenario.status == model.statusFailed:
            c.traceback = c.scenario.output['traceback']
            c.status = model.statusFailed
            if format == 'html':
                return render('/scenarios/show.mako')
            elif format == 'zip':
                return forward(FileApp(c.scenario.getFolder() + '.zip'))
            elif format == 'geojson':
                return geojson.dumps(geojson.FeatureCollection([]))
            elif format == 'json':
                return c.scenario.exportJSON()
        # If the scenario has not been processed,
        if c.scenario.isQueued():
            c.status = model.statusPending
            if format == 'html':
                return render('/scenarios/show.mako')
            elif format == 'zip':
                return forward(FileApp(c.scenario.getFolder() + '.zip'))
            elif format == 'geojson':
                return geojson.dumps(geojson.FeatureCollection([]))
            elif format == 'json':
                return c.scenario.exportJSON()
        # Prepare
        c.status = model.statusDone
        c.scenarioInput = c.scenario.input
github NCPP / ocgis / ocgis_merge / src / openclimategis / util / ncconv / experimental / ocg_converter / geojson_.py View on Github external
#        if self.use_geom:
#            raise(NotImplementedError)
#            headers = ['GID','WKT']
#        else:
##            if self.use_stat:
##                adds = ['WKT']
##            else:
##                adds = ['WKT','TIME']
#            headers = self.get_headers()
        features = [attrs for attrs in self.get_iter(wkt=True)]
        for feat in features:
            feat['geometry'] = feat.pop('WKT')
            if 'TIME' in feat:
                feat['TIME'] = str(feat['TIME'])
        fc = geojson.FeatureCollection(features)
        return(geojson.dumps(fc))
github csparpa / pyowm / pyowm / utils / geo.py View on Github external
def geojson(self):
        return geojson.dumps(self._geom)
github SEL-Columbia / networkplanner / np / controllers / scenarios.py View on Github external
return render('/scenarios/show.mako')
            elif format == 'zip':
                return forward(FileApp(c.scenario.getFolder() + '.zip'))
            elif format == 'geojson':
                return geojson.dumps(geojson.FeatureCollection([]))
            elif format == 'json':
                return c.scenario.exportJSON()
        # If the scenario has not been processed,
        if c.scenario.isQueued():
            c.status = model.statusPending
            if format == 'html':
                return render('/scenarios/show.mako')
            elif format == 'zip':
                return forward(FileApp(c.scenario.getFolder() + '.zip'))
            elif format == 'geojson':
                return geojson.dumps(geojson.FeatureCollection([]))
            elif format == 'json':
                return c.scenario.exportJSON()
        # Prepare
        c.status = model.statusDone
        c.scenarioInput = c.scenario.input
        c.scenarioOutput = c.scenario.output
        transform_point = geometry_store.get_transform_point(geometry_store.proj4LL, geometry_store.proj4SM)
        # If the user wants HTML,
        if format == 'html':
            # Render scenario
            c.metricModel = metric.getModel(c.scenarioInput['metric model name'])
            scenarioStatistics = c.scenarioOutput['statistics']
            nodeStatistics = scenarioStatistics['node']
            # Prepare map
            centerX, centerY = transform_point(nodeStatistics['mean longitude'], nodeStatistics['mean latitude'])
            box1X, box1Y = transform_point(nodeStatistics['minimum longitude'], nodeStatistics['maximum latitude'])
github NCPP / ocgis / ocgis_merge / src / openclimategis / util / ncconv / experimental / OLD_experimental / in_memory_oo_multi2.py View on Github external
def as_geojson(elements):
    features = []
    for e in elements:
        e['properties']['timestamp'] = str(e['properties']['timestamp'])
        features.append(geojson.Feature(**e))
    fc = geojson.FeatureCollection(features)
    return(geojson.dumps(fc))
github hotosm / tasking-manager / server / models / postgis / project.py View on Github external
def set_project_aoi(self, draft_project_dto: DraftProjectDTO):
        """ Sets the AOI for the supplied project """
        aoi_geojson = geojson.loads(json.dumps(draft_project_dto.area_of_interest))

        aoi_geometry = GridService.merge_to_multi_polygon(aoi_geojson, dissolve=True)

        valid_geojson = geojson.dumps(aoi_geometry)
        self.geometry = ST_SetSRID(ST_GeomFromGeoJSON(valid_geojson), 4326)
        self.centroid = ST_Centroid(self.geometry)
github NCPP / ocgis / ocgis_merge / src / openclimategis / util / ncconv / converters.py View on Github external
def as_geojson(elements):
    features = []
    for e in elements:
        e['properties']['timestamp'] = str(e['properties']['timestamp'])
        features.append(geojson.Feature(**e))
    fc = geojson.FeatureCollection(features)
    return(geojson.dumps(fc))
github thinkWhere / geopython17 / micro / models / postgis / mapping.py View on Github external
def __init__(self, name, feature):
        """ Construct mapping object from a GeoJson feature"""
        self.name = name
        geojson_str = geojson.dumps(feature['geometry'])
        self.geometry = ST_SetSRID(ST_GeomFromGeoJSON(geojson_str), 4326)