Importing shapefiles in postgresql in linux using pgadmin 4

孤人 提交于 2020-12-26 08:23:06

问题


I am new to postGIS, I was following this tutorial.

I can't get past the installation part because the instructions are outdated.

I got stuck when it says return to the Dashboard, and click on the Import shapefiles link in the PostGIS section.

I am using pgadmin 4 and I am unable to find the postGIS section there.


回答1:


If you're simply trying to import shapefiles into PostgreSQL, you might wanna take a look at shp2pgsql.

Data sample: TM_WORLD_BORDERS_SIMPL-0.3.zip

After unpacking your zip file just execute the following line in your console:

$ shp2pgsql -I -s 4326 TM_WORLD_BORDERS_SIMPL-0.3.shp table_world | psql -d mydb

Things to take into account:

  • table_world is the name of the target table
  • psql -d mydb takes into account that your current operating system user has an account in the database, that no password is required, that the database is installed at localhost and that it listens at the the standard port 5432. Check the psql documentation to build your own connection command, e.g. psql -U myuser -h 192.168.1.42 -p 5434 -d mydb to login with the user myuser in the database mydb in the remote PostgreSQL at 192.168.1.42 that listens at the port 5434. In case your PostgreSQL isn't configured to accept connections, check this answer.
  • 4326 is the identifier for WGS84, which is the spatial reference system of this shapefile - and the most often used worldwide.

.. and your data is ready to be played with. Screenshot from the geometry viewer of pgAdmin4:

Further reading:

  • psql
  • shp2pgsql tutorial


来源:https://stackoverflow.com/questions/60036327/importing-shapefiles-in-postgresql-in-linux-using-pgadmin-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!