Tag Info

Hot answers tagged

15

I just had the same problem on Ubuntu Server 14.04. I installed postgis extension from the official Ubuntu repositories using apt-get install postgis. Then, find /usr -name postgis.control didn't return any results. The reason was extension/postgis.control wasn't installed because postgis-scripts wasn't. $ aptitude search postgis i libpostgis-java ...


12

I think this is the most frequent question on PostGIS list over time :-) If your data is in SRID 4326 and you use geometry type the result will not give any meaning. It is in degrees. To get the result in meters just cast to geography type and ST_Distance will calculate the distance along the great circle instead and return in meters. ...


10

It's necessary to calculate the actual intersection, e.g. http://postgis.net/docs/ST_Intersection.html SELECT ST_Length(ST_Intersection(line,polygon))


10

I'm surprised it's quite so coarse, but there it is. It's not DISTINCT, per se, it's the '=' operator, which is defined for geometry as 'equality of the index keys' which means practically 'equality of the 32-bit bounding boxes'. You can see the same effect just using '=' directly, select 'POINT (0.000000001 0.000000001)'::geometry = 'POINT (0.000000001 ...


9

I would recommend using pg_dump and pg_restore which work very well in exporting data from one database and then restoring it to another database. there is a nice tutorial here http://www.mkyong.com/database/backup-restore-database-in-postgresql-pg_dumppg_restore/ But simply you will want to export using a command like pg_dump -U username databasename ...


8

Celenius, If you don't use the -t option with size dimensions, then your raster file will come in as a single record. I just noticed an error in the docs which is probably what's confusing you. I'll fix that. The -t should always be followed by a widthxheight. If you want it to be chunked say in 100x100 pixel width height -- as Mapperz says -- use the ...


8

In Ubuntu 14.04 you also need to install the postgresql-9.3-postgis-scripts package. After I ran sudo apt-get install postgis postgresql-9.3-postgis-scripts I was then able to successfully run CREATE EXTENSION postgis; in my database to initialise PostGIS.


7

