Long story short, I'm looking to take 1/3 arc-second 1x1 degree contour shapefiles from the USGS National Map Viewer and transform that into a contoured map of a particular state, but am encountering some significant processing problems along the way. Question is in bold near the end of the post.
To download the maps, I selected all 3DEP Elevation Products, then downloaded the 1/3 arc-second 1x1 degree quads that covered at least part of the state I'm interested in (California). This was easy.
I then used
ogr2ogr to merge the contour quads into a large grid with the help of a shell script that I wrote, shown below:
#!/bin/bash ogr2ogrdir='' directory='/' output='' cd $directory || exit i=1 while IFS= read -r -d '' shpfile do if [ ! -e $directory/$output ] then echo "[$i] Creating $output from shapefile $shpfile..." $ogr2ogrdir -f 'esri shapefile' $directory/$output "$shpfile" else echo "[$i] Appending shapefile $shpfile to $output..." $ogr2ogrdir -f 'esri shapefile' -update -append $directory/$output "$shpfile" fi ((i++)) done < <(find . -name '*.shp' -print0)
ogr2ogr does not support the generation of files larger than 4GB. California was looking likely to be closer to 6GB. To work around this, I picked an arbitrary minute of latitude to divide California into northern and southern sections, and then merged the maps into two files. This produced two shapefiles of approximately 3GB each, looking like the following images. After some processing to remove contour lines outside of the state boundary (
Vector > Geoprocessing Tools > Clip using a state boundary polygon as the clip mask), here is what the two files look like from a screenshot from QGIS below.
What I'd now like to do is merge these two separate files into a single state shapefile of contour lines. But, I'm encountering issues with QGIS. I've tried
Vector > Data Management Tools > Merge Vector Layers in QGIS, but sadly the output is not what I'm expecting. As you can see in the image below, some (why?) of the southern CA original quads in the southern CA shapefile are missing in the final merged product.
I'm not even sure why the artifacting is even occurring along the original quadrangle lines - ogr2ogr supposedly merged them, or at least that's my understanding of the situation.
How can I resolve this issue to produce a clean output of contour lines for the state of California in a single shapefile?
Additionally, I'm noticing at the boundary between my northern and southern demarcation point, I'm getting some misalignment between the contour files. Shown in the image below is the contour lines intersecting at the western point of the state at 41 degrees latitude. Could this be causing the error I'm seeing above?