raster2pgsql should be able to read most .asc formats with metadata header (if raster data is what you want, as opposed to point clouds). also, you can run the command to batch insert via shell/terminal script.
– ThingumaBobMay 2 '18 at 18:57

@Mapperz @ThingumaBob my final goal is intersecting this elevations with some polygons representing buildings using standard Postgis like ST_Intersects in WGS84. Is it better Raster or PointCloud?
– RandomizeMay 2 '18 at 19:05

the pgpointcloud suite is mighty and fast, but not exactly user friendly. it's worth to get into it when you plan on, say, some serious 3D modeling. raster in PostGIS are somewhat more straight forward, albeit slow sometimes, but processing comes shipped with the extension. much depends on what you plan to do with those intersections I'd say.
– ThingumaBobMay 2 '18 at 20:02

@ThingumaBob I have 40m buildings in a separate table to associate with their heights from Lidar (an average height of the Lidar points that fall into the single building shape)
– RandomizeMay 2 '18 at 20:17

1 Answer
1

The .asc file is a raster format know as ARC/INFO ASCII GRID (also known as ESRI ASCII raster) (see for example, here and here). It serves mostly the purpose of exchanging data among software/platforms.

As others have pointed out, raster2pgsql is a tool which can import .asc files to PostgreSQL. The syntax is:

It creates a new table (-c) named 'sometable' within schema named 'somescheme' and imports all .asc files within 'path_to_folder'.

All files are assigned the Coordinate Reference System (-s) equal to 3857 (this is the EPSG code); and indexed (-I). Moreover, the command line adds a column in 'sometable' to store each .asc filename (-F). Last, -t tiles each raster with both width and height as 128 pixels. This is helpful to improve performance in polygon/raster overlay operations (see for example, Importing multiple .asc files into PostGIS violates check constraint. Why?).