Maybe something like this (I'll assume you have some primary key column "id" in each table): SELECT A.id, A.code AS Code, A.sign AS Sign, B.id, ST_Distance(A.geom, B.geom) AS Distance FROM Table_A AS A, Table_B AS B WHERE A.id IN ( SELECT X.id FROM TableA as X, TableB as Y -- Here's the important part: refer to the A table **outside** of the ...


7

GeoDjango 1.4 supports PostGIS 2.0 with too many workarounds to make it worth it. Instead, install GeoDjango 1.5 beta which natively supports PostGIS 2.0 and switch to the official release next month.


7

Assuming your data table look like: streetid housenumber 100 12 100 15 101 12 101 18 You could do a basic SQL query: SELECT streetid, count(*) FROM tablename GROUP BY streetid Where this might get more GIS-y and interesting is the case where streets with the same ID are not contiguous. You didn't mention if this is a ...


6

Revert your software to 1.5, then follow the HARD UPGRADE instructions in the manual, doing the dump step, then the software upgrade, then the restore steps. http://postgis.net/docs/manual-1.5/ch02.html#hard_upgrade


6

You're constructing a POINT with four ordinates. To the parser that looks like a POINT ZM. You want to construct a LINESTRING. ST_SetSRID(ST_MakeLine(ST_MakePoint(lon1, lat1), ST_MakePoint(lon2, lat2)), 4326)


6

You can use a typmod to specify the srid in the geometry_columns view, something like CREATE VIEW pippo AS SELECT st_geometryn(shape,1)::geometry(Geometry, 4326) as geom FROM events The manual has more info.


6

Simple answer: Don't. You shouldn't do it that way. From the OSM road Shapefiles, it is impossible to distinguish between intersections and over/underpasses. You'll create intersections that don't exist in reality if you split all seemingly crossing roads. You'll need to get your hands dirty with the original OSM file, if you don't want to use existing ...


6

To my knowledge, GIS as Arcmap or QGIS can't support layers with several primitives (point, polygon or polyline). What GIS do you use? You can try to create tables for each type: Point: SELECT * INTO newtablepoints FROM initial_table WHERE ST_GeometryType(geom) = 'ST_Point' ; polygon : SELECT * INTO newtablepolygones FROM initial_table WHERE ...


6

What does the “service” box in the PostGIS connection dialog stand for?: The service entry allows you to specify a service file that contains the connection parameters needed to access a certain postgresql database. By having a service file, you can then ignore having to enter other details like database, host, port, user and password. Here are some of ...


6

When you spatially-enable a PostGIS database, the relevant functions, SRS table, and views are placed in the public schema, as you state. That does not mean that all or any of your own spatial tables need to be in the same public schema. PostGIS will still work on all spatial data in the "new" schemas. In fact, I usually place my application-specific tables ...


6

To create 1 random point for each polgyon in a table I have used this table and code: DO $$ DECLARE r RECORD; BEGIN FOR r IN SELECT id_0 FROM "Grid" LOOP -- RAISE NOTICE 'affected row id: %', r.id_0; UPDATE "Grid" SET "point_geom" = (SELECT RandomPointsInPolygon(geom, 1) FROM "Grid" WHERE "id_0" = r.id_0) WHERE "id_0" = r.id_0; END LOOP; END$$; ...


6

Your table seems to be an Amersfoort oblique stereographic (EPSG:28992). To use a lon/lat point as input, you need to create it as a lon/lat point, then transform it, so your distance function would look something like this: ST_Distance(geom, ST_Transform(ST_SetSRID(ST_MakePoint(5.112472, 52.008417),4326),28992))


5

Naturally you back up your database on a regular basis, so it should be a simple case of restoring from the last backup. PostgreSQL also has cool features that allow live swapping of a production database using the Write Ahead Logging system and some very clever thinking. That said, if for some reason your backups aren't up to date, or gasp non existent, ...


5

You'll want to check that /etc/ld.so.conf has a referencence to the path /usr/lib64/mpich2/lib. If you add the path to ldo.so.conf, make sure to run ldconfig. You can then see what is in the ld cache using "ldconfig -p".


5

You will definitely want to tile your raster. The maximum width x height permitted for the PostGIS raster type is 65535 x 65535, regardless of whether or not the raster is in-db or out-db. The other reason to tile your raster (though this may not apply in your case) is that the maximum field size permitted by PostgreSQL is 1 GB [1]. As for optimal tile ...


5

For those who will stumble on this question like me.. It appears that the plugin has been generated (https://github.com/strk/mapnik/tree/2.3.x-pgraster) and has been merged in official Mapnik Repo. The branch is 2.3.x (https://github.com/mapnik/mapnik/tree/2.3.x) Now you can build Mapnik from the branch and use PGRaster plugin to use Raster data from ...


5

Why don't you try the OSGEO Live DVD, check this website for more information and download.


5

Yes, you can, and the PostGIS documentation page for ST_Distance_Sphere and ST_Distance_Sphereoid both contain good examples. Here's one with lon/lat values plugged in to the ST_Point function: SELECT st_distance_sphere( st_point(-69.23, 44.61), st_point(-75.42, 43.55) ) The result in this example is 508166.687378974 meters. To ...


5

PostGIS Windows dl site provides information about running it without installing. The blog it links to has all the info needed.


5

In ArcGIS you don't need to create a buffer layer as AllenT suggested. You can do it just by using the selection tools without creating any additional layers. Firstly, you will need a layer representing your coastline. Depending on where your area of interest is, you may need to either digitise it or download it. Then, you can use Select by Location to ...


5

PostgresSQL/PostGIS is a relational database management system ( RDBMS) and the original order of the columns have no significance. If you want to change the order in which they appear, use SQL: select Field2, Field3, Field1 from table; select Field1, Field3, Field2 from table; And if you want to keep this ordered result as a table in the database, use ...


5

You no longer need to use the templates or even the script in the new versions of Postgis. As you can see in the Postgis - installation page, all you need is run the CREATE EXTENTION command. -- Enable PostGIS (includes raster) CREATE EXTENSION postgis; -- Enable Topology CREATE EXTENSION postgis_topology; -- fuzzy matching needed for Tiger CREATE EXTENSION ...


5

I made and tested the functions I need. For point generation I used a simplified version of the functions in trac.osgeo.org/postgis/wiki/UserWikiRandomPoint: CREATE OR REPLACE FUNCTION random_point( x_min integer DEFAULT 13, y_min integer DEFAULT 49, x_max integer DEFAULT 16, y_max integer DEFAULT 51, srid integer DEFAULT 4326 ) RETURNS geometry AS ...



Only top voted, non community-wiki answers of a minimum length are eligible