How to use the geoalchemy2.WKTElement function in GeoAlchemy2

To help you get started, we’ve selected a few GeoAlchemy2 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 geoadmin / 3d-forge / forge / db.py View on Github external
self.logger.info('Action: populateTables()')
        session = scoped_session(sessionmaker(bind=self.userEngine))
        for model in models:
            count = 1
            shpFiles = model.__shapefiles__
            for shpFile in shpFiles:
                if not os.path.exists(shpFile):
                    self.logger.error('Shapefile %s does not exists' % shpFile)
                    sys.exit(1)
                features = ShpToGDALFeatures(shpFile).__read__()
                bulk = BulkInsert(model, session, withAutoCommit=1000)
                for feature in features:
                    polygon = feature.GetGeometryRef()
                    bulk.add(dict(
                        id=count,
                        the_geom=WKTElement(polygon.ExportToWkt(), 4326)
                    ))
                    count += 1
                bulk.commit()
                self.logger.info('Commit features for %s.' % shpFile)
        self.logger.info('All tables have been created.')
github jet-admin / jet-bridge / packages / jet_bridge_base / jet_bridge_base / fields / wkt.py View on Github external
def to_internal_value_item(self, value):
        if value is None:
            return
        from geoalchemy2 import ArgumentError, WKTElement
        try:
            return WKTElement(value)
        except ArgumentError as e:
            self.error('invalid', error=six.text_type(e))
github ibis-project / ibis / ci / datamgr.py View on Github external
                lambda x: WKTElement(x, srid=srid)
            )
github lbud / run_sf / utils / dbs.py View on Github external
def store_intersection(id, ints, lat, lon, elev):
    """ Store intersections in DB """
    loc = 'POINT(%r %r)' % (lon, lat)
    i = GIntersection(
        id=id, ints=ints, lat=lat, lon=lon, loc=WKTElement(loc, srid=4326),
        elev=elev
    )
    session.add(i)
    return None
github GeoGuideProject / geoguide / geoguide / server / geoguide / helpers.py View on Github external
        df['geom'] = df.apply(lambda r: WKTElement('POINT({} {})'.format(r[dataset.longitude_attr], r[dataset.latitude_attr])), axis=1)
        df.to_sql(table_name, engine, if_exists='append', index_label='geoguide_id', chunksize=CHUNKSIZE, dtype={'geom': Geometry('POINT')})