Friday, 19 August 2016

How to import KML file, with custom data, to Postgres/PostGIS database?


By custom, I don't mean a different structure of KML file, but in section, I have data with HTML tags of this kind:







New York City





Attributes
CITY_ID150335
POPULATION8244910
AREA468.48
]]>



40.712964,-74.003886,0





I want to easily import all this data, for each placemark, to a table with corresponding columns in the database, how to do this?



Answer




you can use ST_GeomFromKML as this page.


SELECT ST_GeomFromKML('

-71.1663,42.2614
-71.1667,42.2616

');

or you can use ogr2ogr as following to process entire KML files;


ogr2ogr -f "PostgreSQL" PG:"host=yourhost user=youruser dbname=yourdb 
password=yourpass" inputfilename.kml


i hope it helps you...


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...