PostGIS

How do I clean up self-intersecting polygons in a spatial database?

≯℡__Kan透↙ 提交于 2019-12-10 15:33:53
问题 I have some spatial data (MapInfo files) that contains self-intersecting polygons. These cause problems in my processing, in particular I can't generate geometric unions in PostGIS. Is there an easy way to resolve the issue? I can deal with multi-polygons if that should be necessary. 回答1: I figured it out myself: an st_buffer(wkb_geometry,0) does the trick, at least on my sample data. 来源: https://stackoverflow.com/questions/4846391/how-do-i-clean-up-self-intersecting-polygons-in-a-spatial

Hibernate Spatial with PostGIS's Geography Type

微笑、不失礼 提交于 2019-12-10 14:54:12
问题 I just added a column of type Geography to a Postgres database that is accessed by an application using hibernate and hibernate spatial. Whenever I access that column with hibernate I get an error saying "Can't convert object of type org.postgresql.util.PGobject". I was using an older version of hibernate spatial but it seems that even the newest version does not support the Geography datatype. Is this really the case or did I just miss something. Is there a way I can work around this

save polygon from image to PostGIS database

余生长醉 提交于 2019-12-10 11:43:59
问题 I'm working on a software to detect buildings from satellite imagery. so far I have managed to separate the building with other objects of the image. My problem now is how to save every building in the shape of a polygon into a PostGIS database? Are there libraries available ata function in java and PostGIS? 回答1: Add the image to postgis using the python function raster2pgsql, http://suite.opengeo.org/opengeo-docs/dataadmin/pgGettingStarted/raster2pgsql.html Then, you can use ST

Postgres: How to find nearest tsrange from timestamp outside of ranges?

戏子无情 提交于 2019-12-10 11:22:26
问题 I am modeling (in Postgres 9.6.1 / postGIS 2.3.1) a booking system for local services provided by suppliers: create table supplier ( id serial primary key, name text not null check (char_length(title) < 280), type service_type, duration interval, ... geo_position geography(POINT,4326) ... ); Each supplier keeps a calendar with time slots when he/she is available to be booked: create table timeslot ( id serial primary key, supplier_id integer not null references supplier(id), slot tstzrange

How to calculate distance between two PointField?

狂风中的少年 提交于 2019-12-10 11:08:26
问题 I use Postgis with Django to store geographic points. I have a model like the following: from django.contrib.gis.db import models class Event(models.Model) position = models.PointField() I have two events(ev1, ev2). Here is the position value of each: SRID=4326;POINT (-73.6335140000000052 45.5472019999999986) SRID=4326;POINT (-73.6267909999999972 45.5459189999999978) My goal is to get distance in meters between those two points. If i do: ev1.position.distance(ev2.position) I get 0

Sequelize WHERE sequelize.fn(…) AND something='something' ordering issue

a 夏天 提交于 2019-12-10 10:49:58
问题 I have a Sequelize findOne function that looks to select a row where the given point intersects a polygon (col 'geom') AND status = 'active'. var point = sequelize.fn('ST_GeomFromText', 'POINT(' + lng + ' ' + lat +')', 4326); var intersects = sequelize.fn('ST_Intersects', sequelize.col('geom'), point); GeoCounty.findOne({ attributes: ['id', 'name' ], where: { status: 'active', $and: intersects }, plain: true }) As of right now, it works just fine. It produces SQL that looks like: SELECT "id",

Error when installing postgis extension to postgresql database

删除回忆录丶 提交于 2019-12-10 10:24:21
问题 Im having problem installing postgis to an existing database. but getting error like this: ERROR: could not load library "/usr/local/pgsql/lib/postgis-2.0.so": libgeos_c.so.1: cannot open shared object file: No such file or directory the postgis-2.0.so is in /usr/local/pgsql/lib/postgis-2.0.so no problem. the libgeos_c.so.1 is installed in /usr/local/lib . So, what is the problem here? Any help would be appreciated. Thanks. BTW, I installed all these followed by this tutorial: http://www

In PostGIS a polygon bigger than half the world is treated as it's opposite

我只是一个虾纸丫 提交于 2019-12-10 04:26:47
问题 I'm using GeoDjango with PostGIS and trying to use a polygon to get records from a database which fall inside it. If I define a polygon which is bigger than half the area of the earth it assumes the 'inside' of my polygon is the smaller area which I intended as the 'outside' and returns only results which are outside it. I can just use this smaller, wrong area to exclude results. Polygon.area seems to know what I intend so I can use this to determine when to make my search inclusive or

Postgres Postgis error: Library not loaded: /usr/local/lib/libspatialite.5.dylib

浪子不回头ぞ 提交于 2019-12-10 02:31:08
问题 While browsing through a Postgres-Rails app in development, I came across a page error-ing out due to a PG error. Thinking my current Git branch's schema may have been out of sync with my database, I attempted to rake db:reset . This caused an error (that I'm no longer able to reproduce) claiming it couldn't find the postgis.control file (IIRC) in usr/local/Cellar/postgresql/9.3.5/share/postgresql directory. After seeing that that control file existed in the corresponding directory for my 9.3

hibernate-spatial: sql query to retrieve a geometry

ぐ巨炮叔叔 提交于 2019-12-09 16:43:19
问题 I'm using postgresql, hibernate-spatial and postgis and expected to be able to use a SqlQuery to retrieve a Geometry object. However whenever I try to query a Point, Polygon or Geometry eg List list = session.createSQLQuery( "select geomfromewkt('SRID=1;POINT(1 1)')").list(); I get the exception: Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111 at org.hibernate.dialect.TypeNames.get(TypeNames.java:78) at org.hibernate.dialect.TypeNames.get(TypeNames.java:103)