Saturday, November 21, 2026

ESRI File Geodatabase timestamps file

 I was working with the GDAL tests for the OpenFileGDB driver and got flagged for having a DOS executable in a zip. And if you just rely on the unix `file` command, that is what it appears to be - a 400 byte DOS executable:

file timestamps
timestamps: DOS executable (block device driver,32-bit sector-support)

But if I was Gemini flash to evaluate it, I got a very nice explanation of what is inside of that file:

Analysis of timestamps in ESSENCE_NAIPF_ORI_PROV_sub93.gdb

Summary

timestamps is a 400-byte binary system file inside an Esri File Geodatabase (.gdb) directory (specifically an ArcGIS 9.3 File Geodatabase, GDB_Release 2.3.0). Although the Unix file utility identifies it as a DOS block device driver, that classification is a false positive caused by its initial bytes (ff ff ff ff 06 00 00 00).

The file is actually an array of 100 little-endian 32-bit signed integers (int32) (slots 0–99), where:

  • 90 slots are 0xffffffff (-1, uninitialized/unused), and
  • 10 slots hold small non-negative integers (0 through 10), all corresponding to GDB_* system catalog tables (a00000001–a0000001c).

1. Unix file Output and Why It Triggers a False Positive

Running file on timestamps produces:

$ file timestamps
timestamps: DOS executable (block device driver,32-bit sector-support)

$ file -i timestamps
timestamps: application/x-dosdriver; charset=binary

$ file -k timestamps
timestamps: DOS executable (block device driver,32-bit sector-support)\012- data

Tracing with file -d timestamps (file-5.46) against magic/Magdir/msdos explains why the heuristic matches:

  1. Driver chain header (0 ulequad&0x07a0ffffffff 0xffffffff): Bytes 0..7 are ff ff ff ff 06 00 00 00 (little-endian 0x00000006ffffffff). The leading 0xffffffff matches an MS-DOS device driver's "next driver" end-of-chain sentinel, and the reserved bits checked by mask 0x07a0 in bytes 4..5 are zero.
  2. Exclusion checks:
    • Offset 4..7 (06 00 00 00) is not 0x14000000 (skip guard for OS/2 INI files).
    • Offset 10..17 (ff ff 00 00 00 00 ff ff) is non-zero (>10 ubequad !0, skip guard for empty-name OOXML fragments). Notice that at least 18 bytes are required to pass this check (file reports data on the first 8 bytes alone, and reports 400 bytes of 0xff as ISO-8859 text, with very long lines (400), with no line terminators).
  3. Attribute word decoding at offset 4 (0x0006):
    • Bit 15 (0x8000) is 0 → prints block device driver.
    • Byte 12 (0x00 < 0x2f) and offset 22 (0x00) fail ASCII driver-name checks, so no driver name is emitted.
    • Bit 1 (0x0002) is 1 → prints ,32-bit sector-.
    • Bitmask 0x4842 is non-zero (0x0006 & 0x4842 == 2) → prints support.

2. File Geodatabase Role & Binary Layout

Inside an Esri File Geodatabase folder, timestamps (alongside gdb) is a required workspace-level marker/control file needed for ArcGIS to recognize the .gdb directory as a geodatabase rather than an ordinary folder. In GDAL's OpenFileGDB write driver (OGROpenFileGDBDataSource::Create()), a newly created geodatabase initializes timestamps to 400 bytes of 0xff (100 × -1).

Raw Hex Dump (400 bytes)

00000000: ffff ffff 0600 0000 ffff ffff 0000 0000  ................
00000010: ffff ffff 0200 0000 0300 0000 0200 0000  ................
00000020: 0200 0000 ffff ffff ffff ffff ffff ffff  ................
00000030: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000040: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000050: ffff ffff ffff ffff ffff ffff 0000 0000  ................
00000060: 0000 0000 ffff ffff ffff ffff 0800 0000  ................
00000070: 0a00 0000 ffff ffff ffff ffff ffff ffff  ................
00000080..0000018f: all bytes 0xff

Mapping of Non--1 Slots to GDB_SystemCatalog

Querying GDB_SystemCatalog (a00000001.gdbtable, which lists 38 active tables plus deleted row 38) maps every slot index i directly to table ID a<i:08x>:

