Hot answers tagged

28

If you have a Windows computer, you can use good 'ol CMD.EXE with a few esoteric for-loops. Make sure you do this in a "contained" directory with only the shp/sql files that you need to load. First step, create the SQL loader files (I also assumed you have Lat/Long WGS84 data with 4326 .. update this to your SRS): for %f in (*shp) do shp2pgsql -s 4326 %f ...


20

If want to stick to a GUI then the newer version of pgAdmin has Shapefile Loader that can be used as a bulk load


11

If you want a painless install, you might want to start over and use the OpenGeo Suite version of PostGIS. $sudo wget -qO- http://apt.opengeo.org/gpg.key | apt-key add - $sudo echo "deb http://apt.opengeo.org/ubuntu lucid main" >> /etc/apt/sources.list $sudo apt-get update $apt-cache search opengeo $sudo apt-get install opengeo-postgis Or you could ...


7

I don't believe the Shapefile loader will work in your case. However, PostGIS comes with a raster loading tool called raster2pgsql. This tool will load any GDAL supported raster format into PostGIS Raster. It is a command-line tool so to execute it you just need to run: raster2pgsql raster_options schema.table_name > output.sql So, the tool will take ...


6

If you are working on your workstation it's more a matter of taste. Knowing how to use psql is useful for some situations like running sql scripts from files, pipe it with other tools, etc. It depends on your needs. My everyday work is done using pgAdmin and I only go down to the CLI when needed. On the other hand psql is sometimes your only option when ...


6

I guess you are a victim of the fact that spatially enabling a PostgreSQL db with PostGIS creates a bunch of functions in the "public" namespace. If you backup the public namespace and then restore it to a PostGIS db these functions will already exist, causing errors. As Paul Ramsey wrote (in a blog post explaining the issue in detail and giving advice): ...


6

I decided to go ahead and use the command line utility (shp2pgsql) to import my .shp file. Since I was able to get it working without too much trouble and a little Googling around I wanted to share this possible solution for anyone else who just wants to import a .shp file into Postgres and didn't want to deal with the hassle of trying to get pgadmin's GUI ...


5

While I have not actually installed it, I had read about the pgAdmin plugin called "PostGIS viewer" (Windows only) referenced here (2010). The first request to add something like this (that I found) was ticket #485. Germán Carrillo developed a multiplatform "PostGIS viewer" based on PyQGIS. You can access old versions here, here, and here, all from 2011. ...


4

I don't think the issue is with the ST_GeomFromGeoJSON call. It's possibly the id field you have OR your table structure. Can you provide your table structure. SELECT ST_GeomFromGeoJSON('{"type":"Point","coordinates":[-48.23456,20.12345]}'); alone works fine, so doubt that is your issue. If the above query fails, then your postgis install is corrupt in ...


4

I can't believe I'm having the same issue in 2014 with 12.04. Neither the GUI nor command-line shapeloader install using the opengeo-suite. I simply followed the noob-friendly directions on this website: http://www.staygeo.com/2013/05/enabling-postgis-shapefile-and-dbf.html, which parallel the instructions by RK almost 2 years ago. "Install opengeo-...


3

The easiest would be to setup PostgreSQL user group roles and assign permissions based on those roles. It's a lot easier in PostgreSQL 9.0+ since you can use DEFAULT PRIVILEGES. --this will take care of future tables in a database ALTER DEFAULT PRIVILEGES GRANT ALL ON TABLES TO gisadmins; -- this will take care of existing tables in public schema. As I ...


3

Yes, absolutely. PostgreSQL is set up to only accept local connections, and GeoServer is set up to use the loopback address i.e. 127.0.0.1 on port 8080. So you can run the standard installers and everything should just work when you type: http://localhost:8080 You'll need to set up GeoServer to see your PostgreSQL database, but that's standard stuff ...


3

Any table in the instance can be registered with sde. But sde is what has to do that registration. I suggest starting with this Essential Reading for Geodatabases Registering with the database


3

PgAdmin has limits on the largest object it can display in a table cells. Large geometries frequently exceed this limit, which results in an "empty" cell, confusing to new users. If you call ST_NPoint(geom) or ST_GeometryType(geom) you can see that the geometry is in fact there, and does have data in it, you just cannot see it in a PgAdmin cell.


3

