PostGIS

GeoAlchemy2: Get the lat, lon of a point

妖精的绣舞 提交于 2019-12-22 13:44:08
问题 Consider the following SQLAalchemy / GeoAlchemy2 ORM with a geometry field: from geoalchemy2 import Geometry, WKTElement class Item(Base): __tablename__ = 'item' id = Column(Integer, primary_key=True) ... geom = Column(Geometry(geometry_type='POINTZ', srid=4326)) When I update an item in the PostgreSQL shell: UPDATE item SET geom = st_geomFromText('POINT(2 3 0)', 4326) WHERE id = 5; Fetching the field: items = session.query(Item).\ filter(Item.id == 3) for item in items: print item.geom Gives

Using osmosis to convert POSTGIS Table to .OSM

拥有回忆 提交于 2019-12-22 09:15:10
问题 I am using osmosis 0.42 and PostGIS 2.0.1 and I'm trying to export some postGIS tables to .OSM xml files. I am using the --read-pgsql command to read from postgis (instead of --read-apidb as it throws an error while connecting to the DB ).. Unfortunately running: osmosis --read-pgsql host="x" database="x" user="x" password="x" --write-xml file="myfile.osm" produce the following error: Task 2-write-xml does not support data provided by default pipe stored at level 1 in the default pipe stack

Enabling Ruby PostGIS support on Heroku

霸气de小男生 提交于 2019-12-22 05:59:15
问题 I'm trying to enable PostGIS in my Rails app on Heroku. My Gemfile includes the activerecord-postgis-adapter gem: gem 'activerecord-postgis-adapter', '3.0.0' However, after booting up my instance, I don't see full support enabled: $ heroku run irb Running `irb` attached to terminal... up, run.5549 irb(main):001:0> require 'rgeo' => true irb(main):002:0> RGeo::Geos.supported? => false I've added the heroku-geo-buildpack,as specified in the PostGIS article, though I'm using the newer, true

How to use Geo library to create valid Ecto Model changeset?

烈酒焚心 提交于 2019-12-22 04:39:20
问题 I'm trying to use Geo library to store Geo.Point via Phoenix model changeset. My params are: {coordinates: [49.44, 17.87]} or more prefer would be {coordinates: {latitude: 49.44, longitude: 17.87}} In iex console I tried: iex(5)> changeset = Place.changeset(%Place{}, %{coordinates: [49.44, 17.87]}) %Ecto.Changeset{action: nil, changes: %{}, constraints: [], errors: [coordinates: "is invalid"], filters: %{} model: %Myapp.Place{__meta__: #Ecto.Schema.Metadata<:built>, coordinates: nil, id: nil,

Django RF: POST geometry from Leaflet Draw to PostGIS

走远了吗. 提交于 2019-12-21 22:00:40
问题 I'm trying to store some geometry in a PostGIS DB which is created using Leaflet Draw. The following answer only covers the first part: how to transform the drawn shape into GeoJSON, i.e.: map.on(L.Draw.Event.CREATED, function (e) { var type = e.layerType var layer = e.layer; // Do whatever else you need to. (save to db, add to map etc) drawnItems.addLayer(layer); //Export to DB (source: https://stackoverflow.com/a/24019108/3976696) var shape = layer.toGeoJSON() shape_for_db = JSON.stringify

st_intersects Vs st_overlaps

六眼飞鱼酱① 提交于 2019-12-21 12:22:36
问题 What is the difference between these two queries : select a.gid, sum(length(b.the_geom)) from polygons as a , roads as b where st_intersects(a.the_geom,b.the_geom) group by a.gid ; select a.gid, sum(length(b.the_geom)) from polygons as a , roads as b where st_overlaps(a.the_geom,b.the_geom) group by a.gid ; Where the first query is giving the correct output whereas the second query retrieves no rows at all. The road that intersects the polygons also overlaps it, right? 回答1: From the

How to define 'geography' type using Npgsql and OrmLite (using postgresql, postgis, c#)

╄→гoц情女王★ 提交于 2019-12-21 12:03:03
问题 How do I define a postgis 'geography' type in my C# class model so that OrmLite can easily pass it through to Postgresql so I can run spatial queries in addition to saving spatial data to the 'geography' column? 回答1: The best library is NetTopologySuite for this case; you can use like this; protected GisSharpBlog.NetTopologySuite.Geometries.Geometry _geom; public GisSharpBlog.NetTopologySuite.Geometries.Geometry Geom { get { return _geom; } set { _geom = value; } } protected string _geomwkt;

importing osm file into a postgres/postgis database

天涯浪子 提交于 2019-12-21 11:43:19
问题 Im using the tool osm2pgsql to import an osm file into a postgres database using phppgadmin as the administrative tool. i have only downloaded a small town from osm in xml format and im having trouble importing it using the terminal on mac. Im a bit of a noob at this so any help would be greatly appreciated. Ive looked at several articles but none provide the clarity i need in order to fulfill my needs. Thanks im getting this error could be something small not sure.. Using projection SRS

Why is PostgreSQL so slow on Windows?

Deadly 提交于 2019-12-21 07:52:05
问题 We had an applicationg running using MySql. We found MySql was not suitable for our app after we found that it didnt support some of the GIS capability that PostGIS has (note: mysql only supports minimum-bounding rectangle GIS search). So we changed our DB to PostgreSQL. We then found out that Postgresql 8.2 running on Windows is so much slower compared to Mysql 5.1. By slower, I mean at roughly 4-5 times slower. Why is this? Is there something in the configuration that we need to change? I

Why is PostgreSQL so slow on Windows?

二次信任 提交于 2019-12-21 07:51:36
问题 We had an applicationg running using MySql. We found MySql was not suitable for our app after we found that it didnt support some of the GIS capability that PostGIS has (note: mysql only supports minimum-bounding rectangle GIS search). So we changed our DB to PostgreSQL. We then found out that Postgresql 8.2 running on Windows is so much slower compared to Mysql 5.1. By slower, I mean at roughly 4-5 times slower. Why is this? Is there something in the configuration that we need to change? I