Slot Index Byte Offset int32 Value Table ID GDB_SystemCatalog Name FileFormat Present on Disk
1 0x04 6 a00000001 GDB_SystemCatalog 0 Yes (a00000001.gdbtable)
3 0x0c 0 a00000003 GDB_SpatialRefs 0 Yes (a00000003.gdbtable)
5 0x14 2 a00000005 GDB_FeatureDataset 0 Yes (a00000005.gdbtable)
6 0x18 3 a00000006 GDB_ObjectClasses 0 Yes (a00000006.gdbtable)
7 0x1c 2 a00000007 GDB_FeatureClasses 0 Yes (a00000007.gdbtable)
8 0x20 2 a00000008 GDB_FieldInfo 0 Yes (a00000008.gdbtable)
23 0x5c 0 a00000017 GDB_DefaultValues 0 Yes (a00000017.gdbtable)
24 0x60 0 a00000018 GDB_Subtypes 0 Yes (a00000018.gdbtable)
27 0x6c 8 a0000001b GDB_CodedDomains 2 No
28 0x70 10 a0000001c GDB_UserMetadata 0 Yes (a0000001c.gdbtable)

All other slots—including 2 (GDB_DBTune), 4 (GDB_Release), 9–22, 25–26, 29–37, 38 (deleted entry for DDE_ESSEN_NAIPF_ORI_VUE in a00000001.gdbtable), 39 (0x27, DDE_ESSEN_NAIPF_ORI_VUE in a00000027.gdbtable), and 40–99—are -1 (0xffffffff).

3. Interpretation of the Values (Inferred Semantics)

Because Esri's File Geodatabase format is proprietary and GDAL neither documents nor updates the slot contents, the exact meaning of the integers is inferred from the dataset metadata and cross-checking other .gdb fixtures:

  • Not wall-clock timestamps: File Geodatabase date/time column values use IEEE 754 float64 days since 1899-12-30; the values in timestamps are small int32 integers (0–10 here, and up to 4206 in other GDAL .gdb test fixtures).
  • Logical revision / cache-invalidation counters for system tables: Across GDAL's .gdb test fixtures (both ArcGIS 9.x and 10.x), only GDB_* system tables (1–8, 23–28 in v9.x; 1–7 in v10.x) hold non--1 values. In this dataset, GDB_UserMetadata records an UncompressFileGeodatabaseData operation on 2014-09-30, and the tables showing .freelist files and 2014-09-30 mtimes (a00000001, a00000006, a00000008, a0000001c) have incremented counters (6, 3, 2, 10), while GDB_CodedDomains retains 8 even though its table currently has FileFormat=2 (unmaterialized/empty on disk). This matches per-table logical timestamps (monotonic change counters) used to detect edits to system catalog tables without scanning them.

Sunday, November 15, 2026

Creating a synthetic test GeoTIFF image

 Recently, I was working on overview algorithms for Cloud Optimized GeoTIFFs (COGs). These extra smaller versions of a larger image are embedded in an image to help algorithms present a representation of the overall full resolution data much quicker. Downsampling data ahead of time can greatly optimize many processes that don’t need the full resolution data. The easiest task to think about that is benefited by overviews is visualization by humans. If you are zoomed out on a map, you would like to see an overview of what data is in that map. If, for example, you have 1 meter data, it’s not reasonable to fetch all of that 1 meter data to downsample the data into the few pixels that will be on your screen. Having a low resolution overview means that the computer only has to fetch a few pixels and it can get the user a nice view in a short time with little work. One of the key questions then is what algorithm should we use to produce these down-sampled extra images? GDAL’s COG driver lists the possible algorithms that it has available for overviews:


OVERVIEW_RESAMPLING=[NEAREST​/​AVERAGE​/​BILINEAR​/​CUBIC​/​CUBICSPLINE​/​LANCZOS​/​MODE​/​RMS]: (GDAL >= 3.2) Resampling method used for overview generation. For paletted images, NEAREST is used by default, otherwise it is CUBIC. This overrides, for overview generation, the value of RESAMPLING if it specified.


When should I use a particular resampling algorithm and why? Some of these are fairly obvious, but some I had no intuition for. If I have categorical data where an integer in each pixel has an assigned mean (e.g., 1 is grass land, 2 is forest, 3 is paved, 4 is bare ground, 5 is buildings, … 8 is water, etc.), then it makes no sense to use an algorithm that will interpolate neighboring pixels to produce a down sampled image. If we are trying to represent 9 pixels with 1 in a lower representation, we might have 6 pixels of grass (value 1) and 3 of water (value 8). If we use an average of the neighboring pixels, we have (1 * 6 + 8 * 3) / 9. = 3.33… Sticking with an integer representation, we might then round that to 3 and declare in the overview that the pixel is paved ground. That makes no sense. It might be better to use the nearest value or the most common value (mode). For elevation data, it might be best to use a cubic or cubic spline to interpolate the best representation. But maybe not. What properties are we trying to preserve in the overview and what algorithm will achieve that goal?