This response may be late,but i had the same trouble and i found the solution. Try this command on your terminal : $sudo ln -s /usr/lib/postgresql/9.1/bin/shp2pgsql /usr/bin/shp2pgsql


3

The pair that you want is PG_Dump and PG_Restore... I use PG_Dump on a scheduled task to backup our PostGIS databases in a format that can be restored easily - and more importantly will work! pg_dump.exe --file=c:\Your\path\BACKUP_Name.Backup -Fc -Z9 -o DatabaseName Custom format Z9 compression (to save space) Include objectIDs and then to restore on ...


3

Here is a code sample to show how you could publish a WMS layer hosted on geoserver in Leaflet: var map = L.map('map').setView([51.505, -0.09], 8); var forest2000 = L.tileLayer.wms("http://138.26.24.xxx:8080/geoserver/tiger/wms",{ layers: 'forest2000', format: 'image/png', transparent: true, opacity: 0.7 }).addTo(map); Change ...


3

The error happened because EPSG:5514 is no added in spatal_ref_sys table. So you can add it using the following query. INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) values ( 5514, 'EPSG', 5514, '+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +towgs84=589,76,480,...


3

You seem to have a PostGIS installation that was created by loading the postgis.sql file, rather than using the CREATE EXTENSION postgis command. So when you dumped your database, you got not only the data, but also all the function definitions, which includes references to the 2.1 PostGIS library. Install PostGIS 2.1.8 on your new system. Create a blank ...


2

You might also want to look at SPIT, which is a PostGIS loader plugin for QGIS


2

You can also use this single command which helps in looping much easier and also does not need to create .sql separately, for f in *.shp do shp2pgsql -c -D -s 4326 -I $f public.${f%.*} | psql -h hostname -d dbname -U usrname done


2

I just figured out that one of my earlier approaches would have worked, but I had a typo in my postgres query. Right-click and copy the binary hex string from SQL Server Management Studio. Paste into a string in the PG Admin III SQL Editor window. Delete the "0x" at the beginning of the string. Wrap that value with a decode. Now ST_GeomFromWKB has WKB. ...


2

No and yes. You can configure pgadmin to call external programs, like shp2pgsql-gui, out of a menu option, which can make things easier for new users (see OpenGeo Suite, for example). But a full commandline like shp2pgsql has too many parameters needed to be effectively called by pgadmin.


2

My problem was that I could not find the pg_dump command. I thought it was a subcommand of psql command. You need to add c:\program files\postgresql\9.3\bin> to path(system variables) of windows or use its direct executable file: export: c:\program files\postgresql\9.3\bin> pg_dump.exe -U postgres test2 >"d:\backup.sql" import: c:\program files\...


2

Solved, thanks. Needed to being ST_Transform instead of ST_SetSRID (see last comment / link) ALTER TABLE public.roads_sco ALTER COLUMN geom TYPE geometry(MULTILINESTRING, 27700) USING ST_Transform(ST_SetSRID(geom,4326),27700)


2

In general to update one table from another, and this applies whether there is a spatial join condition or not, you follow the UPDATE...SET...FROM...WHERE pattern, see the docs. In this case, your WHERE condition is an ST_Contains or ST_Intersects, but it is essentially the same as joining on two IDs or some other condition. It is often convenient to use ...


2

Here is a...unique(??) way of doing it. I managed to create routes using QGIS 2.14 with GRASS and rasters. I got the idea from here. To summarize we will rasterize the land and sea, run a proximity algorithim, invert the output, run a cost, and drain algorithm in GRASS and finally polygonize the routes to polylines. 1) Rasterize your land and sea. First ...


1

If I understand correctly you have a paper plan of city and you want to create a table with geometries and ref numbers from readed 'manualy' coordinates from this paper map? Assuming that: Your table name is parcels It have column ref_number and geom The query could be: insert into parcels(ref_number,geom) values (1,ST_makepoint(wsp_x, wsp_y)) You ...


1

I think it's a bit simpler than that. PostGIS natively understands HEX. I think you can do this -- here is a string I got from SQL Server STAsBinary() output (after stripping off the 0x) SELECT '0101000000000000000000F03F0000000000000040'::geometry;


1

The pgRouting workshop gives a simple example how to return the path geometries. But this would work in the same way for any other attribute: SELECT seq, id1 AS node, id2 AS edge, cost, b.the_geom FROM pgr_dijkstra(' SELECT gid AS id, source::integer, target::integer, ...



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