I am beginner of PostGIS. I am trying to import shapefile to PostGIS. But the file is not imported. What can I solve this problem?
Asked
Active
Viewed 656 times
0
-
1Welcome to SO. Would you care to show us how you tried to import the data? – Jim Jones Mar 02 '21 at 10:20
-
Does this answer your question? [Importing shapefiles in postgresql in linux using pgadmin 4](https://stackoverflow.com/questions/60036327/importing-shapefiles-in-postgresql-in-linux-using-pgadmin-4) – Jim Jones Mar 02 '21 at 10:21
-
I guess it is not – Kaleraa Mar 02 '21 at 10:35
-
I uploaded the ss. – Kaleraa Mar 02 '21 at 10:36
-
can you open this shapefile in qgis, save as another shapefile and import it again? It seems that the dbf (toc file!) is either corrupt or just not readable. – Jim Jones Mar 02 '21 at 11:22
-
I did it but it does not work – Kaleraa Mar 02 '21 at 11:24
-
odd. in this case I would try using `shp2pgql`. the error message is actually clear: the dbf file cannot be opened. now you need to investigate why :) normally I would ask you to share your shapefile, so that I can try it out myself, but since I do not have windows I am afraid it won't shed any light on your problem – Jim Jones Mar 02 '21 at 11:32
-
I am very grateful to you. I send to e-mail you..Thank you for everything. – Kaleraa Mar 02 '21 at 12:02
-
I am sorry I sent to wrong file because of similarity of file name. I send to right file now. – Kaleraa Mar 02 '21 at 18:07
1 Answers
0
You're trying to import a CSV with a Shapefile importer. To import your CSV file first create a table that corresponds to the CSV file structure, e.g. based on your CSV:
CREATE TABLE t (
a INT,
b TEXT,
c TEXT,
d TEXT,
e TEXT,
f TEXT,
g TEXT,
lat NUMERIC,
long NUMERIC,
j INT
);
Then import it using a tool like psql
:
$ cat fastfoodmaps_locations_2007.csv | psql -d yourdb -c "COPY t FROM STDIN CSV;"
Or simply connect to your database using psql
and from there run
\copy t FROM C:\path_to_csv_file\fastfoodmaps_locations_2007.csv CSV
.. then you will see your data:
SELECT * FROM t LIMIT 5;
a | b | c | d | e | f | g | lat | long | j
---+---+---------------------------+-----------+----+-------+----------------+---------+----------+---
1 | b | 3601 N.W. 27th Avenue | Miami | FL | 33142 | (305) 638-3838 | 25.8092 | -80.24 | 0
2 | b | 8995 N. W. 7th Avenue | Miami | FL | 33150 | (305) 754-8453 | 25.8587 | -80.2094 | 0
3 | b | 30390 South Dixie Highway | Homestead | FL | 33030 | (305) 247-7181 | 25.4849 | -80.461 | 0
4 | b | 7975 N. W. 27th Avenue | Miami | FL | 33147 | (305) 836-8152 | 25.8471 | -80.2415 | 0
5 | b | 9201 South Dixie Highway | Miami | FL | 33156 | (305) 666-1130 | 25.6849 | -80.3125 | 0

Jim Jones
- 18,404
- 3
- 35
- 44