For each of the algorithms, it’s possible to apply it to a bunch of sample data and see what it does. That will give us concrete examples that we can look at, build intuition, and use algorithms to evaluate. So, what types of sample data should we use? And what if different people pick different data for the same evaluation? Two satellite images of even the same location on earth are likely to have different properties. The time of day may be different, the seasons change, land use may change, etc.  And those differences might be even more dramatic if we pick different parts of the planet. If one person picked mountain forest and the other picked flat desert, then the results are likely super different.


We can have a whole library of sample images. Picking the images that should be in a catalog of key test images is challenging, but we can do it. These might include: constant images, impulse points, phase sweeps, a Siemens star, a USAF-1951 bar target, steps, slants/edges, ISO 12233 camera calibration targets, nodata zones, thin features, classes/categorical data, ramps, gradients, terraces, dipoles, peaks/valleys/saddles, satellite images, images of animals, various types of noise, text, logos, and more.


Can we create a single sample image that contains a range of data types that will cover a wide range of situations and give us carefully crafted data that can help bring out various aspects of algorithms? Why yes of course! But what should that key single image look like? I think it works well if we designate sub regions of the images (a.k.a., chips) that each contain a specific data type. That way, we only have to track one image, right? Well, we might need to have cases for integer input and floating point input images. We might need different precision (int8, uint8, … int64, uint64 and float8…float64, and a range of complex values). What about algorithms that operate on color, multispectral, or hyperspectral images? If we keep things simple, we can start with an int16 single band image and a float32 single band image.


I’ve wanted this kind of thing for a long time, but never had the time to put it together. But once I got access to Opus 5.5, I figured I’d let an LLM agent give it a go. I wrote up a prompt and had the agent work in an explicit Specification Driven Development (SDD) mode. The results are here:


https://github.com/schwehr/gdal-autotest2/tree/master/generate/example_grid


Take a look at the Product Requirements Document in PRD.md, PLAN.md, and TASKS.md to see how it progressed. It created a 6x14 grid for a total of 84 of chips. Here are the results. I’ve placed them over a red background so you can see where there are nodata values.



This is already down sampled to be on this screen, so I encourage people to play with the original. Here is GDAL’s summary of the int16 version:


gdalinfo resample_grid_int16.tif

Driver: GTiff/GeoTIFF

Files: resample_grid_int16.tif

Size is 6848, 15840

Coordinate System is:

PROJCRS["WGS 84 / Pseudo-Mercator",


[SNIP]


   ID["EPSG",3857]]

Data axis to CRS axis mapping: 1,2

Origin = (0.000000000000000,0.000000000000000)

Pixel Size = (10.000000000000000,-10.000000000000000)

Metadata:

  GDAL_VERSION=3.12.0dev-0eb3a1a5fa

  RESAMPLE_GRID_DTYPE=int16

  RESAMPLE_GRID_LAYOUT={"width": 6848, "height": 15840, "raw_width": 6844, "raw_height": 15836, "panel_px": 1024, "guard_px": 100, "margin_px": 100, "columns": 6, "rows": 14, "overview_factors": [2, 4, 8, 16, 32]}

  RESAMPLE_GRID_SEED=559677208

  RESAMPLE_GRID_VERSION=0.1.0

  AREA_OR_POINT=Area

Image Structure Metadata:

  COMPRESSION=ZSTD

  INTERLEAVE=BAND

  PREDICTOR=2

Corner Coordinates:

