Closed xmnlab closed 6 years ago
Hi @xmnlab, This may not be clear in the readme: Prior to running the server, you have to download all shapefiles from gadm.org, and then import the shapefiles to postgres. If you like, we can skype and I'll demonstrate.
Hi @mikefab
yes, I did it before to use coordinates_to_admin_id_server
download library seems to work fine.
There are one folder for each country at download_shapefiles_from_gadm/data/shapefiles/gadm2-8
The folders download_shapefiles_from_gadm
and import_shapefiles_to_postgres/
are in the same folder.
this is my conf.js file (import):
module.exports = {
shapefile_dir: '../download_shapefiles_from_gadm/data/shapefiles/',
pg_config: {
database: 'all_countries_one_table',
user: 'unicef', //env var: PGUSER
password: 'unicef', //env var: PGPASSWORD
host: 'localhost', // Server hosting the postgres database
port: 5432, //env var: PGPORT
max: 10, // max number of clients in the pool
idleTimeoutMillis: 30000, // how long a client is allowed to remain idle before being closed
},
}
After the installation, I call the package as mentioned in the documentation:
node main.js -s gadm2-8
To work better I create a postgres user with the same name as my linux user and configure its authentication method in postgresql configuration as peer (as postgres user).
local all myusername peer
After I call the package (as mentioned before), the result is like this:
...
ZWE !!!!
bash lib/create_db_all_countries_one_table.sh all_countries_one_table zwe_2_gadm2-8 ../download_shapefiles_from_gadm/data/shapefiles/gadm2-8/ZWE/ZWE_adm2.shp
Table exists all_countries_one_table
Done with import of admins.
...
The all_countries_one_table
database is created with two tables: all_countries_one_table
and spatial_ref_sys
... but all_countries_one_table table is empty. There are 5435 rows at spatial_ref_sys
table.
To test locally, I just dropped the all_countries_one_database db and ran: node main.js -s gadm2-8.
I stopped it after running a few countries, and then logged into postgres:
Looking back at my code, I realize I could have designed it better. Let me know if this helps. Also happy to screenshare on skype with you to see it live.
Also, to give you an idea of what's going on, the script begins by creating the db, and then scans all the country shapefiles to get a list of every column. Then it creates a table with those columns, and proceeds to append each shapefile.
Please see if this works from root of import_shapefiles_to_postgres:
node ./lib/get_all_geo_property_fields
I get...
@mikefab
thank you for your attention!
I found the problem ... I format my laptop some months ago and I "lost" the postgis ..
I installed it again and now I think it will work.
Thank you so much
Dear all,
I am trying to test the batch example, but the server return this:
The all_countries_one_table table has 0 rows .. Is that expected? The spatial_ref_sys table has 5435 rows.
Any idea about how to resolve this problem?