Upper Left  (   0.0000000,   0.0000000) (  0d 0' 0.01"E,  0d 0' 0.01"N)

Lower Left  (       0.000, -158400.000) (  0d 0' 0.01"E,  1d25'22.03"S)

Upper Right (   68480.000,       0.000) (  0d36'54.60"E,  0d 0' 0.01"N)

Lower Right (   68480.000, -158400.000) (  0d36'54.60"E,  1d25'22.03"S)

Center      (   34240.000,  -79200.000) (  0d18'27.30"E,  0d42'41.21"S)

Band 1 Block=512x512 Type=Int16, ColorInterp=Gray

  NoData Value=-9999


It’s a GeoTIFF, so you can add it to a map in QGIS, Earth Engine, or other GIS tools. You can also use gdal_translate to place it anywhere you’d like on a globe. I used that idea combined with `gdal_translate` using the COG driver with the various overview algorithms to see how they work. The results have been super useful for me so far. Here is placing it on a map:



I encourage people to try out this image when learning new image processing / GIS algorithms. Or make your own calibration / test images that fit your needs. Everything in the sample image is LLM generated except that cat image (from SKLearn), the font for the text, and the (now old) Earth Engine logo. You are welcome to the machine generated images under the CC0 license.




 


Friday, November 6, 2026

LLM generated C++ test coverage of GDAL

 First off, even if GDAL were up for taking this LLM generated code by policy, the following is not ready. To start with, there are many quirks in there specific to the google3 monorepo.

For the local use of GDAL in google3, I've been in need of better C++ test coverage of GDAL to guard against trouble when updating from GDAL's master branch. I started gdal-autotest2 more than 10 years ago. It was slow going to get the 22K lines of C++ test code that I had in there. So, I've taken a go at creating a multiagent setup with one agent trying to write per GDAL C++ file test coverage that is > 90% test coverage and have multiple tools and LLM agents review the code. The result is 360K more lines of googletest based C++ test code. It's set up to not use files from disk. As such, the whole thing builds and runs much quicker than the python test code (which is still used). The tests have lots of redundancy and google3 only has a small subset of GDAL's drivers in it. A test suite covering all the GDAL drivers done this way would likely have more than double the lines of code. Be warned that these new tests are not human curated, so there are plenty of silly tests. But even with all those caveats, some folks may find the code useful. The repo is Apache 2.0 license, but I am fine with the license changing to MIT licensed for folks porting it to other repositories. 

https://github.com/schwehr/gdal-autotest2/tree/master/cpp

I'm planning to do the same in cpp/third_party for geos, hdf4, hdf5, libgeotiff, netcdf, proj, and maybe some others, but no promises. 

I see these tests as being in a similar category to fuzzers + a corpus of files that cover as many branches as possible. I used to maintain order 1M files for fuzzers to run though on each commit, but that had diminishing returns and was hard to maintain/update.

Tuesday, September 8, 2026

Surprised by the surprise about LLMs and agents

Two things recently surprised me in the world of LLMs and agent harnesses. My surprise is that these people are surprised by what they found.

  1. Steve Gibson and Leo Laporte were surprised that agents are just a stream of tokens with tool usage and other things are just tokens in the stream, which are just hints.
  2. OpenAI, Anthropic, and others are surprised that LLMs + harnesses under test escaped and cause trouble in multiple rounds.
First, but newer, SN 1093 (Security Now) has a section "Tokens in the Stream" talking about Prompt Injection as Role Confusion. I am surprised by Steve and Leos' surprise. Why? LLMs are just token streams and all this interaction is just convention. It was pretty obvious from the papers that Steve has said he has been reading, listening to Andrej Karpathy's lectures, and just observing these things how the model works. I have hated this phrase when I heard it in my graduate classes, but now I'm going to say it: "It obviously follows" that these things are a security catastrophe where we can do no better than train out known attacks and whack-a-mole on bad patterns in the harnesses. Think SQL injections, but worse as there very limited boundaries.

Second, people testing new models should always assume the worst and there are established ways to handle the worse. If you are testing a new model trained on the internet, it has all of the tricks and bad things on the internet for security holes, side channels, and the likes. Humans have been writing about spy-versus-spy and the like for thousands of years. Every silly hack that ever has been written about is in their training dataset. That includes side channels like blinking LEDs, pulsing power usage, vibration, skewing timings, writing data in odd places (e.g., DNS records, filename paths, metadata fields, steganography). Heck, I baked metadata into file name paths for Mars mission data files: the path to a file told you the spacecraft, the sensor, the sensor settings, the processing type, when it was collected, and more all just by parsing the full file path. These machines have IRC logs from hacking sessions. They have archives of CVEs, CWEs, and more. They probably have scrapings of the old rootshell dot org that I used back in the 90s. And they have trained on ridiculous amounts of source code.

If you want to test a new LLM, then you should really secure it. Hearing about the mistakes that the testers make is more surprising to me than anything. My not test in on a system that is physically disconnected the world during testing? Separate the network write lines and use a read only optical serial tap to follow the machines progress. When you are done with the test, power down the system, scrub the disks, BIOSes, and anything else the system could mutate. Treat all the read data as toxic and "red shell" it when inspecting it. It's not hard to create some really nasty stuff. For example, I have unintentionally created image files during fuzzing that took down the entire machine it was on if the desktop system ever touched the file (thank you OS for being helpful and scanning all new files so you are ready to help me search for them).

I guess what is really old is new. Sigh.

Written without aid of AI.

Monday, August 3, 2026

LLMs aren't so smart

 I'm working on updating my noaadata packages using spec-driven development (SDD). This stuff is definitely got a ways to go on smarts. It's doing plenty very well, but then it did this where it changed "Viet Nam" to "Viet Name" rather than "Vietnam". Sigh. I fixed it in 7233879.

--- a/data/mmsi_prefix.sql
+++ b/data/mmsi_prefix.sql
@@ -203,7 +203,7 @@ INSERT INTO "mmsi_prefix" VALUES(565,'Singapore (Republic of)','Singapore');
 INSERT INTO "mmsi_prefix" VALUES(567,'Thailand','Thailand');
 INSERT INTO "mmsi_prefix" VALUES(570,'Tonga (Kingdom of)','Tonga');
 INSERT INTO "mmsi_prefix" VALUES(572,'Tuvalu','Tuvalu');
-INSERT INTO "mmsi_prefix" VALUES(574,'Viet Nam (Socialist Republic of)','Viet Nam');
+INSERT INTO "mmsi_prefix" VALUES(574,'Viet Name (Socialist Republic of)','Viet Name');
 INSERT INTO "mmsi_prefix" VALUES(576,'Vanuatu (Republic of)','Vanuatu');
 INSERT INTO "mmsi_prefix" VALUES(578,'Wallis and Futuna Islands','Wallis and Futuna Islands');
 INSERT INTO "mmsi_prefix" VALUES(601,'South Africa (Republic of)','South Africa');

Tuesday, July 21, 2026

BitVector 0.0.4 - pylint focused

I'm learning lots. I'd love feedback and suggestions from the python community.

AI generated summary:

The v0.0.4 release of bitvector-modern primarily focuses on extensive code cleanup, linter adherence, and testing improvements. A major portion of the updates involves setting up pylint configurations (including the pylint-pytest plugin) and refactoring code across the repository to address linter rules—such as updating function/class docstrings, switching to f-strings and with statements, simplifying chained comparisons, and cleaning up break, return, and raise statements. Additionally, the release enhances overall quality by expanding unit test coverage for rotation logic, bit shifts, and BitVector methods such as reset(), __int__, __getitem__, and __setitem__, while resolving a bug related to slice assignment length calculations with negative start indices.

Sunday, July 19, 2026

bitvector-modern release 0.0.3

 I just did the first proper release of bitvector-modern with version 0.0.3. I hadn't setup 2 factor authentication (2FA) for my personal PyPI identity, but now I have so I can actually send updates out. I have been out of town with only mobile phone access to the internet, so I have been doing a bunch of updates to the package via Google Jules. That process went really well in general. I had some trouble getting it to do more ambitious changes line adding mmap and numpy based implementations, but you should see from release notes that there were plenty of successes.

Sadly, I did the 0.0.2 release just before this incorrectly, so that's where the changes are listed, but that triggered a 0.0.1 pypi release. I could yank it, but I don't think I need to as nothing is broken. The changes for 0.0.3 are in 0.0.1 on pypi.

I wouldn't recommend using bitvector-modern now for anything other than experimental work as I intend to rework the API in a few intrusive ways. Top of the list is simplifying __init__ and putting the extra functionality into class methods of the for from_. I have already removed the filename and filepointer args from __init__, but I have yet to add back file reading outside of __init__.

At this point, there are quite a few performance improvements over the old library. For starters, I switched the array.array storage from 16-bit to 64-bit blocks. This means that BitVectors smaller than 48-bits will take more storage, but that should not be a problem unless folks are working with large numbers of very small bitvectors that have to remain in memory. With the in-progress Protocol class work, that issue should be mitigated as the package should be able to let the user pick an implementation that works best with their use case.

I hope to start working on my old noaadata package soon and port it to bitvector-modern. I'm excited for the increase performance and improved usability.

The release:

The detailed release notes are here:

From the 0.0.2 release notes: